/** * @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 = []; }
/** * @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; }
/** * @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); }
/** * @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; }