/**
  * Generate the toggle command information.
  *
  * @param CommandCollectionInterface $commands    The already existing commands.
  *
  * @param IAttribute                 $attribute   The attribute.
  *
  * @param string                     $commandName The name of the new command.
  *
  * @param string                     $class       The name of the CSS class for the command.
  *
  * @param string                     $language    The language name.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 protected function generateToggleCommand($commands, $attribute, $commandName, $class, $language)
 {
     if (!$commands->hasCommandNamed($commandName)) {
         $toggle = new TranslatedToggleCommand();
         $toggle->setLanguage($language)->setToggleProperty($attribute->getColName())->setName($commandName)->setLabel($GLOBALS['TL_LANG']['MSC']['metamodelattribute_translatedcheckbox']['toggle'][0])->setDescription(sprintf($GLOBALS['TL_LANG']['MSC']['metamodelattribute_translatedcheckbox']['toggle'][1], $attribute->getName(), $language));
         $extra = $toggle->getExtra();
         $extra['icon'] = 'visible.gif';
         $extra['class'] = $class;
         if ($commands->hasCommandNamed('show')) {
             $info = $commands->getCommandNamed('show');
         } else {
             $info = null;
         }
         $commands->addCommand($toggle, $info);
     }
 }
예제 #2
0
파일: Builder.php 프로젝트: zonky2/core
 /**
  * Retrieve or create a command instance of the given name.
  *
  * @param CommandCollectionInterface $collection    The command collection.
  *
  * @param string                     $operationName The name of the operation.
  *
  * @return CommandInterface
  */
 protected function getCommandInstance(CommandCollectionInterface $collection, $operationName)
 {
     if ($collection->hasCommandNamed($operationName)) {
         $command = $collection->getCommandNamed($operationName);
     } else {
         switch ($operationName) {
             case 'cut':
                 $command = new CutCommand();
                 break;
             case 'copy':
                 $command = new CopyCommand();
                 break;
             default:
                 $command = new Command();
         }
         $command->setName($operationName);
         $collection->addCommand($command);
     }
     return $command;
 }