├── .gitignore ├── Command ├── AddLocationToContentCommand.php ├── AddRelationCommand.php ├── AssignContentToSectionCommand.php ├── BrowseLocationsCommand.php ├── CookBookCommand.php ├── CopyContentCommand.php ├── CreateContentCommand.php ├── CreateContentTypeCommand.php ├── CreateImageCommand.php ├── CreateXmlContentCommand.php ├── DeleteSubtreeCommand.php ├── FindContent2Command.php ├── FindContent3Command.php ├── FindContentCommand.php ├── HideLocationCommand.php ├── ListSectionsCommand.php ├── SubtreeCommand.php ├── UpdateContentCommand.php ├── ViewContentCommand.php └── ViewContentMetaDataCommand.php ├── DependencyInjection ├── Configuration.php └── EzSystemsCookbookExtension.php ├── EzSystemsCookbookBundle.php ├── LICENSE ├── README.md ├── Resources └── config │ └── services.yml └── composer.json /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /vendor 3 | -------------------------------------------------------------------------------- /Command/AddLocationToContentCommand.php: -------------------------------------------------------------------------------- 1 | setName( 'ezpublish:cookbook:addlocation' )->setDefinition( 26 | array( 27 | new InputArgument( 'contentId', InputArgument::REQUIRED, 'An existing content id' ), 28 | new InputArgument( 'parentLocationId', InputArgument::REQUIRED, 'An existing parent location (node) id' ), 29 | ) 30 | ); 31 | } 32 | 33 | protected function execute( InputInterface $input, OutputInterface $output ) 34 | { 35 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 36 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 37 | $contentService = $repository->getContentService(); 38 | $locationService = $repository->getLocationService(); 39 | 40 | $repository->setCurrentUser( $userService = $repository->getUserService()->loadUser( 14 ) ); 41 | 42 | // fetch the input arguments 43 | $parentLocationId = $input->getArgument( 'parentLocationId' ); 44 | $contentId = $input->getArgument( 'contentId' ); 45 | 46 | try 47 | { 48 | $locationCreateStruct = $locationService->newLocationCreateStruct( $parentLocationId ); 49 | $contentInfo = $contentService->loadContentInfo( $contentId ); 50 | $newLocation = $locationService->createLocation( $contentInfo, $locationCreateStruct ); 51 | 52 | print_r( $newLocation ); 53 | } 54 | // Content or location not found 55 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 56 | { 57 | $output->writeln( $e->getMessage() ); 58 | } 59 | // Permission denied 60 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 61 | { 62 | $output->writeln( $e->getMessage() ); 63 | } 64 | 65 | } 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /Command/AddRelationCommand.php: -------------------------------------------------------------------------------- 1 | setName( 'ezpublish:cookbook:add_relation' )->setDefinition( 25 | array( 26 | new InputArgument( 'source', InputArgument::REQUIRED, 'Content ID to create relation from' ), 27 | new InputArgument( 'destination', InputArgument::REQUIRED, 'Content ID to create relation to' ), 28 | ) 29 | ); 30 | } 31 | 32 | protected function execute( InputInterface $input, OutputInterface $output ) 33 | { 34 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 35 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 36 | $contentService = $repository->getContentService(); 37 | 38 | // load the admin user and set it as current user in the repository 39 | $repository->setCurrentUser( $userService = $repository->getUserService()->loadUser( 14 ) ); 40 | 41 | // fetch the input arguments 42 | $sourceContentId = $input->getArgument( 'source' ); 43 | $destinationContentId = $input->getArgument( 'destination' ); 44 | 45 | try 46 | { 47 | // for the given content ids, load content info 48 | $sourceContentInfo = $contentService->loadContentInfo( $sourceContentId ); 49 | $destinationContentInfo = $contentService->loadContentInfo( $destinationContentId ); 50 | 51 | $contentDraft = $contentService->createContentDraft( $sourceContentInfo ); 52 | $contentService->addRelation( $contentDraft->versionInfo, $destinationContentInfo ); 53 | $content = $contentService->publishVersion( $contentDraft->versionInfo ); 54 | 55 | print_r( $content ); 56 | } 57 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 58 | { 59 | // react on content not found 60 | $output->writeln( $e->getMessage() ); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Command/AssignContentToSectionCommand.php: -------------------------------------------------------------------------------- 1 | setName( 'ezpublish:cookbook:assign_section' )->setDefinition( 25 | array( 26 | new InputArgument( 'contentId', InputArgument::REQUIRED, 'Content ID' ), 27 | new InputArgument( 'sectionId', InputArgument::REQUIRED, 'Section ID' ), 28 | ) 29 | ); 30 | } 31 | 32 | protected function execute( InputInterface $input, OutputInterface $output ) 33 | { 34 | // fetch the the input arguments 35 | $sectionId = $input->getArgument( 'sectionId' ); 36 | $contentId = $input->getArgument( 'contentId' ); 37 | 38 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 39 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 40 | $contentService = $repository->getContentService(); 41 | $sectionService = $repository->getSectionService(); 42 | 43 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 44 | 45 | try 46 | { 47 | $contentInfo = $contentService->loadContentInfo( $contentId ); 48 | $section = $sectionService->loadSection( $sectionId ); 49 | $sectionService->assignSection( $contentInfo, $section ); 50 | 51 | // we need to reload the content info to get the updated version 52 | $contentInfo = $contentService->loadContentInfo( $contentId ); 53 | $output->writeln( $contentInfo->sectionId ); 54 | } 55 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 56 | { 57 | $output->writeln( $e->getMessage() ); 58 | } 59 | catch( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 60 | { 61 | $output->writeln( $e->getMessage() ); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Command/BrowseLocationsCommand.php: -------------------------------------------------------------------------------- 1 | setName( 'ezpublish:cookbook:browse_locations' )->setDefinition( 40 | array( 41 | new InputArgument( 'locationId', InputArgument::REQUIRED, 'Location ID to browse from' ) 42 | ) 43 | ); 44 | } 45 | 46 | /** 47 | * Prints out the location name, and recursively calls itself on each its children 48 | * 49 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location 50 | * @param int $depth The current depth 51 | * 52 | * @param OutputInterface $output 53 | */ 54 | private function browseLocation( Location $location, OutputInterface $output, $depth = 0 ) 55 | { 56 | // indent according to depth and write out the name of the content 57 | $output->write( str_pad( ' ', $depth ) ); 58 | $output->writeln( $location->contentInfo->name ); 59 | 60 | // we request the location's children using the location service, and call browseLocation on each 61 | $childLocations = $this->locationService->loadLocationChildren( $location ); 62 | foreach ( $childLocations->locations as $childLocation ) 63 | { 64 | $this->browseLocation( $childLocation, $output, $depth + 1 ); 65 | } 66 | } 67 | 68 | protected function execute( InputInterface $input, OutputInterface $output ) 69 | { 70 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 71 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 72 | $this->contentService = $repository->getContentService(); 73 | $this->locationService = $repository->getLocationService(); 74 | 75 | // fetch the input argument 76 | $locationId = $input->getArgument( 'locationId' ); 77 | 78 | try 79 | { 80 | // load the starting location and browse 81 | $location = $this->locationService->loadLocation( $locationId ); 82 | $this->browseLocation( $location, $output ); 83 | } 84 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 85 | { 86 | $output->writeln( "No location found with id $locationId" ); 87 | } 88 | catch( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 89 | { 90 | $output->writeln( "Anonymous users are not allowed to read location with id $locationId" ); 91 | } 92 | } 93 | } 94 | 95 | 96 | -------------------------------------------------------------------------------- /Command/CookBookCommand.php: -------------------------------------------------------------------------------- 1 | setName( 'ezpublish:cookbook:my_first_command' )->setDefinition( 22 | array( 23 | new InputArgument( 'contentId', InputArgument::REQUIRED, 'An existing content id' ) 24 | ) 25 | ); 26 | } 27 | 28 | protected function execute( InputInterface $input, OutputInterface $output ) 29 | { 30 | $contentId = $input->getArgument( 'contentId' ); 31 | 32 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 33 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 34 | $contentService = $repository->getContentService(); 35 | 36 | try 37 | { 38 | print_r( $contentService->loadContentInfo( $contentId ) ); 39 | } 40 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 41 | { 42 | $output->writeln( "No content with id $contentId" ); 43 | } 44 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 45 | { 46 | $output->writeln( "Anonymous users are not allowed to read content with id $contentId" ); 47 | } 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /Command/CopyContentCommand.php: -------------------------------------------------------------------------------- 1 | setName( 'ezpublish:cookbook:copy_content' )->setDefinition( 25 | array( 26 | new InputArgument( 'contentId', InputArgument::REQUIRED, 'An existing content id' ), 27 | new InputArgument( 'parentLocationId', InputArgument::REQUIRED, 'An existing parent location (node) id' ) 28 | ) 29 | ); 30 | } 31 | 32 | protected function execute( InputInterface $input, OutputInterface $output ) 33 | { 34 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 35 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 36 | $contentService = $repository->getContentService(); 37 | $locationService = $repository->getLocationService(); 38 | 39 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 40 | 41 | // fetch input arguments 42 | $parentLocationId = $input->getArgument( 'parentLocationId' ); 43 | $contentId = $input->getArgument( 'contentId' ); 44 | 45 | try 46 | { 47 | // instantiate a location create struct from the parent 48 | $locationCreateStruct = $locationService->newLocationCreateStruct( $parentLocationId ); 49 | $contentInfo = $contentService->loadContentInfo( $contentId ); 50 | 51 | // copy the content - all versions are also copied. If only a specific version 52 | // should be copied it can be passed as third parameter 53 | // NOTE: the children are not copied wit this method - use LocationService::copySubtree instead 54 | $contentCopy = $contentService->copyContent( $contentInfo, $locationCreateStruct ); 55 | 56 | print_r( $contentCopy ); 57 | } 58 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 59 | { 60 | $output->writeln( $e->getMessage() ); 61 | } 62 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 63 | { 64 | $output->writeln( $e->getMessage() ); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /Command/CreateContentCommand.php: -------------------------------------------------------------------------------- 1 | setName( 'ezpublish:cookbook:create_content' )->setDefinition( 26 | array( 27 | new InputArgument( 'parentLocationId', InputArgument::REQUIRED, 'An existing parent location ID' ), 28 | new InputArgument( 'contentType', InputArgument::REQUIRED, 'An existing content type identifier - the content type must contain a title field and a body field' ), 29 | new InputArgument( 'title', InputArgument::REQUIRED, 'Content for the Title field' ), 30 | new InputArgument( 'intro', InputArgument::REQUIRED, 'Content for the Intro field' ), 31 | new InputArgument( 'body', InputArgument::REQUIRED, 'Content for the Body field' ), 32 | ) 33 | ); 34 | } 35 | 36 | protected function execute( InputInterface $input, OutputInterface $output ) 37 | { 38 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 39 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 40 | $contentService = $repository->getContentService(); 41 | $locationService = $repository->getLocationService(); 42 | $contentTypeService = $repository->getContentTypeService(); 43 | 44 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 45 | 46 | // fetch the input arguments 47 | $parentLocationId = $input->getArgument( 'parentLocationId' ); 48 | $contentTypeIdentifier = $input->getArgument( 'contentType' ); 49 | $title = $input->getArgument( 'title' ); 50 | $intro = $input->getArgument( 'intro' ); 51 | $body = $input->getArgument( 'body' ); 52 | 53 | try 54 | { 55 | $contentType = $contentTypeService->loadContentTypeByIdentifier( $contentTypeIdentifier ); 56 | $contentCreateStruct = $contentService->newContentCreateStruct( $contentType, 'eng-GB' ); 57 | $contentCreateStruct->setField( 'title', $title ); 58 | $contentCreateStruct->setField( 'intro', $intro ); 59 | $contentCreateStruct->setField( 'body', $body ); 60 | 61 | // instantiate a location create struct from the parent location 62 | $locationCreateStruct = $locationService->newLocationCreateStruct( $parentLocationId ); 63 | 64 | // create a draft using the content and location create struct and publish it 65 | $draft = $contentService->createContent( $contentCreateStruct, array( $locationCreateStruct ) ); 66 | $content = $contentService->publishVersion( $draft->versionInfo ); 67 | 68 | // print out the content 69 | print_r( $content ); 70 | } 71 | // Content type or location not found 72 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 73 | { 74 | $output->writeln( $e->getMessage() ); 75 | } 76 | // Invalid field value 77 | catch ( \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException $e ) 78 | { 79 | $output->writeln( $e->getMessage() ); 80 | } 81 | // Required field missing or empty 82 | catch ( \eZ\Publish\API\Repository\Exceptions\ContentValidationException $e ) 83 | { 84 | $output->writeln( $e->getMessage() ); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Command/CreateContentTypeCommand.php: -------------------------------------------------------------------------------- 1 | setName( 'ezpublish:cookbook:create_content_type' )->setDefinition( 23 | array( 24 | new InputArgument( 'identifier', InputArgument::REQUIRED, 'a content type identifier' ), 25 | new InputArgument( 'group_identifier', InputArgument::REQUIRED, 'a content type group identifier' ) 26 | ) 27 | ); 28 | } 29 | 30 | protected function execute( InputInterface $input, OutputInterface $output ) 31 | { 32 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 33 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 34 | $contentTypeService = $repository->getContentTypeService(); 35 | 36 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 37 | 38 | // fetch command line arguments 39 | $groupIdentifier = $input->getArgument( 'group_identifier' ); 40 | $contentTypeIdentifier = $input->getArgument( 'identifier' ); 41 | 42 | try 43 | { 44 | $contentTypeGroup = $contentTypeService->loadContentTypeGroupByIdentifier( $groupIdentifier ); 45 | } 46 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 47 | { 48 | $output->writeln( "content type group with identifier $groupIdentifier not found" ); 49 | return; 50 | } 51 | 52 | // instantiate a ContentTypeCreateStruct with the given content type identifier and set parameters 53 | $contentTypeCreateStruct = $contentTypeService->newContentTypeCreateStruct( $contentTypeIdentifier ); 54 | $contentTypeCreateStruct->mainLanguageCode = 'eng-GB'; 55 | // We set the Content Type naming pattern to the title's value 56 | $contentTypeCreateStruct->nameSchema = ''; 57 | 58 | // set names for the content type 59 | $contentTypeCreateStruct->names = array( 60 | 'eng-GB' => $contentTypeIdentifier . 'eng-GB', 61 | // 'ger-DE' => $contentTypeIdentifier . 'ger-DE', 62 | ); 63 | 64 | // set description for the content type 65 | $contentTypeCreateStruct->descriptions = array( 66 | 'eng-GB' => 'Description for ' . $contentTypeIdentifier . ' [eng-GB]', 67 | // 'ger-DE' => 'Description for ' . $contentTypeIdentifier . ' [ger-DE]', 68 | ); 69 | 70 | // add a TextLine Field with identifier 'title' 71 | $titleFieldCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( 'title', 'ezstring' ); 72 | $titleFieldCreateStruct->names = array( 'eng-GB' => 'Title'/*, 'ger-DE' => 'Titel'*/ ); 73 | $titleFieldCreateStruct->descriptions = array( 'eng-GB' => 'The Title'/*, 'ger-DE' => 'Der Titel'*/ ); 74 | $titleFieldCreateStruct->fieldGroup = 'content'; 75 | $titleFieldCreateStruct->position = 10; 76 | $titleFieldCreateStruct->isTranslatable = true; 77 | $titleFieldCreateStruct->isRequired = true; 78 | $titleFieldCreateStruct->isSearchable = true; 79 | $contentTypeCreateStruct->addFieldDefinition( $titleFieldCreateStruct ); 80 | 81 | // add a TextLine Field body field 82 | $bodyFieldCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct( 'body', 'ezstring' ); 83 | $bodyFieldCreateStruct->names = array( 'eng-GB' => 'Body'/*, 'ger-DE' => 'Text'*/ ); 84 | $bodyFieldCreateStruct->descriptions = array( 'eng-GB' => 'Description for Body'/*, 'ger-DE' => 'Beschreibung Text'*/ ); 85 | $bodyFieldCreateStruct->fieldGroup = 'content'; 86 | $bodyFieldCreateStruct->position = 20; 87 | $bodyFieldCreateStruct->isTranslatable = true; 88 | $bodyFieldCreateStruct->isRequired = true; 89 | $bodyFieldCreateStruct->isSearchable = true; 90 | $contentTypeCreateStruct->addFieldDefinition( $bodyFieldCreateStruct ); 91 | 92 | try 93 | { 94 | $contentTypeDraft = $contentTypeService->createContentType( $contentTypeCreateStruct, array( $contentTypeGroup ) ); 95 | $contentTypeService->publishContentTypeDraft( $contentTypeDraft ); 96 | $output->writeln( "<info>Content type created '$contentTypeIdentifier' with ID $contentTypeDraft->id" ); 97 | } 98 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 99 | { 100 | $output->writeln( "<error>" . $e->getMessage() . "</error>" ); 101 | } 102 | catch ( \eZ\Publish\API\Repository\Exceptions\ForbiddenException $e ) 103 | { 104 | $output->writeln( "<error>" . $e->getMessage() . "</error>" ); 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /Command/CreateImageCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the CreateImageCommand class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 12 | use Symfony\Component\Console\Input\InputInterface; 13 | use Symfony\Component\Console\Output\OutputInterface; 14 | use Symfony\Component\Console\Input\InputArgument; 15 | use Symfony\Component\Console\Input\InputOption; 16 | 17 | 18 | class CreateImageCommand extends ContainerAwareCommand 19 | { 20 | protected function configure() 21 | { 22 | $this->setName( 'ezpublish:cookbook:create_image' )->setDefinition( 23 | array( 24 | new InputArgument( 'parentLocationId', InputArgument::REQUIRED, 'An existing parent location (node) id' ), 25 | new InputArgument( 'name', InputArgument::REQUIRED, 'the name of the image' ), 26 | new InputArgument( 'file', InputArgument::REQUIRED, 'the absolute path of the image file' ) 27 | ) 28 | ); 29 | } 30 | 31 | protected function execute( InputInterface $input, OutputInterface $output ) 32 | { 33 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 34 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 35 | $contentService = $repository->getContentService(); 36 | $locationService = $repository->getLocationService(); 37 | $contentTypeService = $repository->getContentTypeService(); 38 | 39 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 40 | 41 | // fetch the input arguments 42 | $parentLocationId = $input->getArgument( 'parentLocationId' ); 43 | $name = $input->getArgument( 'name' ); 44 | $file = $input->getArgument( 'file' ); 45 | 46 | try 47 | { 48 | $contentType = $contentTypeService->loadContentTypeByIdentifier( "image" ); 49 | $contentCreateStruct = $contentService->newContentCreateStruct( $contentType, 'eng-GB' ); 50 | $contentCreateStruct->setField( 'name', $name ); // set name field 51 | 52 | // set image file field 53 | $value = new \eZ\Publish\Core\FieldType\Image\Value( 54 | array( 55 | 'path' => $file, 56 | 'fileSize' => filesize( $file ), 57 | 'fileName' => basename( $file ), 58 | 'alternativeText' => $name 59 | ) 60 | ); 61 | $contentCreateStruct->setField( 'image', $value ); 62 | 63 | // Create and publish the image as a child of the provided parent location 64 | $draft = $contentService->createContent( 65 | $contentCreateStruct, 66 | array( 67 | $locationService->newLocationCreateStruct( $parentLocationId ) 68 | ) 69 | ); 70 | $content = $contentService->publishVersion( $draft->versionInfo ); 71 | print_r( $content ); 72 | } 73 | // Content type or parent location not found 74 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 75 | { 76 | $output->writeln( $e->getMessage() ); 77 | } 78 | // Remote ID already exists 79 | catch ( \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException $e ) 80 | { 81 | $output->writeln( $e->getMessage() ); 82 | } 83 | // Invalid field 84 | catch ( \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException $e ) 85 | { 86 | $output->writeln( $e->getMessage() ); 87 | } 88 | // Missing required field, or invalid value 89 | catch( \eZ\Publish\API\Repository\Exceptions\ContentValidationException $e ) 90 | { 91 | $output->writeln( $e->getMessage() ); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Command/CreateXmlContentCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the CreateXmlContentCommand class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | */ 8 | namespace EzSystems\CookbookBundle\Command; 9 | 10 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand, 11 | Symfony\Component\Console\Input\InputInterface, 12 | Symfony\Component\Console\Output\OutputInterface, 13 | Symfony\Component\Console\Input\InputArgument, 14 | Symfony\Component\Console\Input\InputOption; 15 | 16 | class CreateXmlContentCommand extends ContainerAwareCommand 17 | { 18 | protected function configure() 19 | { 20 | $this->setName( 'ezpublish:cookbook:create_xmltext' )->setDefinition( 21 | array( 22 | new InputArgument( 'parentLocationId', InputArgument::REQUIRED, 'An existing parent location (node) id' ), 23 | new InputArgument( 'name', InputArgument::REQUIRED, 'the name of the folder' ), 24 | new InputArgument( 'imageId', InputArgument::REQUIRED, 'an id of an image content object' ) 25 | ) 26 | ); 27 | } 28 | 29 | protected function execute( InputInterface $input, OutputInterface $output ) 30 | { 31 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 32 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 33 | $contentService = $repository->getContentService(); 34 | $locationService = $repository->getLocationService(); 35 | $contentTypeService = $repository->getContentTypeService(); 36 | 37 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 38 | 39 | // fetch the input arguments 40 | $parentLocationId = $input->getArgument( 'parentLocationId' ); 41 | $name = $input->getArgument( 'name' ); 42 | $imageId = $input->getArgument( 'imageId' ); 43 | 44 | try 45 | { 46 | // load a folder content type and instantiate a content creation struct 47 | $contentType = $contentTypeService->loadContentTypeByIdentifier( "folder" ); 48 | $contentCreateStruct = $contentService->newContentCreateStruct( $contentType, "eng-GB" ); 49 | 50 | $contentCreateStruct->setField( "name", $name ); 51 | $xmlText = <<< EOX 52 | <?xml version='1.0' encoding='utf-8'?> 53 | <section> 54 | <paragraph>This is a <strong>image test</strong></paragraph> 55 | <paragraph><embed view='embed' size='medium' object_id='$imageId'/></paragraph> 56 | </section> 57 | EOX; 58 | $contentCreateStruct->setField( "description", $xmlText ); 59 | 60 | // instantiate a location create struct and create and publsidh the content 61 | $locationCreateStruct = $locationService->newLocationCreateStruct( $parentLocationId ); 62 | $draft = $contentService->createContent( $contentCreateStruct, array( $locationCreateStruct ) ); 63 | $content = $contentService->publishVersion( $draft->versionInfo ); 64 | print_r( $content ); 65 | } 66 | // ContentType or Location not found 67 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 68 | { 69 | $output->writeln( $e->getMessage() ); 70 | } 71 | // Remote ID exists already 72 | catch ( \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException $e ) 73 | { 74 | $output->writeln( $e->getMessage() ); 75 | } 76 | // Invalid field 77 | catch ( \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException $e ) 78 | { 79 | $output->writeln( $e->getMessage() ); 80 | } 81 | // Missing required field, or invalid value 82 | catch ( \eZ\Publish\API\Repository\Exceptions\ContentValidationException $e ) 83 | { 84 | $output->writeln( $e->getMessage() ); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Command/DeleteSubtreeCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the DeleteSubtree class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 12 | use Symfony\Component\Console\Input\InputInterface; 13 | use Symfony\Component\Console\Output\OutputInterface; 14 | use Symfony\Component\Console\Input\InputArgument; 15 | use Symfony\Component\Console\Input\InputOption; 16 | 17 | class DeleteSubtreeCommand extends ContainerAwareCommand 18 | { 19 | protected function configure() 20 | { 21 | $this->setName( 'ezpublish:cookbook:delete_subtree' )->setDefinition( 22 | array( 23 | new InputArgument( 'location_id', InputArgument::REQUIRED, 'The subtree\'s root Location ID' ) 24 | ) 25 | ); 26 | } 27 | 28 | protected function execute( InputInterface $input, OutputInterface $output ) 29 | { 30 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 31 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 32 | $locationService = $repository->getLocationService(); 33 | 34 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 35 | 36 | $locationId = $input->getArgument( 'location_id' ); 37 | 38 | try 39 | { 40 | // We first try to load the location so that a NotFoundException is thrown if the Location doesn't exist 41 | $location = $locationService->loadLocation( $locationId ); 42 | $locationService->deleteLocation( $location ); 43 | } 44 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 45 | { 46 | $output->writeln( "No location with id $locationId" ); 47 | } 48 | } 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /Command/FindContent2Command.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the FindContent2Command class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand, 12 | Symfony\Component\Console\Input\InputInterface, 13 | Symfony\Component\Console\Output\OutputInterface, 14 | Symfony\Component\Console\Input\InputArgument, 15 | Symfony\Component\Console\Input\InputOption, 16 | eZ\Publish\API\Repository\Values\Content\Query\Criterion; 17 | 18 | 19 | /** 20 | * This command performs combined full text, subtree and content type search 21 | * 22 | * @author christianbacher 23 | * 24 | */ 25 | class FindContent2Command extends ContainerAwareCommand 26 | { 27 | /** 28 | * This method override configures on input argument for the content id 29 | */ 30 | protected function configure() 31 | { 32 | $this->setName( 'ezpublish:cookbook:find_advanced' )->setDefinition( 33 | array( 34 | new InputArgument( 'text', InputArgument::REQUIRED, 'Text to search for in title field' ), 35 | new InputArgument( 'contentTypeId', InputArgument::REQUIRED, 'Content type id' ), 36 | new InputArgument( 'locationId', InputArgument::REQUIRED, 'Subtree id' ), 37 | ) 38 | ); 39 | } 40 | 41 | protected function execute( InputInterface $input, OutputInterface $output ) 42 | { 43 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 44 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 45 | $searchService = $repository->getSearchService(); 46 | $locationService = $repository->getLocationService(); 47 | 48 | $text = $input->getArgument( 'text' ); 49 | $contentTypeId = $input->getArgument( 'contentTypeId' ); 50 | $locationId = $input->getArgument( 'locationId' ); 51 | 52 | // create the query with three criteria 53 | $query = new \eZ\Publish\API\Repository\Values\Content\Query(); 54 | $criterion1 = new Criterion\Subtree( $locationService->loadLocation( $locationId )->pathString ); 55 | $criterion2 = new Criterion\ContentTypeId( $contentTypeId ); 56 | 57 | $query->filter = new Criterion\LogicalAnd( 58 | array( $criterion1, $criterion2 ) 59 | ); 60 | 61 | $result = $searchService->findContent( $query ); 62 | $output->writeln( '<info>Found ' . $result->totalCount . ' items</info>' ); 63 | foreach ( $result->searchHits as $searchHit ) 64 | { 65 | $output->writeln( "* " . $searchHit->valueObject->contentInfo->name ); 66 | } 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /Command/FindContent3Command.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the FindContent3Command class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | 10 | namespace EzSystems\CookbookBundle\Command; 11 | 12 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 13 | use Symfony\Component\Console\Input\InputInterface; 14 | use Symfony\Component\Console\Output\OutputInterface; 15 | use Symfony\Component\Console\Input\InputArgument; 16 | use Symfony\Component\Console\Input\InputOption; 17 | use eZ\Publish\API\Repository\Values\Content\Query\Criterion; 18 | 19 | 20 | /** 21 | * This command performs a location and content type identifier filter search 22 | */ 23 | class FindContent3Command extends ContainerAwareCommand 24 | { 25 | /** 26 | * This method override configures on input argument for the content id 27 | */ 28 | protected function configure() 29 | { 30 | $this->setName( 'ezpublish:cookbook:find_filter' )->setDefinition( 31 | array( 32 | new InputArgument( 'contentTypeIdentifier', InputArgument::REQUIRED, 'Content type identifier, one or several seperated by comma. example --contentTypeIdentifier=article,folder' ), 33 | new InputArgument( 'locationId', InputArgument::REQUIRED, 'Location id' ), 34 | ) 35 | ); 36 | } 37 | 38 | protected function execute( InputInterface $input, OutputInterface $output ) 39 | { 40 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 41 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 42 | $searchService = $repository->getSearchService(); 43 | 44 | $text = $input->getArgument( 'text' ); 45 | $contentTypeIdentifierList = explode( ',', $input->getArgument( 'contentTypeId' ) ); 46 | $locationId = $input->getArgument( 'locationId' ); 47 | 48 | // create the query with parent location id and a or condition of content type identifiers criteria 49 | $query = new \eZ\Publish\API\Repository\Values\Content\Query(); 50 | $locationCriterion = new Criterion\ParentLocationId( $locationId ); 51 | $congtentTypeOr = new Criterion\LogicalOr( array() ); 52 | 53 | foreach ( $contentTypeIdentifierList as $contentTypeIdentifier ) 54 | $congtentTypeOr->criteria[] = new Criterion\ContentTypeIdentifier( $contentTypeIdentifier ); 55 | 56 | $query->filter = new Criterion\LogicalAnd( 57 | array( $locationCriterion, $congtentTypeOr ) 58 | ); 59 | 60 | $result = $searchService->findContent( $query ); 61 | $output->writeln( '<info>Found ' . $result->totalCount . ' items</info>' ); 62 | foreach ( $result->searchHits as $searchHit ) 63 | { 64 | $output->writeln( "* " . $searchHit->valueObject->contentInfo->name ); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Command/FindContentCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | /** 4 | * File containing the FindContentCommand class. 5 | * 6 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 7 | * @license For full copyright and license information view LICENSE file distributed with this source code. 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 12 | use Symfony\Component\Console\Input\InputInterface; 13 | use Symfony\Component\Console\Output\OutputInterface; 14 | use Symfony\Component\Console\Input\InputArgument; 15 | use eZ\Publish\API\Repository\Values\Content\Query; 16 | 17 | /** 18 | * This command performs a simple full text search 19 | * 20 | * @author christianbacher 21 | */ 22 | class FindContentCommand extends ContainerAwareCommand 23 | { 24 | protected function configure() 25 | { 26 | $this->setName( 'ezpublish:cookbook:find_fulltext' )->setDefinition( 27 | array( 28 | new InputArgument( 'text', InputArgument::REQUIRED, 'Text to search for' ) 29 | ) 30 | ); 31 | } 32 | 33 | protected function execute( InputInterface $input, OutputInterface $output ) 34 | { 35 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 36 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 37 | $searchService = $repository->getSearchService(); 38 | 39 | $text = $input->getArgument( 'text' ); 40 | 41 | $query = new Query(); 42 | // Use 'query' over 'filter' to get hit score (relevancy) and default sorting by it with Solr/Elastic 43 | $query->query = new Query\Criterion\FullText( $text ); 44 | 45 | $result = $searchService->findContent( $query ); 46 | $output->writeln( 'Found ' . $result->totalCount . ' items' ); 47 | foreach ( $result->searchHits as $searchHit ) 48 | { 49 | $output->writeln( $searchHit->valueObject->contentInfo->name ); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Command/HideLocationCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the HideLocationCommand class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand, 12 | Symfony\Component\Console\Input\InputInterface, 13 | Symfony\Component\Console\Output\OutputInterface, 14 | Symfony\Component\Console\Input\InputArgument, 15 | Symfony\Component\Console\Input\InputOption; 16 | 17 | /** 18 | * This command demonstrates how to hide and unhide a location (subtree) 19 | * 20 | * @author christianbacher 21 | * 22 | */ 23 | class HideLocationCommand extends ContainerAwareCommand 24 | { 25 | protected function configure() 26 | { 27 | $this->setName( 'ezpublish:cookbook:add_location' )->setDefinition( 28 | array( 29 | new InputArgument( 'location_id', InputArgument::REQUIRED, 'An existing location id' ), 30 | ) 31 | ); 32 | } 33 | 34 | protected function execute( InputInterface $input, OutputInterface $output ) 35 | { 36 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 37 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 38 | $contentService = $repository->getContentService(); 39 | $locationService = $repository->getLocationService(); 40 | 41 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 42 | 43 | // fetch the location argument 44 | $locationId = $input->getArgument( 'location_id' ); 45 | 46 | try 47 | { 48 | $location = $contentService->loadContentInfo( $locationId ); 49 | 50 | $hiddenLocation = $locationService->hideLocation( $location ); 51 | $output->writeln( "<info>Location after hide:</info>" ); 52 | print_r( $hiddenLocation ); 53 | 54 | // unhide the now hidden location 55 | $unhiddenLocation = $locationService->unhideLocation( $hiddenLocation ); 56 | $output->writeln( "\n<info>Location after unhide:</info>" ); 57 | print_r( $unhiddenLocation ); 58 | 59 | } 60 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 61 | { 62 | $output->writeln( "No location found with id $locationId" ); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Command/ListSectionsCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the BrowseLocationsCommand class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand, 12 | Symfony\Component\Console\Input\InputInterface, 13 | Symfony\Component\Console\Output\OutputInterface, 14 | Symfony\Component\Console\Input\InputArgument, 15 | Symfony\Component\Console\Input\InputOption; 16 | 17 | /** 18 | * This commands lists sections from the system, with ID, name and identifier 19 | */ 20 | class ListSectionsCommand extends ContainerAwareCommand 21 | { 22 | protected function configure() 23 | { 24 | $this->setName( 'ezpublish:cookbook:list_sections' ); 25 | } 26 | 27 | protected function execute( InputInterface $input, OutputInterface $output ) 28 | { 29 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 30 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 31 | $sectionService = $repository->getSectionService(); 32 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 33 | 34 | try 35 | { 36 | /** @var $section \eZ\Publish\API\Repository\Values\Content\Section */ 37 | foreach ( $sectionService->loadSections() as $section ) 38 | { 39 | $output->writeln( "Section #{$section->id}: {$section->name} [$section->identifier]" ); 40 | } 41 | } 42 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 43 | { 44 | // react on permission denied 45 | $output->writeln( "Anonymous users are not allowed to list sections" ); 46 | } 47 | } 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /Command/SubtreeCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the SubtreeCommand class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand, 12 | Symfony\Component\Console\Input\InputInterface, 13 | Symfony\Component\Console\Output\OutputInterface, 14 | Symfony\Component\Console\Input\InputArgument, 15 | Symfony\Component\Console\Input\InputOption; 16 | 17 | class SubtreeCommand extends ContainerAwareCommand 18 | { 19 | protected function configure() 20 | { 21 | $this->setName( 'ezpublish:cookbook:subtree' )->setDefinition( 22 | array( 23 | new InputArgument( 'operation', InputArgument::REQUIRED, 'Operation to execute, either copy or move' ), 24 | new InputArgument( 'srcLocationId', InputArgument::REQUIRED, 'A subtree\`s root Location' ), 25 | new InputArgument( 'destinationParentLocationId', InputArgument::REQUIRED, 'Parent location ID to copy/move to' ), 26 | ) 27 | ); 28 | } 29 | 30 | protected function execute( InputInterface $input, OutputInterface $output ) 31 | { 32 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 33 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 34 | $locationService = $repository->getLocationService(); 35 | 36 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 37 | 38 | // fetch arguments 39 | $operation = $input->getArgument( 'operation' ); // copy or move 40 | $destinationParentLocationId = $input->getArgument( 'destinationParentLocationId' ); 41 | $srcLocationId = $input->getArgument( 'srcLocationId' ); 42 | 43 | try 44 | { 45 | $srcLocation = $locationService->loadLocation( $srcLocationId ); 46 | $destinationParentLocation = $locationService->loadLocation( $destinationParentLocationId ); 47 | 48 | if ( $operation == 'copy' ) 49 | { 50 | $newLocation = $locationService->copySubtree( $srcLocation, $destinationParentLocation ); 51 | } 52 | else if ( $operation == 'move' ) 53 | { 54 | $newLocation = $locationService->moveSubtree( $srcLocation, $destinationParentLocation ); 55 | } 56 | else 57 | { 58 | $output->writeln( "<error>operation must be either copy or move</error>" ); 59 | return; 60 | } 61 | 62 | print_r( $newLocation ); 63 | } 64 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 65 | { 66 | $output->writeln( $e->getMessage() ); 67 | } 68 | catch( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 69 | { 70 | $output->writeln( $e->getMessage() ); 71 | } 72 | } 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /Command/UpdateContentCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the CreateContentCommand class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand, 12 | Symfony\Component\Console\Input\InputInterface, 13 | Symfony\Component\Console\Output\OutputInterface, 14 | Symfony\Component\Console\Input\InputArgument, 15 | Symfony\Component\Console\Input\InputOption; 16 | 17 | class UpdateContentCommand extends ContainerAwareCommand 18 | { 19 | protected function configure() 20 | { 21 | $this->setName( 'ezpublish:cookbook:update_content' )->setDefinition( 22 | array( 23 | new InputArgument( 'contentId' , InputArgument::REQUIRED, 'the content to be updated' ), 24 | new InputArgument( 'newtitle' , InputArgument::REQUIRED, 'the new title of the content' ), 25 | new InputArgument( 'newbody' , InputArgument::REQUIRED, 'the new body of the content' ) 26 | ) 27 | ); 28 | } 29 | 30 | protected function execute( InputInterface $input, OutputInterface $output ) 31 | { 32 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 33 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 34 | $contentService = $repository->getContentService(); 35 | 36 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 37 | 38 | $contentId = $input->getArgument( 'contentId' ); 39 | $newTitle = $input->getArgument( 'newtitle' ); 40 | $newBody = $input->getArgument( 'newbody' ); 41 | 42 | try 43 | { 44 | // create a content draft from the current published version 45 | $contentInfo = $contentService->loadContentInfo( $contentId ); 46 | $contentDraft = $contentService->createContentDraft( $contentInfo ); 47 | 48 | // instantiate a content update struct and set the new fields 49 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); 50 | $contentUpdateStruct->initialLanguageCode = 'eng-GB'; // set language for new version 51 | $contentUpdateStruct->setField( 'title', $newTitle ); 52 | $contentUpdateStruct->setField( 'body', $newBody ); 53 | 54 | // update and publish draft 55 | $contentDraft = $contentService->updateContent( $contentDraft->versionInfo, $contentUpdateStruct ); 56 | $content = $contentService->publishVersion( $contentDraft->versionInfo ); 57 | 58 | print_r( $content ); 59 | } 60 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 61 | { 62 | $output->writeln( $e->getMessage() ); 63 | } 64 | catch( \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException $e ) 65 | { 66 | $output->writeln( $e->getMessage() ); 67 | } 68 | catch( \eZ\Publish\API\Repository\Exceptions\ContentValidationException $e ) 69 | { 70 | $output->writeln( $e->getMessage() ); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Command/ViewContentCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the ViewContentCommand class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 12 | use Symfony\Component\Console\Input\InputInterface; 13 | use Symfony\Component\Console\Output\OutputInterface; 14 | use Symfony\Component\Console\Input\InputArgument; 15 | use Symfony\Component\Console\Input\InputOption; 16 | 17 | /** 18 | * This command loads a Content using its numerical identifier, iterates over the Content's Fields, and shows the value 19 | * of each of them. 20 | */ 21 | class ViewContentCommand extends ContainerAwareCommand 22 | { 23 | protected function configure() 24 | { 25 | $this->setName( 'ezpublish:cookbook:view_content' )->setDefinition( 26 | array( 27 | new InputArgument( 'contentId', InputArgument::REQUIRED, 'An existing content id' ) 28 | ) 29 | ); 30 | } 31 | 32 | protected function execute( InputInterface $input, OutputInterface $output ) 33 | { 34 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 35 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 36 | $contentService = $repository->getContentService(); 37 | $contentTypeService = $repository->getContentTypeService(); 38 | $fieldTypeService = $repository->getFieldTypeService(); 39 | 40 | $contentId = $input->getArgument( 'contentId' ); 41 | 42 | try 43 | { 44 | $content = $contentService->loadContent( $contentId ); 45 | $contentType = $contentTypeService->loadContentType( $content->contentInfo->contentTypeId ); 46 | 47 | // Iterate over the field definitions of the content type, and print identifier: value 48 | foreach ( $contentType->fieldDefinitions as $fieldDefinition ) 49 | { 50 | $output->writeln( "<info>" . $fieldDefinition->identifier . "</info>" ); 51 | $fieldType = $fieldTypeService->getFieldType( $fieldDefinition->fieldTypeIdentifier ); 52 | $field = $content->getField( $fieldDefinition->identifier ); 53 | $valueHash = $fieldType->toHash( $field->value ); 54 | $output->writeln( $valueHash ); 55 | } 56 | } 57 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 58 | { 59 | $output->writeln( "<error>No content with id $contentId found</error>" ); 60 | } 61 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 62 | { 63 | $output->writeln( "<error>Permission denied on content with id $contentId</error>" ); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Command/ViewContentMetaDataCommand.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * File containing the ViewContentMetaDataCommand class. 4 | * 5 | * @copyright Copyright (C) eZ Systems AS. All rights reserved. 6 | * @license For full copyright and license information view LICENSE file distributed with this source code. 7 | * @version //autogentag// 8 | */ 9 | namespace EzSystems\CookbookBundle\Command; 10 | 11 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand, 12 | Symfony\Component\Console\Input\InputInterface, 13 | Symfony\Component\Console\Output\OutputInterface, 14 | Symfony\Component\Console\Input\InputArgument, 15 | Symfony\Component\Console\Input\InputOption; 16 | 17 | class ViewContentMetaDataCommand extends ContainerAwareCommand 18 | { 19 | protected function configure() 20 | { 21 | $this->setName( 'ezpublish:cookbook:view_content_metadata' )->setDefinition( 22 | array( 23 | new InputArgument( 'contentId', InputArgument::REQUIRED, 'An existing content id' ) 24 | ) 25 | ); 26 | } 27 | 28 | 29 | protected function execute( InputInterface $input, OutputInterface $output ) 30 | { 31 | /** @var $repository \eZ\Publish\API\Repository\Repository */ 32 | $repository = $this->getContainer()->get( 'ezpublish.api.repository' ); 33 | $contentService = $repository->getContentService(); 34 | $contentTypeService = $repository->getContentTypeService(); 35 | $locationService = $repository->getLocationService(); 36 | $urlAliasService = $repository->getURLAliasService(); 37 | $sectionService = $repository->getSectionService(); 38 | $userService = $repository->getUserService(); 39 | 40 | $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) ); 41 | 42 | $contentId = $input->getArgument( 'contentId' ); 43 | 44 | try 45 | { 46 | $contentInfo = $contentService->loadContentInfo( $contentId ); 47 | $contentType = $contentTypeService->loadContentType( $contentInfo->contentTypeId ); 48 | 49 | // show all locations of the content 50 | $locations = $locationService->loadLocations( $contentInfo ); 51 | $output->writeln( "<info>LOCATIONS</info>" ); 52 | foreach ( $locations as $location ) 53 | { 54 | $urlAlias = $urlAliasService->reverseLookup( $location ); 55 | $output->writeln( " $location->pathString ($urlAlias->path)" ); 56 | } 57 | 58 | // show all relations of the current version 59 | $versionInfo = $contentService->loadVersionInfo( $contentInfo ); 60 | $relations = $contentService->loadRelations( $versionInfo ); 61 | if ( count( $relations ) ) 62 | { 63 | $output->writeln( "<info>RELATIONS</info>" ); 64 | foreach ( $relations as $relation ) 65 | { 66 | $name = $relation->destinationContentInfo->name; 67 | $output->write( " Relation of type " . $this->outputRelationType( $relation->type ) . " to content $name" ); 68 | } 69 | } 70 | 71 | // show meta data 72 | $output->writeln( "\n<info>METADATA</info>" ); 73 | $output->writeln( " <info>Name:</info> $contentInfo->name" ); 74 | $output->writeln( " <info>Type:</info> " . $contentType->identifier ); 75 | $output->writeln( " <info>Last modified:</info> " . $contentInfo->modificationDate->format( 'Y-m-d' ) ); 76 | $output->writeln( " <info>Published:</info> ". $contentInfo->publishedDate->format( 'Y-m-d' ) ); 77 | $output->writeln( " <info>RemoteId:</info> $contentInfo->remoteId" ); 78 | $output->writeln( " <info>Main Language:</info> $contentInfo->mainLanguageCode" ); 79 | $output->writeln( " <info>Always available:</info> " . ( $contentInfo->alwaysAvailable ? 'Yes' : 'No' ) ); 80 | 81 | $owner = $userService->loadUser( $contentInfo->ownerId ); 82 | $output->writeln( " <info>Owner:</info> " . $owner->contentInfo->name ); 83 | 84 | $section = $sectionService->loadSection( $contentInfo->sectionId ); 85 | $output->writeln( " <info>Section:</info> $section->name" ); 86 | 87 | // show versions 88 | $versionInfoArray = $contentService->loadVersions( $contentInfo ); 89 | if ( count( $versionInfoArray ) ) 90 | { 91 | $output->writeln( "\n<info>VERSIONS</info>" ); 92 | foreach ( $versionInfoArray as $versionInfo ) 93 | { 94 | $creator = $userService->loadUser( $versionInfo->creatorId ); 95 | $output->write( " Version $versionInfo->versionNo " ); 96 | $output->write( " by " . $creator->contentInfo->name ); 97 | $output->writeln( " " . $this->outputStatus( $versionInfo->status ) . " " . $versionInfo->initialLanguageCode ); 98 | } 99 | } 100 | } 101 | catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e ) 102 | { 103 | $output->writeln( "<error>No content with id $contentId</error>" ); 104 | } 105 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e ) 106 | { 107 | $output->writeln( "<error>Anonymous users are not allowed to read content with id $contentId</error>" ); 108 | } 109 | } 110 | 111 | /** 112 | * Returns the string version of $status 113 | * 114 | * @param int $status 115 | * @return string 116 | */ 117 | private function outputStatus( $status ) 118 | { 119 | switch ( $status ) 120 | { 121 | case 0: 122 | return 'DRAFT'; 123 | case 1: 124 | return 'PUBLISHED'; 125 | case 2: 126 | return 'ARCHIVED'; 127 | default: 128 | return "UNKNOWN"; 129 | } 130 | } 131 | 132 | 133 | /** 134 | * Returns the string version of $relationType 135 | * 136 | * @param int $relationType 137 | * @return string 138 | */ 139 | private function outputRelationType( $relationType ) 140 | { 141 | switch ( $relationType ) 142 | { 143 | case 1: 144 | return 'COMMON'; 145 | case 2: 146 | return 'EMBED'; 147 | case 4: 148 | return 'LINK'; 149 | case 8: 150 | return 'ATTRIBUTE'; 151 | default: 152 | return "UNKNOWN"; 153 | } 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /DependencyInjection/Configuration.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | namespace EzSystems\CookbookBundle\DependencyInjection; 4 | 5 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; 6 | use Symfony\Component\Config\Definition\ConfigurationInterface; 7 | 8 | /** 9 | * This is the class that validates and merges configuration from your ezpublish/config files 10 | * 11 | * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} 12 | */ 13 | class Configuration implements ConfigurationInterface 14 | { 15 | /** 16 | * {@inheritDoc} 17 | */ 18 | public function getConfigTreeBuilder() 19 | { 20 | $treeBuilder = new TreeBuilder(); 21 | $rootNode = $treeBuilder->root('ez_systems_cook_book'); 22 | 23 | // Here you should define the parameters that are allowed to 24 | // configure your bundle. See the documentation linked above for 25 | // more information on that topic. 26 | 27 | return $treeBuilder; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DependencyInjection/EzSystemsCookbookExtension.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | namespace EzSystems\CookbookBundle\DependencyInjection; 4 | 5 | use Symfony\Component\DependencyInjection\ContainerBuilder; 6 | use Symfony\Component\Config\FileLocator; 7 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; 8 | use Symfony\Component\DependencyInjection\Loader; 9 | 10 | /** 11 | * This is the class that loads and manages your bundle configuration 12 | * 13 | * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} 14 | */ 15 | class EzSystemsCookbookExtension extends Extension 16 | { 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | public function load(array $configs, ContainerBuilder $container) 21 | { 22 | $configuration = new Configuration(); 23 | $config = $this->processConfiguration($configuration, $configs); 24 | 25 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 26 | $loader->load('services.yml'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /EzSystemsCookbookBundle.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | namespace EzSystems\CookbookBundle; 4 | 5 | use Symfony\Component\HttpKernel\Bundle\Bundle; 6 | 7 | class EzSystemsCookbookBundle extends Bundle 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 1999-2020 eZ Systems AS. All rights reserved. 2 | This source code is provided under the following license: 3 | 4 | 5 | GNU GENERAL PUBLIC LICENSE 6 | Version 2, June 1991 7 | 8 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 9 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 10 | Everyone is permitted to copy and distribute verbatim copies 11 | of this license document, but changing it is not allowed. 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | License is intended to guarantee your freedom to share and change free 18 | software--to make sure the software is free for all its users. This 19 | General Public License applies to most of the Free Software 20 | Foundation's software and to any other program whose authors commit to 21 | using it. (Some other Free Software Foundation software is covered by 22 | the GNU Lesser General Public License instead.) You can apply it to 23 | your programs, too. 24 | 25 | When we speak of free software, we are referring to freedom, not 26 | price. Our General Public Licenses are designed to make sure that you 27 | have the freedom to distribute copies of free software (and charge for 28 | this service if you wish), that you receive source code or can get it 29 | if you want it, that you can change the software or use pieces of it 30 | in new free programs; and that you know you can do these things. 31 | 32 | To protect your rights, we need to make restrictions that forbid 33 | anyone to deny you these rights or to ask you to surrender the rights. 34 | These restrictions translate to certain responsibilities for you if you 35 | distribute copies of the software, or if you modify it. 36 | 37 | For example, if you distribute copies of such a program, whether 38 | gratis or for a fee, you must give the recipients all the rights that 39 | you have. You must make sure that they, too, receive or can get the 40 | source code. And you must show them these terms so they know their 41 | rights. 42 | 43 | We protect your rights with two steps: (1) copyright the software, and 44 | (2) offer you this license which gives you legal permission to copy, 45 | distribute and/or modify the software. 46 | 47 | Also, for each author's protection and ours, we want to make certain 48 | that everyone understands that there is no warranty for this free 49 | software. If the software is modified by someone else and passed on, we 50 | want its recipients to know that what they have is not the original, so 51 | that any problems introduced by others will not reflect on the original 52 | authors' reputations. 53 | 54 | Finally, any free program is threatened constantly by software 55 | patents. We wish to avoid the danger that redistributors of a free 56 | program will individually obtain patent licenses, in effect making the 57 | program proprietary. To prevent this, we have made it clear that any 58 | patent must be licensed for everyone's free use or not licensed at all. 59 | 60 | The precise terms and conditions for copying, distribution and 61 | modification follow. 62 | 63 | GNU GENERAL PUBLIC LICENSE 64 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 65 | 66 | 0. This License applies to any program or other work which contains 67 | a notice placed by the copyright holder saying it may be distributed 68 | under the terms of this General Public License. The "Program", below, 69 | refers to any such program or work, and a "work based on the Program" 70 | means either the Program or any derivative work under copyright law: 71 | that is to say, a work containing the Program or a portion of it, 72 | either verbatim or with modifications and/or translated into another 73 | language. (Hereinafter, translation is included without limitation in 74 | the term "modification".) Each licensee is addressed as "you". 75 | 76 | Activities other than copying, distribution and modification are not 77 | covered by this License; they are outside its scope. The act of 78 | running the Program is not restricted, and the output from the Program 79 | is covered only if its contents constitute a work based on the 80 | Program (independent of having been made by running the Program). 81 | Whether that is true depends on what the Program does. 82 | 83 | 1. You may copy and distribute verbatim copies of the Program's 84 | source code as you receive it, in any medium, provided that you 85 | conspicuously and appropriately publish on each copy an appropriate 86 | copyright notice and disclaimer of warranty; keep intact all the 87 | notices that refer to this License and to the absence of any warranty; 88 | and give any other recipients of the Program a copy of this License 89 | along with the Program. 90 | 91 | You may charge a fee for the physical act of transferring a copy, and 92 | you may at your option offer warranty protection in exchange for a fee. 93 | 94 | 2. You may modify your copy or copies of the Program or any portion 95 | of it, thus forming a work based on the Program, and copy and 96 | distribute such modifications or work under the terms of Section 1 97 | above, provided that you also meet all of these conditions: 98 | 99 | a) You must cause the modified files to carry prominent notices 100 | stating that you changed the files and the date of any change. 101 | 102 | b) You must cause any work that you distribute or publish, that in 103 | whole or in part contains or is derived from the Program or any 104 | part thereof, to be licensed as a whole at no charge to all third 105 | parties under the terms of this License. 106 | 107 | c) If the modified program normally reads commands interactively 108 | when run, you must cause it, when started running for such 109 | interactive use in the most ordinary way, to print or display an 110 | announcement including an appropriate copyright notice and a 111 | notice that there is no warranty (or else, saying that you provide 112 | a warranty) and that users may redistribute the program under 113 | these conditions, and telling the user how to view a copy of this 114 | License. (Exception: if the Program itself is interactive but 115 | does not normally print such an announcement, your work based on 116 | the Program is not required to print an announcement.) 117 | 118 | These requirements apply to the modified work as a whole. If 119 | identifiable sections of that work are not derived from the Program, 120 | and can be reasonably considered independent and separate works in 121 | themselves, then this License, and its terms, do not apply to those 122 | sections when you distribute them as separate works. But when you 123 | distribute the same sections as part of a whole which is a work based 124 | on the Program, the distribution of the whole must be on the terms of 125 | this License, whose permissions for other licensees extend to the 126 | entire whole, and thus to each and every part regardless of who wrote it. 127 | 128 | Thus, it is not the intent of this section to claim rights or contest 129 | your rights to work written entirely by you; rather, the intent is to 130 | exercise the right to control the distribution of derivative or 131 | collective works based on the Program. 132 | 133 | In addition, mere aggregation of another work not based on the Program 134 | with the Program (or with a work based on the Program) on a volume of 135 | a storage or distribution medium does not bring the other work under 136 | the scope of this License. 137 | 138 | 3. You may copy and distribute the Program (or a work based on it, 139 | under Section 2) in object code or executable form under the terms of 140 | Sections 1 and 2 above provided that you also do one of the following: 141 | 142 | a) Accompany it with the complete corresponding machine-readable 143 | source code, which must be distributed under the terms of Sections 144 | 1 and 2 above on a medium customarily used for software interchange; or, 145 | 146 | b) Accompany it with a written offer, valid for at least three 147 | years, to give any third party, for a charge no more than your 148 | cost of physically performing source distribution, a complete 149 | machine-readable copy of the corresponding source code, to be 150 | distributed under the terms of Sections 1 and 2 above on a medium 151 | customarily used for software interchange; or, 152 | 153 | c) Accompany it with the information you received as to the offer 154 | to distribute corresponding source code. (This alternative is 155 | allowed only for noncommercial distribution and only if you 156 | received the program in object code or executable form with such 157 | an offer, in accord with Subsection b above.) 158 | 159 | The source code for a work means the preferred form of the work for 160 | making modifications to it. For an executable work, complete source 161 | code means all the source code for all modules it contains, plus any 162 | associated interface definition files, plus the scripts used to 163 | control compilation and installation of the executable. However, as a 164 | special exception, the source code distributed need not include 165 | anything that is normally distributed (in either source or binary 166 | form) with the major components (compiler, kernel, and so on) of the 167 | operating system on which the executable runs, unless that component 168 | itself accompanies the executable. 169 | 170 | If distribution of executable or object code is made by offering 171 | access to copy from a designated place, then offering equivalent 172 | access to copy the source code from the same place counts as 173 | distribution of the source code, even though third parties are not 174 | compelled to copy the source along with the object code. 175 | 176 | 4. You may not copy, modify, sublicense, or distribute the Program 177 | except as expressly provided under this License. Any attempt 178 | otherwise to copy, modify, sublicense or distribute the Program is 179 | void, and will automatically terminate your rights under this License. 180 | However, parties who have received copies, or rights, from you under 181 | this License will not have their licenses terminated so long as such 182 | parties remain in full compliance. 183 | 184 | 5. You are not required to accept this License, since you have not 185 | signed it. However, nothing else grants you permission to modify or 186 | distribute the Program or its derivative works. These actions are 187 | prohibited by law if you do not accept this License. Therefore, by 188 | modifying or distributing the Program (or any work based on the 189 | Program), you indicate your acceptance of this License to do so, and 190 | all its terms and conditions for copying, distributing or modifying 191 | the Program or works based on it. 192 | 193 | 6. Each time you redistribute the Program (or any work based on the 194 | Program), the recipient automatically receives a license from the 195 | original licensor to copy, distribute or modify the Program subject to 196 | these terms and conditions. You may not impose any further 197 | restrictions on the recipients' exercise of the rights granted herein. 198 | You are not responsible for enforcing compliance by third parties to 199 | this License. 200 | 201 | 7. If, as a consequence of a court judgment or allegation of patent 202 | infringement or for any other reason (not limited to patent issues), 203 | conditions are imposed on you (whether by court order, agreement or 204 | otherwise) that contradict the conditions of this License, they do not 205 | excuse you from the conditions of this License. If you cannot 206 | distribute so as to satisfy simultaneously your obligations under this 207 | License and any other pertinent obligations, then as a consequence you 208 | may not distribute the Program at all. For example, if a patent 209 | license would not permit royalty-free redistribution of the Program by 210 | all those who receive copies directly or indirectly through you, then 211 | the only way you could satisfy both it and this License would be to 212 | refrain entirely from distribution of the Program. 213 | 214 | If any portion of this section is held invalid or unenforceable under 215 | any particular circumstance, the balance of the section is intended to 216 | apply and the section as a whole is intended to apply in other 217 | circumstances. 218 | 219 | It is not the purpose of this section to induce you to infringe any 220 | patents or other property right claims or to contest validity of any 221 | such claims; this section has the sole purpose of protecting the 222 | integrity of the free software distribution system, which is 223 | implemented by public license practices. Many people have made 224 | generous contributions to the wide range of software distributed 225 | through that system in reliance on consistent application of that 226 | system; it is up to the author/donor to decide if he or she is willing 227 | to distribute software through any other system and a licensee cannot 228 | impose that choice. 229 | 230 | This section is intended to make thoroughly clear what is believed to 231 | be a consequence of the rest of this License. 232 | 233 | 8. If the distribution and/or use of the Program is restricted in 234 | certain countries either by patents or by copyrighted interfaces, the 235 | original copyright holder who places the Program under this License 236 | may add an explicit geographical distribution limitation excluding 237 | those countries, so that distribution is permitted only in or among 238 | countries not thus excluded. In such case, this License incorporates 239 | the limitation as if written in the body of this License. 240 | 241 | 9. The Free Software Foundation may publish revised and/or new versions 242 | of the General Public License from time to time. Such new versions will 243 | be similar in spirit to the present version, but may differ in detail to 244 | address new problems or concerns. 245 | 246 | Each version is given a distinguishing version number. If the Program 247 | specifies a version number of this License which applies to it and "any 248 | later version", you have the option of following the terms and conditions 249 | either of that version or of any later version published by the Free 250 | Software Foundation. If the Program does not specify a version number of 251 | this License, you may choose any version ever published by the Free Software 252 | Foundation. 253 | 254 | 10. If you wish to incorporate parts of the Program into other free 255 | programs whose distribution conditions are different, write to the author 256 | to ask for permission. For software which is copyrighted by the Free 257 | Software Foundation, write to the Free Software Foundation; we sometimes 258 | make exceptions for this. Our decision will be guided by the two goals 259 | of preserving the free status of all derivatives of our free software and 260 | of promoting the sharing and reuse of software generally. 261 | 262 | NO WARRANTY 263 | 264 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 265 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 266 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 267 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 268 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 269 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 270 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 271 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 272 | REPAIR OR CORRECTION. 273 | 274 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 275 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 276 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 277 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 278 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 279 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 280 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 281 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 282 | POSSIBILITY OF SUCH DAMAGES. 283 | 284 | END OF TERMS AND CONDITIONS 285 | 286 | How to Apply These Terms to Your New Programs 287 | 288 | If you develop a new program, and you want it to be of the greatest 289 | possible use to the public, the best way to achieve this is to make it 290 | free software which everyone can redistribute and change under these terms. 291 | 292 | To do so, attach the following notices to the program. It is safest 293 | to attach them to the start of each source file to most effectively 294 | convey the exclusion of warranty; and each file should have at least 295 | the "copyright" line and a pointer to where the full notice is found. 296 | 297 | <one line to give the program's name and a brief idea of what it does.> 298 | Copyright (C) <year> <name of author> 299 | 300 | This program is free software; you can redistribute it and/or modify 301 | it under the terms of the GNU General Public License as published by 302 | the Free Software Foundation; either version 2 of the License, or 303 | (at your option) any later version. 304 | 305 | This program is distributed in the hope that it will be useful, 306 | but WITHOUT ANY WARRANTY; without even the implied warranty of 307 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 308 | GNU General Public License for more details. 309 | 310 | You should have received a copy of the GNU General Public License along 311 | with this program; if not, write to the Free Software Foundation, Inc., 312 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 313 | 314 | Also add information on how to contact you by electronic and paper mail. 315 | 316 | If the program is interactive, make it output a short notice like this 317 | when it starts in an interactive mode: 318 | 319 | Gnomovision version 69, Copyright (C) year name of author 320 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 321 | This is free software, and you are welcome to redistribute it 322 | under certain conditions; type `show c' for details. 323 | 324 | The hypothetical commands `show w' and `show c' should show the appropriate 325 | parts of the General Public License. Of course, the commands you use may 326 | be called something other than `show w' and `show c'; they could even be 327 | mouse-clicks or menu items--whatever suits your program. 328 | 329 | You should also get your employer (if you work as a programmer) or your 330 | school, if any, to sign a "copyright disclaimer" for the program, if 331 | necessary. Here is a sample; alter the names: 332 | 333 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 334 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 335 | 336 | <signature of Ty Coon>, 1 April 1989 337 | Ty Coon, President of Vice 338 | 339 | This General Public License does not permit incorporating your program into 340 | proprietary programs. If your program is a subroutine library, you may 341 | consider it more useful to permit linking proprietary applications with the 342 | library. If this is what you want to do, use the GNU Lesser General 343 | Public License instead of this License. 344 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CookbookBundle 2 | ============== 3 | 4 | Cookbook bundle aims to: 5 | - Provide full working examples of eZ Platform API use 6 | - Serve as a reusale set of commands you can use when you need to during development 7 | 8 | 1.0 on this bundle aims to work across eZ Publish Platform 5.4 and eZ Platform 1.7 / 1.13 / 2.5. 9 | 10 | 11 | # Getting started 12 | 13 | Required: 14 | 15 | - PHP _(minimum 5.6, 7.0+ is recommended)_ 16 | - Composer 17 | 18 | 0. Create and install eZ Platform using composer: 19 | 20 | ```bash 21 | composer create-project ezsystems/ezplatform:^2 22 | ``` 23 | 24 | Follow the instructions that show up on the screen to have fully working clean install of eZ Platform. 25 | 26 | 1. Install `CookbookBundle` using composer: 27 | 28 | ```bash 29 | # execute in your eZ Platform project working directory: 30 | composer require ezsystems/cookbook-bundle:^1.0@dev 31 | ``` 32 | 33 | Follow the instructions that show up on the screen to have fully working clean install of `CookbookBundle`. 34 | 35 | 2. Enable the bundle in `AppKernel.php`: 36 | 37 | ```php 38 | public function registerBundles() 39 | { 40 | $bundles = array( 41 | // ... 42 | new EzSystems\CookbookBundle\EzSystemsCookbookBundle(), 43 | ); 44 | 45 | // ... 46 | } 47 | ``` 48 | 49 | 3. Clear Symfony cache 50 | 51 | ```bash 52 | php bin/console cache:clear 53 | ``` 54 | 55 | 4. Try already defined commands. You can find all available commands by: 56 | 57 | ```bash 58 | php bin/console |grep 'ezpublish:cookbook' 59 | ``` 60 | 61 | That's all! 62 | -------------------------------------------------------------------------------- /Resources/config/services.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # ez_systems_cookbook.example.class: EzSystems\CookbookBundle\Example 3 | 4 | services: 5 | # ez_systems_cookbook.example: 6 | # class: %ez_systems_cookbook.example.class% 7 | # arguments: [@service_id, "plain_value", %parameter%] 8 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ezsystems/cookbook-bundle", 3 | "description": "eZ Platform Bundle with ready to use code samples", 4 | "homepage": "https://github.com/ezsystems/cookbook-bundle", 5 | "license": "GPL-2.0", 6 | "type": "ezplatform-bundle", 7 | "authors": [ 8 | { 9 | "name": "eZ dev-team & eZ Community", 10 | "homepage": "https://github.com/ezsystems/cookbook-bundle/contributors" 11 | } 12 | ], 13 | "require": { 14 | "php": "^5.6 || ^7.0", 15 | "ezsystems/ezpublish-kernel": "^5.4.10 || ^6.7 || ^7.0" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "EzSystems\\CookbookBundle\\": "" 20 | } 21 | }, 22 | "extra": { 23 | "branch-alias": { 24 | "dev-master": "1.0.x-dev" 25 | } 26 | } 27 | } 28 | --------------------------------------------------------------------------------