private 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;
    }
private 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;
    }
private 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 ; }
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
Retrieve or create a command instance of the given name .