Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
EZP-29613: As a developer I want access to ContentType on Content to …
…avoid re-loading it (#2444)

API:
* Initial simple addition of `Content->getContentType()` API
* Implement getContentType() on Core User & UserGroup object
* Add SPI method for  multi load content types
* Improve PHP doc on SPI/Persistence/Content/Type
* Adapt content domain mappers to bulk load content types
* Add unit test for Legacy/Content/Type/Handler::loadContentTypeList()
* Change MemoryCachingHandler to correctly use loadContentTypeList() and not single load()
* Change to use Doctrine QueryBuilder to fix loadTypesDataList(), use it for all loads for test coverage and consistency
* Fix Legacy Search test to keep connection, also refactor to avoid duplication

API:
* Expose `ContentTypeService->loadContentTypeList()` in order to adapt for new loadContentListByContentInfo()

Usage in Core, aka get rid of ContentType load operations:
* Adapt FieldRenderingExtension to use Content->getContentType()
* Optimize FieldHelper and it's usage in ContentExtension
* Optimize RestExecutedView to use content->getContentType()
  • Loading branch information
andrerom committed Dec 4, 2018
1 parent 2dbb6fb commit 59a0ea5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Persistence/Content/Type.php
Expand Up @@ -11,7 +11,7 @@
use eZ\Publish\SPI\Persistence\ValueObject;

/**
* @todo What about sort_field and sort_order?
* SPI Persistence Content\Type value object.
*/
class Type extends ValueObject
{
Expand Down Expand Up @@ -173,14 +173,17 @@ class Type extends ValueObject
public $groupIds = array();

/**
* Content fields in this type.
* Definitions for Content fields in this type.
*
* @var \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition[]
*/
public $fieldDefinitions = array();

/**
* @todo: Document.
* Defines if content objects should have always available enabled or not by default.
*
* Always available (when enabled) means main language is always available, and works as a editorial fallback
* language on load operations when translation filter is provided but no match is found.
*
* @var bool
*/
Expand Down
12 changes: 12 additions & 0 deletions Persistence/Content/Type/Handler.php
Expand Up @@ -81,6 +81,18 @@ public function loadAllGroups();
*/
public function loadContentTypes($groupId, $status = Type::STATUS_DEFINED);

/**
* Return list of unique Content Types, with type id as key.
*
* Missing items (NotFound) will be missing from the array and not cause an exception, it's up
* to calling logic to determine if this should cause exception or not.
*
* @param array $contentTypeIds
*
* @return \eZ\Publish\SPI\Persistence\Content\Type[]
*/
public function loadContentTypeList(array $contentTypeIds): array;

/**
* Loads a content type by id and status.
*
Expand Down

0 comments on commit 59a0ea5

Please sign in to comment.