Issue #2134861 by Gábor Hojtsy, amateescu: Field instance bundle is only accessible directly on the bundle property.
parent
d370d5f6cf
commit
9145204f16
|
@ -18,15 +18,20 @@ namespace Drupal\config_translation;
|
|||
*/
|
||||
class ConfigFieldInstanceMapper extends ConfigEntityMapper {
|
||||
|
||||
/**
|
||||
* Loaded entity instance to help produce the translation interface.
|
||||
*
|
||||
* @var \Drupal\field\FieldInstanceInterface
|
||||
*/
|
||||
protected $entity;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBaseRouteParameters() {
|
||||
$parameters = parent::getBaseRouteParameters();
|
||||
$base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']);
|
||||
// @todo Field instances have no method to return the bundle the instance is
|
||||
// attached to. See https://drupal.org/node/2134861
|
||||
$parameters[$base_entity_info['bundle_entity_type']] = $this->entity->bundle;
|
||||
$parameters[$base_entity_info['bundle_entity_type']] = $this->entity->targetBundle();
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
|
|
|
@ -597,6 +597,13 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
|
|||
$this->bundle_rename_allowed = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function targetBundle() {
|
||||
return $this->bundle;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implements the magic __sleep() method.
|
||||
*
|
||||
|
|
|
@ -32,4 +32,12 @@ interface FieldInstanceInterface extends ConfigEntityInterface, FieldDefinitionI
|
|||
*/
|
||||
public function allowBundleRename();
|
||||
|
||||
/**
|
||||
* Returns the name of the bundle this field instance is attached to.
|
||||
*
|
||||
* @return string
|
||||
* The name of the bundle this field instance is attached to.
|
||||
*/
|
||||
public function targetBundle();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue