-
-
Save joaoinacio/de4492f763de8fd8441ef7e75aa8f218 to your computer and use it in GitHub Desktop.
This file contains 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 characters
<?php | |
namespace Test\Bundle\TestBundle\Command; | |
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\Console\Input\InputArgument; | |
use Symfony\Component\Console\Input\InputOption; | |
class TestCommand extends ContainerAwareCommand | |
{ | |
/** | |
* configure | |
* | |
* @access protected | |
* @return void | |
*/ | |
protected function configure() | |
{ | |
$this->setName( 'test:content' )->setDefinition( | |
array( | |
) | |
); | |
} | |
protected function setAdmin() | |
{ | |
$repository = $this->getContainer()->get('ezpublish.api.repository'); | |
$repository->setCurrentUser($repository->getUserService()->loadUser(14)); | |
} | |
protected function execute( InputInterface $input, OutputInterface $output ) | |
{ | |
$this->setAdmin(); | |
$this->container = $this->getContainer(); | |
$repo = $this->container->get('ezpublish.api.repository'); | |
$contentTypeService = $repo->getContentTypeService(); | |
$contentType = $contentTypeService->loadContentTypeByIdentifier('test'); | |
$fieldDefinition = $contentType->getFieldDefinition('body'); | |
$updateStruct = $contentTypeService->newFieldDefinitionUpdateStruct(); | |
$updateStruct->descriptions = array('eng-GB' => 'Body'); | |
$draft = $contentTypeService->createContentTypeDraft($contentType); | |
try { | |
$contentTypeService->updateFieldDefinition($draft,$fieldDefinition,$updateStruct); | |
$contentTypeService->publishContentTypeDraft($draft); | |
} catch (\Exception $e ) { | |
var_dump( $e->getTraceAsString() ); | |
throw $e; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment