Command/ContentTypeGroup/GenerateCommand.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        /** @var $repository Repository */
        $repository = $this->getContainer()->get('ezpublish.api.repository');

        /** @var $questionHelper QuestionHelper */
        $questionHelper = $this->getHelper('question');

        $question = new Question('Content type group name: ');
        $question->setValidator(
            array(
                'Smile\EzToolsBundle\Command\ContentTypeGroup\Validators',
                'validateContentTypeGroupName'
            )
        );

        $contentTypeGroupName = false;
        while(!$contentTypeGroupName) {
            $contentTypeGroupName = $questionHelper->ask($input, $output, $question);

            if (!$contentTypeGroupName || empty($contentTypeGroupName)) {
                $output->writeln("<error>Content type group name should only contains numbers, letters or space</error>");
            }
        }

        /** @var $configResolver ConfigResolver */
        $configResolver = $this->getContainer()->get('ezpublish.config.resolver');
        $adminID = $configResolver->getParameter('adminid', 'smile_ez_tools');

        $contentTypeGroupService = new ContentTypeGroup($repository);
        $contentTypeGroupService->setAdminID($adminID);
        try {
            $contentTypeGroupService->add($contentTypeGroupName);
            $output->writeln( "<info>Content type group created '$contentTypeGroupName'<info>");
        } catch( UnauthorizedException $e) {
            $output->writeln( "<error>" . $e->getMessage() . "</error>" );
        } catch (ForbiddenException $e ) {
            $output->writeln( "<error>" . $e->getMessage() . "</error>" );
        }
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        /** @var $repository Repository */
        $repository = $this->getContainer()->get('ezpublish.api.repository');

        /** @var $questionHelper QuestionHelper */
        $questionHelper = $this->getHelper('question');

        $question = new Question('Content type group name: ');
        $question->setValidator(
            array(
                'Smile\EzToolsBundle\Command\ContentTypeGroup\Validators',
                'validateContentTypeGroupName'
            )
        );

        $contentTypeGroupName = false;
        while(!$contentTypeGroupName) {
            $contentTypeGroupName = $questionHelper->ask($input, $output, $question);

            if (!$contentTypeGroupName || empty($contentTypeGroupName)) {
                $output->writeln("<error>Content type group name should only contains numbers, letters or space</error>");
            }
        }

        /** @var $configResolver ConfigResolver */
        $configResolver = $this->getContainer()->get('ezpublish.config.resolver');
        $adminID = $configResolver->getParameter('adminid', 'smile_ez_tools');

        $contentTypeGroupService = new ContentTypeGroup($repository);
        $contentTypeGroupService->setAdminID($adminID);
        try {
            $contentTypeGroupService->add($contentTypeGroupName);
            $output->writeln( "<info>Content type group created '$contentTypeGroupName'<info>");
        } catch( UnauthorizedException $e) {
            $output->writeln( "<error>" . $e->getMessage() . "</error>" );
        } catch (ForbiddenException $e ) {
            $output->writeln( "<error>" . $e->getMessage() . "</error>" );
        }
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { /** @var $repository Repository */ $ repository = $ this -> getContainer ( ) -> get ( 'ezpublish.api.repository' ) ; /** @var $questionHelper QuestionHelper */ $ questionHelper = $ this -> getHelper ( 'question' ) ; $ question = new Question ( 'Content type group name: ' ) ; $ question -> setValidator ( array ( 'Smile\EzToolsBundle\Command\ContentTypeGroup\Validators' , 'validateContentTypeGroupName' ) ) ; $ contentTypeGroupName = false ; while ( ! $ contentTypeGroupName ) { $ contentTypeGroupName = $ questionHelper -> ask ( $ input , $ output , $ question ) ; if ( ! $ contentTypeGroupName || empty ( $ contentTypeGroupName ) ) { $ output -> writeln ( "<error>Content type group name should only contains numbers, letters or space</error>" ) ; } } /** @var $configResolver ConfigResolver */ $ configResolver = $ this -> getContainer ( ) -> get ( 'ezpublish.config.resolver' ) ; $ adminID = $ configResolver -> getParameter ( 'adminid' , 'smile_ez_tools' ) ; $ contentTypeGroupService = new ContentTypeGroup ( $ repository ) ; $ contentTypeGroupService -> setAdminID ( $ adminID ) ; try { $ contentTypeGroupService -> add ( $ contentTypeGroupName ) ; $ output -> writeln ( "<info>Content type group created '$contentTypeGroupName'<info>" ) ; } catch ( UnauthorizedException $ e ) { $ output -> writeln ( "<error>" . $ e -> getMessage ( ) . "</error>" ) ; } catch ( ForbiddenException $ e ) { $ output -> writeln ( "<error>" . $ e -> getMessage ( ) . "</error>" ) ; } }
Execute ContentTypeGroup generate command

@param InputInterface $input
@param OutputInterface $output
@return int|null|void
Execute ContentTypeGroup generate command