├── .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( "Content type created '$contentTypeIdentifier' with ID $contentTypeDraft->id" );
97 | }
98 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e )
99 | {
100 | $output->writeln( "" . $e->getMessage() . "" );
101 | }
102 | catch ( \eZ\Publish\API\Repository\Exceptions\ForbiddenException $e )
103 | {
104 | $output->writeln( "" . $e->getMessage() . "" );
105 | }
106 | }
107 | }
--------------------------------------------------------------------------------
/Command/CreateImageCommand.php:
--------------------------------------------------------------------------------
1 | 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 | 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 |
53 |
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 | 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 | 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( 'Found ' . $result->totalCount . ' items' );
63 | foreach ( $result->searchHits as $searchHit )
64 | {
65 | $output->writeln( "* " . $searchHit->valueObject->contentInfo->name );
66 | }
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/Command/FindContent3Command.php:
--------------------------------------------------------------------------------
1 | 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( 'Found ' . $result->totalCount . ' items' );
62 | foreach ( $result->searchHits as $searchHit )
63 | {
64 | $output->writeln( "* " . $searchHit->valueObject->contentInfo->name );
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Command/FindContentCommand.php:
--------------------------------------------------------------------------------
1 | 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 | 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( "Location after hide:" );
52 | print_r( $hiddenLocation );
53 |
54 | // unhide the now hidden location
55 | $unhiddenLocation = $locationService->unhideLocation( $hiddenLocation );
56 | $output->writeln( "\nLocation after unhide:" );
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 | 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 | 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( "operation must be either copy or move" );
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 | 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 | 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( "" . $fieldDefinition->identifier . "" );
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( "No content with id $contentId found" );
60 | }
61 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e )
62 | {
63 | $output->writeln( "Permission denied on content with id $contentId" );
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Command/ViewContentMetaDataCommand.php:
--------------------------------------------------------------------------------
1 | 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( "LOCATIONS" );
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( "RELATIONS" );
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( "\nMETADATA" );
73 | $output->writeln( " Name: $contentInfo->name" );
74 | $output->writeln( " Type: " . $contentType->identifier );
75 | $output->writeln( " Last modified: " . $contentInfo->modificationDate->format( 'Y-m-d' ) );
76 | $output->writeln( " Published: ". $contentInfo->publishedDate->format( 'Y-m-d' ) );
77 | $output->writeln( " RemoteId: $contentInfo->remoteId" );
78 | $output->writeln( " Main Language: $contentInfo->mainLanguageCode" );
79 | $output->writeln( " Always available: " . ( $contentInfo->alwaysAvailable ? 'Yes' : 'No' ) );
80 |
81 | $owner = $userService->loadUser( $contentInfo->ownerId );
82 | $output->writeln( " Owner: " . $owner->contentInfo->name );
83 |
84 | $section = $sectionService->loadSection( $contentInfo->sectionId );
85 | $output->writeln( " Section: $section->name" );
86 |
87 | // show versions
88 | $versionInfoArray = $contentService->loadVersions( $contentInfo );
89 | if ( count( $versionInfoArray ) )
90 | {
91 | $output->writeln( "\nVERSIONS" );
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( "No content with id $contentId" );
104 | }
105 | catch ( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e )
106 | {
107 | $output->writeln( "Anonymous users are not allowed to read content with id $contentId" );
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 | 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 | 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 |
298 | Copyright (C)
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 | , 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 |
--------------------------------------------------------------------------------