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