Last active
April 12, 2016 19:40
Revisions
-
NamelessCoder revised this gist
Apr 12, 2016 . 1 changed file with 27 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,29 +1,51 @@ <?php /** * Content Element Definition Provider * * Contains methods to either remove/change or add * content definitions to the new content wizard * and content type selectors. * * Same instance is used for removing and adding * definitions (for performance and in case it * needs an internal state for some reason). * * To generate the final list of content element * definitions that are available, every Provider * must be consulted in the order they were registered. * * A default Provider can be shipped which reads * available definitions from pageTSconfig and has * an empty modifyContentElementDefinitions() method. */ class ContentElementDefinitionProvider extends AbstractContentElementDefinitionProvider implements ContentDefinitionProviderInterface { /** * DEFINED ON INTERFACE * * Remove from or change in current definitions. Return from this method the new * array of definitions after removing unwanted or changing wanted definitions. * * @param ContentElementDefinition[] $currentDefinitions * @return ContentElementDefinition[] */ public function modifyContentElementDefinitions(array $currentDefinitions) { $newDefinitions = $currentDefinitions; // removing definitions unset($newDefinitions['media'], $newDefinitions['shortcut']); // changing definitions $newDefinitions['text']->setIcon('mycooltexticon.png'); return $newDefinitions; } /** * DEFINED ON INTERFACE * * Add new content definitions. Return from this method the new * array of definitions that should be *added* to existing ones. * * @return ContentElementDefinition[] */ -
NamelessCoder created this gist
Apr 12, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ <?php class ContentElementDefinitionProvider extends AbstractContentElementDefinitionProvider implements ContentDefinitionProviderInterface { /** * DEFINED ON INTERFACE * * Manipulate current definitions. Return from this method the new * array of definitions * * @param ContentElementDefinition[] $currentDefinitions * @return ContentElementDefinition[] */ public function removeContentElementDefinitions(array $currentDefinitions) { $newDefinitions = $currentDefinitions; unset($newDefinitions['media'], $newDefinitions['shortcut']); return $newDefinitions; } /** * DEFINED ON INTERFACE * * Manipulate current definitions. Return from this method the new * array of definitions * * @return ContentElementDefinition[] */ public function addContentElementDefinitions() { $existingGroup = $this->getExistingContentElementDefinitionGroupByName('general'); $newContentDefinitionOne = new ContentElementDefinition(); $newContentDefinitionOne->setContentElementDefinitionGroup($existingGroup); $newContentDefinitionOne->setCType('my_customtype'); $newContentDefinitionOne->setIcon('...'); $newContentDefinitionOne = new ContentElementDefinition(); $newContentDefinitionTwo->setContentElementDefinitionGroup(new ContentElementDefinitionGroup('mynewgroup')); $newContentDefinitionTwo->setCType('...'); return array( $newContentDefinitionOne, $newContentDefinitionTwo ); } }