Available online at:
http://j.mp/ez-sc-2013-public-api
eZContentObjectTreeNode
, eZContentObject
, eZContentClass
, ...private
, protected
, ...)Content object | Content |
Tree node | Location |
Content class | Content type |
Content attribute | Field |
Datatype | Field type |
Content class attribute | Field definition |
eZ\Publish\API\Repository\Repository
/** @var $repository eZ\Publish\API\Repository\Repository */
/** @var $sectionService eZ\Publish\API\Repository\SectionService */
$sectionService = $repository->getSectionService();
/** @var $section eZ\Publish\API\Repository\Values\Content\Section */
$section = $sectionService->loadSection( 1 );
ContentService
to handle contents (eZ\Publish\API\Repository\ContentService
)LocationService
to handle locations (eZ\Publish\API\Repository\LocationService
)ContentTypeService
to handle content types (eZ\Publish\API\Repository\ContentTypeService
)URLAliasService
to handle url aliases (eZ\Publish\API\Repository\URLAliasService
)SearchService
to search contents (eZ\Publish\API\Repository\SearchService
)Repository::setCurrentUser
UserService
$sectionService = $repository->getSectionService();
/** @var $section eZ\Publish\API\Repository\Values\Content\Section */
$section = $sectionService->loadSection( 1 );
$section
is a value object// changing the owner of a content
$contentService = $repository->getContentService();
$updateMetadataStruct = $contentService->newContentMetadataUpdateStruct();
$updateMetadataStruct->ownerId = 14;
$contentService->updateContentMetadata( $contentInfo, $updateMetadataStruct );
ContentMetadataUpdateStruct
, ContentUpdateStruct
, ContentCreateStruct
, .../** @var $repository \eZ\Publish\API\Repository\Repository */
$repository = $container->get( 'ezpublish.api.repository' );
$container
is the Symfony's service containereZ\Bundle\EzPublishCoreBundle\Controller
:$repository = $this->getRepository();
Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
:$repository = $this->getContainer()->get( 'ezpublish.api.repository' );
Content
vs. ContentInfo
SearchService
to find contentsuse eZ\Publish\API\Repository\Values\Content\Query;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
$searchService = $repository->getSearchService();
$query = new Query();
$query->criterion = new Criterion\Visibility( Criterion\Visibility::VISIBLE );
$query->limit = 10;
$query->offset = 0;
$query->sortClauses = array( new SortClause\LocationPriority() );
/** @var $contents eZ\Publish\API\Repository\Values\Content\Search\SearchResult */
$contents = $searchService->findContent( $query );
$items = eZContentObject::subTreeByNodeID(
array(
'Depth' => 1,
'ClassFilterType' => 'include',
'ClassFilterArray' => array( 'folder' ),
'SortBy' => array( array( 'priority', false ) )
), 2
);
$searchService = $repository->getSearchService();
$query = new Query();
$query->criterion = new Criterion\LogicalAnd(
array(
new Criterion\Visibility( Criterion\Visibility::VISIBLE ),
new Criterion\ParentLocationId( 2 ),
new Criterion\ContentTypeIdentifier( array( 'folder' ) )
)
);
$query->sortClauses = array( new SortClause\LocationPriority() );
/** @var $contents eZ\Publish\API\Repository\Values\Content\Search\SearchResult */
$contents = $searchService->findContent( $query );
$items = eZContentObject::subTreeByNodeID(
array(
'ClassFilterType' => 'include',
'ClassFilterArray' => array( 'folder' ),
'SortBy' => array( array( 'priority', false ) )
), 2
);
$searchService = $repository->getSearchService();
$query = new Query();
$query->criterion = new Criterion\LogicalAnd(
array(
new Criterion\Visibility( Criterion\Visibility::VISIBLE ),
new Criterion\Subtree( '/1/2' ),
new Criterion\ContentTypeIdentifier( array( 'folder' ) )
)
);
$query->sortClauses = array( new SortClause\LocationPriority() );
/** @var $contents eZ\Publish\API\Repository\Values\Content\Search\SearchResult */
$contents = $searchService->findContent( $query );
EzSystems/EzSummerCampPublicApiBundle
generate:bundle
command$ php ezpublish/console generate:bundle
phpunit -c ezpublish/ src/EzSystems/SummerCamp2013PublicApiBundle
failsEzSystems\SummerCamp2013PublicApiBundle\Controller\ExportController
half implemented/eng/summercamp/rssblogposts
RSS feed of the blog posts (10 last)EzSystems\SummerCamp2013PublicApiBundle\Controller\ExportController
$ php ezpublish/console summercamp:create_blog_posts
EzSystems\SummerCamp2013PublicApiBundle\Command\CreateBlogPostCommand
strip_tags( ezxml )
summercamp/rssblogposts
to accept parameters?