/** * Parse the defined model scoped operations and populate the definition. * * @param Contao2BackendViewDefinitionInterface $view The backend view configuration definition to populate. * * @return void */ protected function parseModelOperations(Contao2BackendViewDefinitionInterface $view) { $operationsDca = $this->getFromDca('list/operations'); if (!is_array($operationsDca)) { return; } $collection = $view->getModelCommands(); foreach ($operationsDca as $operationName => $operationDca) { $command = $this->createCommand($operationName, $operationDca); $collection->addCommand($command); } }
/** * Parse the defined model scoped operations and populate the definition. * * @param Contao2BackendViewDefinitionInterface $view The backend view information. * * @param IMetaModelDataDefinition $container The data container. * * @return void * * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ protected function parseModelOperations(Contao2BackendViewDefinitionInterface $view, IMetaModelDataDefinition $container) { $collection = $view->getModelCommands(); $this->createCommand($collection, 'edit', array('act' => 'edit'), 'edit.gif', array())->createCommand($collection, 'copy', array('act' => ''), 'copy.gif', array('attributes' => 'onclick="Backend.getScrollOffset();"'))->createCommand($collection, 'cut', array('act' => 'paste', 'mode' => 'cut'), 'cut.gif', array('attributes' => 'onclick="Backend.getScrollOffset();"'))->createCommand($collection, 'delete', array('act' => 'delete'), 'delete.gif', array('attributes' => sprintf('onclick="if (!confirm(\'%s\')) return false; Backend.getScrollOffset();"', $GLOBALS['TL_LANG']['MSC']['deleteConfirm'])))->createCommand($collection, 'show', array('act' => 'show'), 'show.gif', array()); if ($this->getMetaModel()->hasVariants()) { $this->createCommand($collection, 'createvariant', array('act' => 'createvariant'), 'system/modules/metamodels/assets/images/icons/variants.png', array()); } // Check if we have some children. foreach ($this->getViewCombinations()->getParentedInputScreens($container->getName()) as $screen) { $metaModel = $screen->getMetaModel(); $arrCaption = array('', sprintf($GLOBALS['TL_LANG']['MSC']['metamodel_edit_as_child']['label'], $metaModel->getName())); foreach ($screen->getBackendCaption() as $arrLangEntry) { if ($arrLangEntry['label'] != '' && $arrLangEntry['langcode'] == $GLOBALS['TL_LANGUAGE']) { $arrCaption = array($arrLangEntry['description'], $arrLangEntry['label']); } } $this->createCommand($collection, 'edit_' . $metaModel->getTableName(), array('table' => $metaModel->getTableName()), self::getBackendIcon($screen->getIcon()), array('attributes' => 'onclick="Backend.getScrollOffset();"', 'label' => $arrCaption[0], 'description' => $arrCaption[1], 'idparam' => 'pid')); } $event = new BuildMetaModelOperationsEvent($this->getMetaModel(), $container, $this->getInputScreenDetails(), $this); $this->serviceContainer->getEventDispatcher()->dispatch($event::NAME, $event); }