Closed (duplicate)
Project:
Block field
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
31 May 2017 at 13:25 UTC
Updated:
20 Feb 2018 at 20:02 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mbovan commentedAdding a patch that provides normalization for the settings field property as well.
Comment #3
wim leersjson,xml, etc)?Documenting the reason for this priority is useful for future maintainability.
At least until #2575761: Discuss a better system for discovering and selecting normalizers is fixed.
{@inheritdoc}s/HAL normalizer/HAL field item normalizer/
Hrm, what is this actually normalizing?
If there were tests, this would actually be clear.
Comment #4
wim leersFor an example for tests, see
\Drupal\Tests\serialization\Unit\Normalizer\TimestampItemNormalizerTest+ ideally also integration tests (for which I can also find you an example), but having at least such a unit test would be very valuable.(Because
TimestampItemNormalizer extends FieldItemNormalizer, just like this.)Comment #5
john cook commentedI've moved the service provider definition into services.yml instead of a custom class.
Changed the comments as suggested by Wim in #3.
@Wim; creating at test is causing be a bit of trouble. If I mock
BlockFieldItem, as withTimestampItemNormalizerTest, then the normalizer can't get thesettingsproperty. I've also tried to instantiateBlockFieldItemmocking other things but I'm having trouble getting it to work; if you know of anywhere I can see an example that would be helpful.Further detail about mocking
Using
$field_item->settings:BlockFieldItemreturns an array as expected using it's magic getter.NULL, probably because the property doesn't exist on the mock.Using a
foreach ($field_item as $property_name => $property)loop:BlockFieldItemreturns a\Drupal\Core\TypedData\Plugin\DataType\Mapobject.I could put in a check, but wouldn't the mean that the code would not be checked correctly?
Comment #7
berdirThe service provider is required because this module also needs to work without the hal module
Comment #8
john cook commentedThanks Berdir. I've reverted to use the custom service provider. There's interdiffs of this patch with the patches int #2 and #5.
Comment #10
john cook commentedNow I've got no idea what testbot wants.
It works locally.
Comment #11
berdirTests are run against 8.4, you are likely on 8.3.
Try removing the administer nodes permission then the UI is the same on 8.4 and 8.3. But that should be a separate issue, that's an existing fail.
Comment #12
JamesK commentedWhy does it depend on hal rather than serialization? You should be able to extend Drupal\serialization\Normalizer\FieldItemNormalizer to use this more generically.
Also, this is likely to require follow-up after #2895532: @DataType=map cannot be normalized, affects @FieldType=link, @FieldType=map
Comment #13
JamesK commentedAs the patch is now in #2895532: @DataType=map cannot be normalized, affects @FieldType=link, @FieldType=map (#96) it actually fixes this issue without anything needing to happen here.
Comment #14
berdirAgreed, closing as a duplicate of the core issue.