Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace EzSystems\EzSupportToolsBundle\Command;
- use EzSystems\EzSupportToolsBundle\SystemInfo\SystemInfoCollectorRegistry;
- use EzSystems\EzSupportToolsBundle\SystemInfo\OutputFormatRegistry;
- use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- class CreateFolderCommand extends ContainerAwareCommand
- {
- /**
- * Define command and input options.
- */
- protected function configure()
- {
- $this->setName('content:create');
- }
- /**
- * Execute the Command.
- *
- * @param $input InputInterface
- * @param $output OutputInterface
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $repository = $this->getContainer()->get( 'ezpublish.api.repository');
- $userService = $repository->getUserService();
- $contentService = $repository->getContentService();
- $locationService = $repository->getLocationService();
- $contentTypeService = $repository->getContentTypeService();
- $username = 'admin';
- $password = 'publish';
- $contentTypeName = 'folder';
- $languageCode = 'eng-GB';
- $parentLocationId = 2;
- $permissionResolver = $repository->getPermissionResolver();
- $user = $userService->loadUserByCredentials( $username, $password );
- $permissionResolver->setCurrentUserReference($user);
- $contentType = $contentTypeService->loadContentTypeByIdentifier( $contentTypeName );
- $contentCreateStruct = $contentService->newContentCreateStruct( $contentType, $languageCode );
- $contentCreateStruct->setField( 'name', 'Destination' );
- $locationCreateStruct = $locationService->newLocationCreateStruct( $parentLocationId );
- $draft = $contentService->createContent( $contentCreateStruct, array( $locationCreateStruct ) );
- $content = $contentService->publishVersion( $draft->versionInfo );
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement