Example #1
0
 /**
  * @param GadgetInterface $gadget
  * @param string $title
  */
 public function __construct(GadgetInterface $gadget, $title)
 {
     $this->gadget = $gadget->getName();
     $this->title = $title;
     $this->level = self::LEVEL_NOTICE;
     $this->extraInformation = [];
 }
Example #2
0
 /**
  * @param GadgetInterface $gadget
  * @throws \Exception
  */
 public function add(GadgetInterface $gadget)
 {
     if ($this->has($gadget->getName())) {
         throw new \Exception(sprintf('gadget with the name "%s" exists already', $gadget->getName()));
     }
     $this->gadgets[$gadget->getName()] = $gadget;
 }
Example #3
0
 /**
  * @param GadgetInterface $gadget
  * @param array $config
  * @return array
  */
 protected function resolve(GadgetInterface $gadget, array $config)
 {
     $builder = new TreeBuilder();
     $node = $builder->root($gadget->getName(), 'array', new NodeBuilder());
     $gadget->configure($node);
     $tree = $builder->buildTree();
     $config = $tree->normalize($config);
     return $tree->finalize($config);
 }
Example #4
0
 /**
  * @param GadgetInterface $gadget
  * @param string $path
  * @param array $options
  * @param AbstractLogger $logger
  * @return Result
  */
 private function executeGadget(GadgetInterface $gadget, $path, array $options, AbstractLogger $logger)
 {
     $event = new GadgetEvent($path, $options, $gadget, $logger);
     $this->eventDispatcher->dispatch(Events::PRE_GADGET, $event);
     $options = $event->getOptions();
     $result = $gadget->run($path, $options, $logger);
     $event = new GadgetResultEvent($path, $options, $gadget, $result, $logger);
     $this->eventDispatcher->dispatch(Events::POST_GADGET, $event);
     return $result;
 }