-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EZP-29104: Impl. ImageAsset field type #246
EZP-29104: Impl. ImageAsset field type #246
Conversation
4cb73fc
to
c41b7e6
Compare
public function transform($value) | ||
{ | ||
if (!$value instanceof Value) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it more future proof I'd rather return null
for $value = null
but for !$value instanceof Value
it should throw \Symfony\Component\Form\Exception\TransformationFailedException
.
$this->fieldTypeService = $fieldTypeService; | ||
} | ||
|
||
public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to implement FieldDefinitionFormMapperInterface
and define empty method. It should work without these.
class ImageAssetFieldType extends AbstractType | ||
{ | ||
/** @var \eZ\Publish\API\Repository\ContentService */ | ||
private $contentService; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
{ | ||
$builder | ||
->add( | ||
'destinationContentId', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: no need to make it multiline
|
||
class ImageAssetValueTransformer extends AbstractBinaryBaseTransformer implements DataTransformerInterface | ||
{ | ||
public function transform($value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about docblock and return type hint here and reverseTransform()
?
/** @var \eZ\Publish\API\Repository\FieldTypeService */ | ||
private $fieldTypeService; | ||
|
||
public function __construct(FieldTypeService $fieldTypeService) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docblocks?
PR updated according to @webhdx @mikadamczyk suggestions. |
PR ready for the final code review @mikadamczyk @webhdx |
<?php | ||
|
||
/** | ||
* This file is part of the eZ Publish Kernel package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a part of the Kernel package. We can add declare(strict_types=1);
|
||
class SelectionOption extends ValueObject | ||
{ | ||
public $isDefault; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing dockblock and an empty line between properties
|
||
EzSystems\RepositoryForms\FieldType\Mapper\ImageAssetFormMapper: | ||
tags: | ||
- { name: ez.fieldFormMapper.definition, fieldType: ezimageasset } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ez.fieldFormMapper.definition
is not needed as the class is not implementing FieldDefinitionFormMapperInterface
Co-authored-by: Dawid Parafiński <[email protected]>
8457386
to
a503d1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready to merge @alongosz
Description
Impl. of
\EzSystems\RepositoryForms\FieldType\FieldDefinitionFormMapperInterface
and\EzSystems\RepositoryForms\FieldType\FieldValueFormMapperInterface
for Image Asset Field Type.