Issue #2134861 by Gábor Hojtsy, amateescu: Field instance bundle is only accessible directly on the bundle property.

8.0.x
webchick 2013-12-10 22:43:45 -08:00
parent d370d5f6cf
commit 9145204f16
3 changed files with 23 additions and 3 deletions

View File

@ -18,15 +18,20 @@ namespace Drupal\config_translation;
*/ */
class ConfigFieldInstanceMapper extends ConfigEntityMapper { class ConfigFieldInstanceMapper extends ConfigEntityMapper {
/**
* Loaded entity instance to help produce the translation interface.
*
* @var \Drupal\field\FieldInstanceInterface
*/
protected $entity;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getBaseRouteParameters() { public function getBaseRouteParameters() {
$parameters = parent::getBaseRouteParameters(); $parameters = parent::getBaseRouteParameters();
$base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']); $base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']);
// @todo Field instances have no method to return the bundle the instance is $parameters[$base_entity_info['bundle_entity_type']] = $this->entity->targetBundle();
// attached to. See https://drupal.org/node/2134861
$parameters[$base_entity_info['bundle_entity_type']] = $this->entity->bundle;
return $parameters; return $parameters;
} }

View File

@ -597,6 +597,13 @@ class FieldInstance extends ConfigEntityBase implements FieldInstanceInterface {
$this->bundle_rename_allowed = TRUE; $this->bundle_rename_allowed = TRUE;
} }
/**
* {@inheritdoc}
*/
public function targetBundle() {
return $this->bundle;
}
/* /*
* Implements the magic __sleep() method. * Implements the magic __sleep() method.
* *

View File

@ -32,4 +32,12 @@ interface FieldInstanceInterface extends ConfigEntityInterface, FieldDefinitionI
*/ */
public function allowBundleRename(); 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();
} }