| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/plugins/fluentform/app/Services/FormBuilder/ |
Upload File : |
<?php
namespace FluentForm\App\Services\FormBuilder;
use Closure;
class Components implements \JsonSerializable
{
/**
* $items [Components list]
*
* @var array
*/
protected $items = [];
/**
* Build the object instance
*
* @param array $items
*/
public function __construct(array $items)
{
$this->items = $items;
}
/**
* Add a component into list [$items]
*
* @param string $name
* @param array $component
* @param string $group ['general'|'advanced']
*
* @return $this
*/
public function add($name, array $component, $group)
{
if (isset($this->items[$group])) {
$this->items[$group][$name] = $component;
}
return $this;
}
/**
* Remove a component from the list [$items]
*
* @param string $name
* @param string $group ['general'|'advanced']
*
* @return $this
*/
public function remove($name, $group)
{
if (isset($this->items[$group])) {
unset($this->items[$group][$name]);
}
return $this;
}
/**
* Modify an existing component
*
* @param string $name
* @param Closure $callback [to modify the component within]
* @param string $group
*
* @return $this
*/
public function update($name, Closure $callback, $group)
{
$element = $callback($this->items[$group][$name]);
$this->items[$group][$name] = $element;
return $this;
}
/**
* Sort the components in list [$items]
*
* @param string $sortBy [key to sort by]
*
* @return $this
*/
public function sort($sortBy = 'index')
{
foreach ($this->items as $group => &$items) {
usort($items, function ($a, $b) {
if (@$a['index'] == @$b['index']) {
return 0;
}
return @$a['index'] < @$b['index'] ? -1 : 1;
});
}
return $this;
}
/**
* Return array [$items]
*
* @return array
*/
public function toArray()
{
return $this->items;
}
/**
* Return array [$items]
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
}
/**
* Getter to hook proxy call
*
* @return mixed
*/
public function __get($key)
{
if (in_array($key, ['general', 'advanced'])) {
return new GroupSetterProxy($this, $key);
}
}
}