2017 © Pedro Peláez
 

ezplatform-bundle query-builder-bundle

Fluent repository query builder for eZ Publish 5

image

ezsystems/query-builder-bundle

Fluent repository query builder for eZ Publish 5

  • Friday, July 7, 2017
  • by bdunogier
  • Repository
  • 5 Watchers
  • 3 Stars
  • 99 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 7 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

eZ Publish Query Builder bundle

Build Status Coverage Status, (*1)

This bundle for eZ Publish, the open-source CMS platform, provides a PHP API dedicated to fluently writing repository queries. It is built to provide accurate and contextually relevant code completion as long as a rich PHP IDE is used (tested with PhpStorm, Eclipse and NetBeans, works out of the box on all)., (*2)

Status: prototype

This bundle is provided as is. It is currently a working proof of concept:, (*3)

  • most metadata criteria will work (parentLocationId, contentTypeIdentifier, dateModified...)
  • most metadata based sorting will work
  • test coverage is quite high now, but quite a couple features aren't tested or working yet.

Installation

From your eZ Publish 5 installation, run composer require ezsystems/query-builder-bundle:dev-master. Register the bundle in `ezpublish/EzPublishKernel.php:, (*4)

    public function registerBundles()
    {
        $bundles = array(
            new FrameworkBundle(),
            // [...]
            new NelmioCorsBundle(),
            new EzSystems\QueryBuilderBundle\EzSystemsQueryBuilderBundle()
        );

Testing out the prototype

A command is available that can be used to test the builder: php ezpublish/console query-builder:test. It will execute the query written in vendor/ezsystems/query-builder-bundle/EzSystems/QueryBuilderBundle/Command/QueryBuilderTestCommand.php, and print out the results as a table., (*5)

You can play with it, and test the various methods., (*6)

Usage

The builder is obtained from the Symfony2 service container. The fluent API is used to configure the query's options, and the eZ\Publish\API\Values\Content\Query object is obtained by using getQuery():, (*7)

/** @var \EzSystems\QueryBuilderBundle\eZ\Publish\API\QueryBuilder */
$queryBuilder = $container->get( 'ezpublish.api.query_builder' );

// Filter on articles within sections #6 & #7 that have 'query' in their 'title' field, sorted by name
in an ascending order:

$queryBuilder
    ->contentTypeIdentifier()->eq( 'article' )
    ->sectionId()->in( 6, 7 )
    ->textLineField( 'title' )->contains( 'CMS' )
    ->sortBy()->contentName()->ascending();

// Get the query
$query = $queryBuilder->getQuery();

// Run the query using the search service
$results = $container->get( 'ezpublish.api.service.search' )->find( $query );

License

This bundle is under GPL v2.0 license., (*8)

The Versions

30/10 2016

dev-filter_query_support

dev-filter_query_support

Fluent repository query builder for eZ Publish 5

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires