Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

FieldHelper.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Helper;
8
9 use eZ\Publish\API\Repository\ContentTypeService;
10 use eZ\Publish\API\Repository\FieldTypeService;
11 use eZ\Publish\API\Repository\Values\Content\Content;
12 use eZ\Publish\API\Repository\Values\Content\ContentInfo;
13
14 class FieldHelper
15 {
17 private $contentTypeService;
18
20 private $fieldTypeService;
21
23 private $translationHelper;
24
25 public function __construct(TranslationHelper $translationHelper, ContentTypeService $contentTypeService, FieldTypeService $fieldTypeService)
26 {
27 $this->fieldTypeService = $fieldTypeService;
28 $this->contentTypeService = $contentTypeService;
29 $this->translationHelper = $translationHelper;
30 }
31
41 public function isFieldEmpty(Content $content, $fieldDefIdentifier, $forcedLanguage = null)
42 {
43 $field = $this->translationHelper->getTranslatedField($content, $fieldDefIdentifier, $forcedLanguage);
44 $fieldDefinition = $content->getContentType()->getFieldDefinition($fieldDefIdentifier);
45
46 return $this
47 ->fieldTypeService
48 ->getFieldType($fieldDefinition->fieldTypeIdentifier)
49 ->isEmptyValue($field->value);
50 }
51
62 public function getFieldDefinition(ContentInfo $contentInfo, $fieldDefIdentifier)
63 {
64 return $this
65 ->contentTypeService
66 ->loadContentType($contentInfo->contentTypeId)
67 ->getFieldDefinition($fieldDefIdentifier);
68 }
69 }
eZ\Publish\API\Repository\Values\Content\ContentInfo
Definition: API/Repository/Values/Content/ContentInfo.php:31
eZ\Publish\API\Repository\Values\Content\Content
Definition: Publish/API/Repository/Values/Content/Content.php:21
eZ\Publish\API\Repository\Values\Content\Content\getContentType
getContentType()
Returns the ContentType for this content.
eZ\Publish\Core\Helper\FieldHelper
Definition: FieldHelper.php:15
eZ\Publish\Core\Helper\FieldHelper\$contentTypeService
$contentTypeService
Definition: FieldHelper.php:17
eZ\Publish\Core\Helper\FieldHelper\__construct
__construct(TranslationHelper $translationHelper, ContentTypeService $contentTypeService, FieldTypeService $fieldTypeService)
Definition: FieldHelper.php:25
eZ\Publish\Core\Helper\FieldHelper\$translationHelper
$translationHelper
Definition: FieldHelper.php:23
eZ\Publish\Core\Helper\FieldHelper\$fieldTypeService
$fieldTypeService
Definition: FieldHelper.php:20
eZ\Publish\Core\Helper\FieldHelper\getFieldDefinition
getFieldDefinition(ContentInfo $contentInfo, $fieldDefIdentifier)
Returns FieldDefinition object based on $contentInfo and $fieldDefIdentifier.
Definition: FieldHelper.php:62
eZ\Publish\Core\Helper\FieldHelper\isFieldEmpty
isFieldEmpty(Content $content, $fieldDefIdentifier, $forcedLanguage=null)
Checks if provided field can be considered empty.
Definition: FieldHelper.php:41
eZ\Publish\Core\Helper\TranslationHelper
Helper class for translation.
Definition: TranslationHelper.php:25
eZ\Publish\API\Repository\ContentTypeService
Definition: API/Repository/ContentTypeService.php:25
eZ\Publish\API\Repository\FieldTypeService
An implementation of this class provides access to FieldTypes.
Definition: API/Repository/FieldTypeService.php:15
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.