Skip to content

Commit

Permalink
[Skip CI][WiP] Introduced Content filtering API (ContentService::find)
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Apr 28, 2020
1 parent adc12ab commit f7a33b2
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 0 deletions.
7 changes: 7 additions & 0 deletions eZ/Publish/API/Repository/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use eZ\Publish\API\Repository\Values\Content\Relation;
use eZ\Publish\API\Repository\Values\User\User;
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
use Ibexa\Platform\API\Repository\Value\Content\ContentList;
use Ibexa\Platform\SPI\Repository\Value\Filter;

/**
* This class provides service methods for managing content.
Expand Down Expand Up @@ -514,6 +516,11 @@ public function hideContent(ContentInfo $contentInfo): void;
*/
public function revealContent(ContentInfo $contentInfo): void;

/**
* Fetches Content items from the Repository filtered by the given conditions.
*/
public function find(Filter $filter): ContentList;

/**
* Instantiates a new content create struct object.
*
Expand Down
7 changes: 7 additions & 0 deletions eZ/Publish/Core/Event/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
use eZ\Publish\API\Repository\Events\Content\UpdateContentEvent;
use eZ\Publish\API\Repository\Events\Content\UpdateContentMetadataEvent;
use eZ\Publish\SPI\Repository\Decorator\ContentServiceDecorator;
use Ibexa\Platform\API\Repository\Value\Content\ContentList;
use Ibexa\Platform\SPI\Repository\Value\Filter;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class ContentService extends ContentServiceDecorator
Expand Down Expand Up @@ -376,4 +378,9 @@ public function revealContent(ContentInfo $contentInfo): void
new RevealContentEvent(...$eventData)
);
}

public function find(Filter $filter): ContentList
{
return $this->innerService->find($filter);
}
}
10 changes: 10 additions & 0 deletions eZ/Publish/Core/Repository/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as SPIRelationCreateStruct;
use eZ\Publish\SPI\Persistence\Content\ContentInfo as SPIContentInfo;
use Exception;
use Ibexa\Platform\API\Repository\Value\Content\ContentList as APIContentList;
use Ibexa\Platform\Repository\Value as CoreValue;
use Ibexa\Platform\SPI\Repository\Value\Filter;

/**
* This class provides service methods for managing content.
Expand Down Expand Up @@ -2509,6 +2512,13 @@ public function revealContent(ContentInfo $contentInfo): void
}
}

public function find(Filter $filter): APIContentList
{
$contentList = new CoreValue\Content\ContentList();

return $contentList;
}

/**
* Instantiates a new content create struct object.
*
Expand Down
7 changes: 7 additions & 0 deletions eZ/Publish/Core/Repository/SiteAccessAware/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use eZ\Publish\API\Repository\LanguageResolver;
use Ibexa\Platform\API\Repository\Value\Content\ContentList;
use Ibexa\Platform\SPI\Repository\Value\Filter;

/**
* SiteAccess aware implementation of ContentService injecting languages where needed.
Expand Down Expand Up @@ -242,6 +244,11 @@ public function revealContent(ContentInfo $contentInfo): void
$this->service->revealContent($contentInfo);
}

public function find(Filter $filter): ContentList
{
return $this->service->find($filter);
}

public function newContentCreateStruct(ContentType $contentType, string $mainLanguageCode): ContentCreateStruct
{
return $this->service->newContentCreateStruct($contentType, $mainLanguageCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
use eZ\Publish\API\Repository\Values\User\User;
use Ibexa\Platform\API\Repository\Value\Content\ContentList;
use Ibexa\Platform\SPI\Repository\Value\Filter;

abstract class ContentServiceDecorator implements ContentService
{
Expand Down Expand Up @@ -240,6 +242,11 @@ public function revealContent(ContentInfo $contentInfo): void
$this->innerService->revealContent($contentInfo);
}

public function find(Filter $filter): ContentList
{
return $this->innerService->find($filter);
}

public function newContentCreateStruct(
ContentType $contentType,
string $mainLanguageCode
Expand Down
38 changes: 38 additions & 0 deletions src/lib/Core/Repository/Value/Content/ContentList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Platform\Repository\Value\Content;

use ArrayIterator;
use Ibexa\Platform\API\Repository\Value\Content\ContentList as APIContentList;
use Traversable;

/**
* @internal For internal use by Repository.
* Type-hint \Ibexa\Platform\API\Repository\Value\Content\ContentList instead.
*
* @see \Ibexa\Platform\API\Repository\Value\Content\ContentList
*/
final class ContentList implements APIContentList
{
/** @var int */
private $totalCount = 0;

/** @var \eZ\Publish\API\Repository\Values\Content\Content */
private $items;

public function getTotalCount(): int
{
return $this->totalCount;
}

public function getIterator(): Traversable
{
return new ArrayIterator($this->items);
}
}

0 comments on commit f7a33b2

Please sign in to comment.