コード例 #1
0
 /**
  * Merge in registered properties.
  *
  * @param TreeBuilder $builder
  */
 public function merge(TreeBuilder $builder)
 {
     $buttons = $builder->getButtons();
     foreach ($buttons as &$parameters) {
         if ($button = $this->buttons->get(array_get($parameters, 'button'))) {
             $parameters = array_replace_recursive($button, $parameters);
         }
     }
     $builder->setButtons($buttons);
 }
コード例 #2
0
 /**
  * Merge in registered properties.
  *
  * @param FormBuilder $builder
  */
 public function merge(FormBuilder $builder)
 {
     $actions = $builder->getActions();
     foreach ($actions as &$parameters) {
         $action = $original = array_pull($parameters, 'action');
         if ($action && ($action = $this->actions->get($action))) {
             $parameters = array_replace_recursive($action, array_except($parameters, 'action'));
         }
         $button = array_get($parameters, 'button', $original);
         if ($button && ($button = $this->buttons->get($button))) {
             $parameters = array_replace_recursive($button, array_except($parameters, 'button'));
         }
     }
     $builder->setActions($actions);
 }
コード例 #3
0
 /**
  * Merge in registered properties.
  *
  * @param ControlPanelBuilder $builder
  */
 public function merge(ControlPanelBuilder $builder)
 {
     $buttons = $builder->getButtons();
     foreach ($buttons as &$parameters) {
         if (!($button = array_get($parameters, 'button'))) {
             continue;
         }
         if ($button && ($button = $this->buttons->get($button))) {
             $parameters = array_replace_recursive($button, $parameters);
         }
         $button = array_get($parameters, 'button', $button);
         if ($button && ($button = $this->buttons->get($button))) {
             $parameters = array_replace_recursive($button, $parameters);
         }
     }
     $builder->setButtons($buttons);
 }
コード例 #4
0
 /**
  * Make a button.
  *
  * @param  array           $parameters
  * @return ButtonInterface
  */
 public function make(array $parameters)
 {
     $button = array_get($parameters, 'button');
     if ($button && ($registered = $this->buttons->get($button))) {
         $parameters = array_replace_recursive($registered, array_except($parameters, 'button'));
     }
     $parameters = $this->translator->translate($parameters);
     if (!array_get($parameters, 'button') || !class_exists(array_get($parameters, 'button'))) {
         array_set($parameters, 'button', $this->button);
     }
     /* @var ButtonInterface $button */
     $button = app()->make(array_get($parameters, 'button'), $parameters);
     $this->hydrator->hydrate($button, $parameters);
     if (($permission = $button->getPermission()) && !$this->authorizer->authorize($permission)) {
         $button->setEnabled(false);
     }
     return $button;
 }