ezsystems/ezplatform-core
Core package of eZ Platform (Ibexa DXP) CMS for Symfony/PHP. Provides the content repository, domain services, persistence, and APIs that power content modeling, publishing workflows, and integration with the eZ Platform stack.
Installation Add the package via Composer:
composer require ezsystems/ezplatform-core
Ensure your config/bundles.php includes EzSystems\EzPlatformCoreBundle\EzPlatformCoreBundle::class.
First Use Case: Content Repository Access
Inject the EzSystems\EzPlatformCore\Repository\Repository service in a controller or command:
use EzSystems\EzPlatformCore\Repository\Repository;
public function __construct(private Repository $repository) {}
public function index()
{
$contentService = $this->repository->getContentService();
$searchService = $this->repository->getSearchService();
// Use services as needed
}
Key Entry Points
$contentCreateStruct = $contentService->newContentCreateStruct(
$contentType,
$parentLocation,
$languageCode
);
$contentCreateStruct->setField('title', 'New Content');
$contentDraft = $contentService->createContent($contentCreateStruct);
$contentService->publishVersion($contentDraft->versionInfo);
$content = $contentService->loadContent($contentId);
$contentInfo = $contentService->getContentInfo($contentId);
$searchService = $this->repository->getSearchService();
$query = new \EzSystems\EzPlatformSearch\Search\Criteria\Query();
$query->query = new \EzSystems\EzPlatformSearch\Search\Criteria\Query\Query();
$query->query->matchAll();
$searchResults = $searchService->findQuery($query);
$filter = new \EzSystems\EzPlatformSearch\Search\Criteria\Filter();
$filter->property('content_type_identifier', 'article');
$query->query->filter = $filter;
$locationService = $this->repository->getLocationService();
$location = $locationService->loadLocation($locationId);
$newParent = $locationService->loadLocation($newParentId);
$locationService->moveSubtree($location, $newParent);
$userService = $this->repository->getUserService();
$permission = $userService->hasAccess($contentId, 'edit');
Extend EzSystems\EzPlatformCoreBundle\DependencyInjection\EzPlatformCoreExtension in your config/packages/ez_platform_core.yaml:
ezplatform_core:
repository:
content_service: '@your_custom.content_service' # Override if needed
Subscribe to eZ Platform events (e.g., ContentPublishedEvent) via Symfony’s event dispatcher:
$dispatcher->addListener(
\EzSystems\EzPlatformCore\Event\Content\ContentPublishedEvent::class,
[$this, 'onContentPublished']
);
Extend field types by implementing EzSystems\EzPlatformFieldType\FieldType and register them in services.yaml:
services:
your_custom.field_type:
class: Your\Custom\FieldType
tags:
- { name: ezplatform.field_type }
Repository Initialization
Repository or using it outside a request context (e.g., in a queue job).RequestContext:
$repository = new Repository($this->container->get('ezplatform.repository.request_context'));
Content Versioning
ContentService::publishVersion() with VersionInfo and handle ContentPublishException:
try {
$contentService->publishVersion($versionInfo);
} catch (\EzSystems\EzPlatformCore\API\Exceptions\ContentPublishException $e) {
// Handle conflict (e.g., retry or notify user)
}
Search Performance
Search\Criteria\Pagination and optimize with Search\Criteria\Query\Query::limit():
$query->query->limit = 50;
$query->query->offset = 0;
Field Data Serialization
FieldService to validate and transform field data:
$fieldService = $this->repository->getFieldService();
$fieldValue = $fieldService->createFieldValue('textline', 'Hello');
Enable Debug Mode
Set ezplatform_core.debug: true in config/packages/ez_platform_core.yaml to log SQL queries and API calls.
Log Repository Events Enable Symfony’s profiler and check the "eZ Platform" tab for repository events and performance metrics.
Validate Content Structures
Use ContentTypeService to validate content structures before creation:
$contentTypeService = $this->repository->getContentTypeService();
$contentType = $contentTypeService->loadContentTypeByIdentifier('article');
if (!$contentType) {
throw new \RuntimeException('Content type not found');
}
Custom Content Services
Extend EzSystems\EzPlatformCore\API\Repository\Values\Content\ContentService by implementing a decorator:
class CustomContentService extends ContentService
{
public function createContent(ContentCreateStruct $contentCreateStruct)
{
// Pre-process logic
$result = parent::createContent($contentCreateStruct);
// Post-process logic
return $result;
}
}
Register it in services.yaml:
services:
ezplatform.repository.content_service:
class: Your\Custom\ContentService
decorates: 'ezplatform.repository.content_service'
Override Search Handlers
Replace the default search handler by configuring ezplatform.search.handler in config/packages/ez_platform_core.yaml:
ezplatform_core:
search:
handler: your_custom.search.handler
Custom Field Value Transformers
Implement EzSystems\EzPlatformFieldType\FieldValueTransformer for custom field types and tag it as a service:
services:
your_custom.field_value_transformer:
class: Your\Custom\FieldValueTransformer
tags:
- { name: ezplatform.field_value_transformer, type: 'your_custom_field_type' }
How can I help you explore Laravel packages today?