-
Notifications
You must be signed in to change notification settings - Fork 203
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 #2403
EZP-29104: Impl. ImageAsset field type #2403
Conversation
This comment has been minimized.
This comment has been minimized.
f781352
to
6b81695
Compare
6cabfd0
to
f131f00
Compare
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFieldTypeIdentifier() |
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.
we can add here return type hint
return $this->innerAliasGenerator->getVariation($field, $versionInfo, $variationName, $parameters); | ||
} | ||
|
||
public function supportsValue(Value $value): bool |
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 docblock
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getVariation(Field $field, VersionInfo $versionInfo, $variationName, array $parameters = []) |
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 return type hint
} | ||
} | ||
|
||
public function imageAssetSettingsProvider() |
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 docblock and return type hint
class AliasGeneratorTest extends TestCase | ||
{ | ||
/** | ||
* @var \eZ\Bundle\EzPublishCoreBundle\Imagine\ImageAsset\AliasGenerator |
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.
Should we use a single line or multiline for /** @var .... */ In this PR both are used
* | ||
* @param \eZ\Publish\Core\FieldType\ImageAsset\Value $value | ||
* | ||
* @return mixed |
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.
@return array
?
|
||
/** @var \eZ\Publish\API\Repository\ContentService|\PHPUnit_Framework_MockObject_MockObject */ | ||
private $contentService; | ||
/** @var \eZ\Publish\API\Repository\LocationService|\PHPUnit_Framework_MockObject_MockObject */ |
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 empty line
} | ||
|
||
/** | ||
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
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->assertEquals($expected, $actual); | ||
} | ||
|
||
public function dataProviderForIsAsset(): array |
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.
Should we add docblock here and below (createMapper()
, createPartialMapper()
, createContentWithId()
, createContentWithContentType()
?
@@ -76,4 +88,9 @@ public function getImageVariation(Field $field, VersionInfo $versionInfo, $varia | |||
} | |||
} | |||
} | |||
|
|||
public function getImageAssetContentFieldIdentifier() |
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 docblock and return type hint
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'm sorry, but from my perspective it's impossible to review. Please at least separate implementation from tests (I mean by commits). Since we're gonna squash this, PR commits don't need to have an issue number. They need to be in past tense though.
git reset origin/master
is your friend.
a66e067
to
9f77101
Compare
@alongosz I split PR into two separate commits as you requested: implementation and tests |
This comment has been minimized.
This comment has been minimized.
025369d
to
fa162cb
Compare
This comment has been minimized.
This comment has been minimized.
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException; | ||
use eZ\Publish\Core\FieldType\Image\Value as ImageValue; | ||
|
||
class Mapper |
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.
Please either change this name to be more meaningful or add short PhpDoc stating what this class maps.
This comment has been minimized.
This comment has been minimized.
PR ready for the final code review @alongosz @mikadamczyk |
* | ||
* @return bool | ||
*/ | ||
public function isSearchable(): bool |
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 method is same as in parent class, so it is redundant
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 method is same as in parent class, so it is redundant
I'm sorry to disagree in this case. Relying on the fact that the current implementation of FieldType
base core class returns false
is risky. While we probably wouldn't change it for any minor version (though there's no BC promise for Core), it's going to be difficult to track in case of major version upgrade.
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 agree with @mikadamczyk
I'm sorry to disagree in this case. Relying on the fact that the current implementation of FieldType base core class returns false is risky.
Not in this case: \eZ\Publish\Core\FieldType\FieldType
is the abstract class . If I cannot rely on methods inherited from it, then I should implement \eZ\Publish\SPI\FieldType\FieldType
from scratch.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
PR updated according to @alongosz suggestions. |
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.
+1, one nitpick, but fixing it won't affect behavior, so can be tested by QA
QA:
please try to see if you're able to use it in multisite environment with changed SiteAccess-aware config of this feature per SA (I suggest just parent_location_id
).
I'm asking for it because there are known issues when injecting dynamic parameters from SA config resolver.
$contentService: '@ezpublish.api.service.content' | ||
$locationService: '@ezpublish.api.service.location' | ||
$contentTypeService: '@ezpublish.api.service.content_type' | ||
$mappings: '$fieldtypes.ezimageasset.mappings$' |
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.
Since the setting is introduced on Bundle level, here you should rather have some core fallback. It will also allow you to avoid overriding service in test yamls.
f8d41a3
to
67fa812
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 :)
67fa812
to
525ec16
Compare
master
ImageAsset Field Type allows to store images in independent content items of a generic Image content type, in the media library, instead of storing them within the original content item to make then reusable accross system.
From the kernel POV its works as same as a
ezobjetrelation
field type.ImageAsset Field Type configuration
ImageAsset Field Type allows to configure the following options:
content_type_identifier
image
content_field_identifier
image
name_field_identifier
name
parent_location_id
51
Example configuration:
Customizing ImageAsset Field Type rendering
Internally the Image Asset Type is render via subrequest (similar to other relation types). Rendering customization is possible by configuring view type
asset_image
:Generating image variation from the Image Asset
Thanks to the
eZ\Bundle\EzPublishCoreBundle\Imagine\ImageAsset\AliasGenerator
decorator it is possible to work with\eZ\Publish\SPI\Variation\VariationHandler
in same way as with Image Field Type.TODO:
$ composer fix-cs
).