/** * {@inheritdoc} */ public function addDefinition($id, array $definition) { if ($this->treeStorage->load($id) || $id === '') { throw new PluginException(String::format('The ID @id already exists as a plugin definition or is not valid', array('@id' => $id))); } // Add defaults, so there is no requirement to specify everything. $this->processDefinition($definition, $id); // Store the new link in the tree. $this->treeStorage->save($definition); return $this->createInstance($id); }
/** * {@inheritdoc} */ public function addDefinition($id, array $definition) { if ($this->treeStorage->load($id)) { throw new PluginException("The menu link ID {$id} already exists as a plugin definition"); } elseif ($id === '') { throw new PluginException("The menu link ID cannot be empty"); } // Add defaults, so there is no requirement to specify everything. $this->processDefinition($definition, $id); // Store the new link in the tree. $this->treeStorage->save($definition); return $this->createInstance($id); }