Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ezplatform Core Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the package via Composer:

    composer require ezsystems/ezplatform-core
    

    Ensure your config/bundles.php includes EzSystems\EzPlatformCoreBundle\EzPlatformCoreBundle::class.

  2. 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
    }
    
  3. Key Entry Points

    • ContentService: CRUD operations for content.
    • SearchService: Querying content via eZ Platform’s search engine.
    • LocationService: Managing content hierarchy.
    • UserService: User-related operations (e.g., authentication, permissions).

Implementation Patterns

Core Workflows

1. Content Management

  • Create/Update Content:
    $contentCreateStruct = $contentService->newContentCreateStruct(
        $contentType,
        $parentLocation,
        $languageCode
    );
    $contentCreateStruct->setField('title', 'New Content');
    $contentDraft = $contentService->createContent($contentCreateStruct);
    $contentService->publishVersion($contentDraft->versionInfo);
    
  • Fetch Content:
    $content = $contentService->loadContent($contentId);
    $contentInfo = $contentService->getContentInfo($contentId);
    

2. Search Integration

  • Basic Search:
    $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);
    
  • Filtering:
    $filter = new \EzSystems\EzPlatformSearch\Search\Criteria\Filter();
    $filter->property('content_type_identifier', 'article');
    $query->query->filter = $filter;
    

3. Location Hierarchy

  • Move Content:
    $locationService = $this->repository->getLocationService();
    $location = $locationService->loadLocation($locationId);
    $newParent = $locationService->loadLocation($newParentId);
    $locationService->moveSubtree($location, $newParent);
    

4. User Management

  • Check Permissions:
    $userService = $this->repository->getUserService();
    $permission = $userService->hasAccess($contentId, 'edit');
    

Integration Tips

Laravel Service Providers

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

Event Listeners

Subscribe to eZ Platform events (e.g., ContentPublishedEvent) via Symfony’s event dispatcher:

$dispatcher->addListener(
    \EzSystems\EzPlatformCore\Event\Content\ContentPublishedEvent::class,
    [$this, 'onContentPublished']
);

Custom Field Types

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 }

Gotchas and Tips

Pitfalls

  1. Repository Initialization

    • Issue: Forgetting to inject Repository or using it outside a request context (e.g., in a queue job).
    • Fix: Use dependency injection and ensure the repository is initialized with a valid RequestContext:
      $repository = new Repository($this->container->get('ezplatform.repository.request_context'));
      
  2. Content Versioning

    • Issue: Publishing drafts without checking for conflicts or pending versions.
    • Fix: Use 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)
      }
      
  3. Search Performance

    • Issue: Complex queries without indexing or pagination.
    • Fix: Use Search\Criteria\Pagination and optimize with Search\Criteria\Query\Query::limit():
      $query->query->limit = 50;
      $query->query->offset = 0;
      
  4. Field Data Serialization

    • Issue: Incorrectly handling field data (e.g., assuming JSON structure without validation).
    • Fix: Use FieldService to validate and transform field data:
      $fieldService = $this->repository->getFieldService();
      $fieldValue = $fieldService->createFieldValue('textline', 'Hello');
      

Debugging Tips

  1. Enable Debug Mode Set ezplatform_core.debug: true in config/packages/ez_platform_core.yaml to log SQL queries and API calls.

  2. Log Repository Events Enable Symfony’s profiler and check the "eZ Platform" tab for repository events and performance metrics.

  3. 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');
    }
    

Extension Points

  1. 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'
    
  2. 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
    
  3. 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' }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views