Sulu\Component\Content\Extension\ExtensionManager::getExtension PHP Méthode

getExtension() public méthode

public getExtension ( $structureType, $name )
    public function getExtension($structureType, $name)
    {
        $extensions = $this->getExtensions($structureType);
        if (!isset($extensions[$name])) {
            throw new \InvalidArgumentException(sprintf('Extension "%s" has not been registered for structure type "%s", registred extensions: "%s"', $name, $structureType, implode('", "', array_keys($extensions))));
        }
        return isset($extensions[$name]) ? $extensions[$name] : null;
    }

Usage Example

Exemple #1
0
 /**
  * TODO: Refactor this .. this should be handled in a listener or in the form, or something
  * {@inheritdoc}
  */
 public function saveExtension($uuid, $data, $extensionName, $webspaceKey, $locale, $userId)
 {
     $document = $this->loadDocument($uuid, $locale, array('exclude_ghost' => true));
     if ($document === null) {
         throw new TranslatedNodeNotFoundException($uuid, $locale);
     }
     if (!$document instanceof ExtensionBehavior) {
         throw new \RuntimeException(sprintf('Document of class "%s" must implement the ExtensionableBehavior if it is to be extended', get_class($document)));
     }
     // save data of extensions
     $extension = $this->structureManager->getExtension($document->getStructureType(), $extensionName);
     $node = $this->inspector->getNode($document);
     $extension->save($node, $data, $webspaceKey, $locale);
     $extensionData = $extension->load($node, $webspaceKey, $locale);
     $document->setExtension($extension->getName(), $extensionData);
     $this->documentManager->flush();
     $structure = $this->documentToStructure($document);
     $event = new ContentNodeEvent($node, $structure);
     $this->eventDispatcher->dispatch(ContentEvents::NODE_POST_SAVE, $event);
     return $structure;
 }
All Usage Examples Of Sulu\Component\Content\Extension\ExtensionManager::getExtension