Skip to content
Snippets Groups Projects
Commit 7360754c authored by Matt Glaman's avatar Matt Glaman Committed by Bojan Živanović
Browse files

Override properties based on field overrides

parent 8b301b9b
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ use CommerceGuys\Addressing\AddressFormat\AddressField;
use CommerceGuys\Addressing\AddressFormat\FieldOverride;
use CommerceGuys\Addressing\AddressFormat\FieldOverrides;
use Drupal\address\AddressInterface;
use Drupal\address\FieldHelper;
use Drupal\address\LabelHelper;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
......@@ -134,6 +135,21 @@ class AddressItem extends FieldItemBase implements AddressInterface {
return $properties;
}
/**
* {@inheritdoc}
*/
public function getProperties($include_computed = FALSE) {
$properties = parent::getProperties($include_computed);
$parsed_overrides = new FieldOverrides($this->getFieldOverrides());
$hidden_properties = array_map(static function ($name) {
return FieldHelper::getPropertyName($name);
}, $parsed_overrides->getHiddenFields());
foreach ($hidden_properties as $hidden_property) {
unset($properties[$hidden_property]);
}
return $properties;
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment