Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getData($entity = null, array $options = []) : array
 {
     $items = [];
     if (array_key_exists('actions', $options)) {
         $actions = $options['actions'];
         foreach ($actions as $action) {
             $path = array_key_exists('path', $action) ? $action['path'] : null;
             $name = array_key_exists('name', $action) ? $action['name'] : null;
             $icon = array_key_exists('icon', $action) ? $action['icon'] : null;
             $parameters = array_key_exists('parameters', $action) ? $action['parameters'] : [];
             $parameters['id'] = $entity->getId();
             $items[] = $this->actionFactory->get($path, $name, $icon, $parameters);
         }
     }
     return ['actions' => $items];
 }
 public function testGetNameAndIconNull()
 {
     $actionFactory = new ActionFactory();
     $this->setExpectedException('InvalidArgumentException');
     $actionFactory->get("path", null, null, []);
 }
Example #3
0
 /**
  * @param string $path
  * @param string|null $name
  * @param string|null $icon
  * @param array $parameters
  * @return ActionCollection
  */
 public function add(string $path, string $name = null, string $icon = null, array $parameters = []) : self
 {
     $element = $this->factory->get($path, $name, $icon, $parameters);
     $this->items[] = $element;
     return $this;
 }