ezsystems/query-builder-bundle

此包已被废弃,不再维护。未建议替代包。

eZ Publish 5 的流畅仓库查询构建器

安装: 138

依赖者: 0

建议者: 0

安全: 0

星标: 5

关注者: 5

分叉: 5

开放问题: 0

类型:ezplatform-bundle

dev-master 2017-07-07 07:34 UTC

This package is auto-updated.

Last update: 2023-01-05 07:37:06 UTC


README

Build Status Coverage Status

此包为 eZ Publish(开源 CMS 平台)提供,它提供了一种 PHP API,用于流畅地编写仓库查询。它旨在使用丰富的 PHP IDE 时提供 精确 和上下文相关的 代码补全(已在 PhpStorm、Eclipse 和 NetBeans 上测试,所有平台均无需额外配置即可运行)。

状态:原型

此包以现有形式提供。目前它是一个工作的概念验证

  • 大多数元数据标准都将正常工作(parentLocationIdcontentTypeIdentifierdateModified...)
  • 大多数基于元数据的排序都将正常工作
  • 测试覆盖率现在相当高,但还有一些功能尚未测试或工作。

安装

从您的 eZ Publish 5 安装中,运行 composer require ezsystems/query-builder-bundle:dev-master。在 `ezpublish/EzPublishKernel.php` 中注册此包。

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

测试原型

有一个可用于测试构建器的命令:php ezpublish/console query-builder:test。它将执行在 vendor/ezsystems/query-builder-bundle/EzSystems/QueryBuilderBundle/Command/QueryBuilderTestCommand.php 中编写的查询,并将结果打印为表格。

您可以尝试操作它并测试各种方法。

用法

构建器是从 Symfony2 服务容器中获得的。使用流畅的 API 配置查询选项,并通过 getQuery() 使用 eZ\Publish\API\Values\Content\Query 对象。

/** @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 );

许可

此包受 GPL v2.0 许可 的约束。