diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldInstanceListController.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldInstanceListController.php index dcac786..513619b 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldInstanceListController.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldInstanceListController.php @@ -108,7 +108,7 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr * {inheritdoc} */ public function render($entity_type = NULL, $bundle = NULL, Request $request = NULl) { - $this->entityType = $entity_type; + $this->entityTypeId = $entity_type; $this->bundle = $bundle; $this->bundleEntityType = $this->entityManager->getDefinition($entity_type)->getBundleEntityType(); $this->fieldTypes = $this->fieldTypeManager->getConfigurableDefinitions(); @@ -132,8 +132,8 @@ public function render($entity_type = NULL, $bundle = NULL, Request $request = N * {@inheritdoc} */ public function load() { - $entities = $this->fieldInfo->getBundleInstances($this->entityType, $this->bundle); - uasort($entities, array($this->entityInfo->getClass(), 'sort')); + $entities = $this->fieldInfo->getBundleInstances($this->entityTypeId, $this->bundle); + uasort($entities, array($this->entityType->getClass(), 'sort')); return $entities; } @@ -161,7 +161,7 @@ public function buildRow(EntityInterface $field_instance) { $field_type = array( '#type' => 'link', '#title' => $this->fieldTypes[$field_instance->getField()->getType()]['label'], - '#route_name' => 'field_ui.field_edit_' . $this->entityType, + '#route_name' => 'field_ui.field_edit_' . $this->entityTypeId, '#route_parameters' => array( $this->bundleEntityType => $this->bundle, 'field_instance' => $field_instance->id(), @@ -185,21 +185,21 @@ public function getOperations(EntityInterface $entity) { $operations['edit'] = array( 'title' => $this->t('Edit'), - 'route_name' => 'field_ui.instance_edit_' . $this->entityType, + 'route_name' => 'field_ui.instance_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters, 'attributes' => array('title' => $this->t('Edit instance settings.')), 'weight' => 10, ); $operations['field-settings'] = array( 'title' => $this->t('Field settings'), - 'route_name' => 'field_ui.field_edit_' . $this->entityType, + 'route_name' => 'field_ui.field_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters, 'attributes' => array('title' => $this->t('Edit field settings.')), 'weight' => 20, ); $operations['delete'] = array( 'title' => $this->t('Delete'), - 'route_name' => 'field_ui.delete_' . $this->entityType, + 'route_name' => 'field_ui.delete_' . $this->entityTypeId, 'route_parameters' => $route_parameters, 'attributes' => array('title' => $this->t('Delete instance.')), 'weight' => 30, diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldAddForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldAddForm.php index 474be68..5b7cd60 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldAddForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldAddForm.php @@ -33,7 +33,7 @@ class FieldAddForm extends FormBase { * * @var string */ - protected $entityType; + protected $entityTypeId; /** * The entity bundle. @@ -47,7 +47,7 @@ class FieldAddForm extends FormBase { * * @var string */ - protected $bundleEntityType; + protected $bundleEntityTypeId; /** * The entity manager. @@ -100,8 +100,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), $container->get('field.info'), - $container->get('plugin.manager.field.field_type'), - $container->get('form_builder') + $container->get('plugin.manager.field.field_type') ); } @@ -110,15 +109,15 @@ public static function create(ContainerInterface $container) { */ public function buildForm(array $form, array &$form_state, $entity_type = NULL, $bundle = NULL) { $entity_info = $this->entityManager->getDefinition($entity_type); - $this->bundleEntityType = $entity_info->getBundleEntityType(); + $this->bundleEntityTypeId = $entity_info->getBundleEntityType(); if (!isset($form_state['bundle'])) { if (!$bundle) { - $bundle = $this->getRequest()->attributes->get('_raw_variables')->get($this->bundleEntityType); + $bundle = $this->getRequest()->attributes->get('_raw_variables')->get($this->bundleEntityTypeId); } $form_state['bundle'] = $bundle; } - $this->entityType = $entity_type; + $this->entityTypeId = $entity_type; $this->bundle = $form_state['bundle']; $form = array( @@ -333,14 +332,14 @@ public function submitForm(array &$form, array &$form_state) { $field_prefix = $this->config('field_ui.settings')->get('field_prefix'); $field = array( - 'entity_type' => $this->entityType, + 'entity_type' => $this->entityTypeId, 'name' => $field_prefix . $form_state['values']['field_name'], 'type' => $form_state['values']['type'], 'translatable' => $form_state['values']['translatable'], ); $instance = array( 'field_name' => $field['name'], - 'entity_type' => $this->entityType, + 'entity_type' => $this->entityTypeId, 'bundle' => $this->bundle, 'label' => $values['label'], ); @@ -357,12 +356,12 @@ public function submitForm(array &$form, array &$form_state) { // Always show the field settings step, as the cardinality needs to be // configured for new fields. $route_parameters = array( - $this->bundleEntityType => $this->bundle, + $this->bundleEntityTypeId => $this->bundle, 'field_instance' => $new_instance->id(), ); - $destinations[] = array('route_name' => 'field_ui.field_edit_' . $this->entityType, 'route_parameters' => $route_parameters); - $destinations[] = array('route_name' => 'field_ui.instance_edit_' . $this->entityType, 'route_parameters' => $route_parameters); - $destinations[] = array('route_name' => 'field_ui.overview_' . $this->entityType, 'route_parameters' => $route_parameters); + $destinations[] = array('route_name' => 'field_ui.field_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters); + $destinations[] = array('route_name' => 'field_ui.instance_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters); + $destinations[] = array('route_name' => 'field_ui.overview_' . $this->entityTypeId, 'route_parameters' => $route_parameters); } catch (\Exception $e) { drupal_set_message($this->t('There was a problem creating field %label: !message', array('%label' => $instance['label'], '!message' => $e->getMessage())), 'error'); @@ -371,14 +370,14 @@ public function submitForm(array &$form, array &$form_state) { // Re-use existing field. if ($values['new_or_existing'] == 'existing') { - $field = $this->fieldInfo->getField($this->entityType, $values['field_name']); + $field = $this->fieldInfo->getField($this->entityTypeId, $values['field_name']); if (!empty($field->locked)) { drupal_set_message($this->t('The field %label cannot be added because it is locked.', array('%label' => $values['label'])), 'error'); } else { $instance = array( 'field_name' => $field->getName(), - 'entity_type' => $this->entityType, + 'entity_type' => $this->entityTypeId, 'bundle' => $this->bundle, 'label' => $values['label'], ); @@ -390,15 +389,15 @@ public function submitForm(array &$form, array &$form_state) { $this->configureEntityDisplays($field); $route_parameters = array( - $this->bundleEntityType => $this->bundle, + $this->bundleEntityTypeId => $this->bundle, 'field_instance' => $new_instance->id(), ); $destinations[] = array( - 'route_name' => 'field_ui.instance_edit_' . $this->entityType, + 'route_name' => 'field_ui.instance_edit_' . $this->entityTypeId, 'route_parameters' => $route_parameters, ); $destinations[] = array( - 'route_name' => 'field_ui.overview_' . $this->entityType, + 'route_name' => 'field_ui.overview_' . $this->entityTypeId, 'route_parameters' => $route_parameters, ); } @@ -428,14 +427,14 @@ protected function configureEntityDisplays(FieldDefinitionInterface $field) { // Make sure the field is displayed in the 'default' form mode (using // default widget and settings). It stays hidden for other form modes // until it is explicitly configured. - entity_get_form_display($this->entityType, $this->bundle, 'default') + entity_get_form_display($this->entityTypeId, $this->bundle, 'default') ->setComponent($field->getName()) ->save(); // Make sure the field is displayed in the 'default' view mode (using // default formatter and settings). It stays hidden for other view // modes until it is explicitly configured. - entity_get_display($this->entityType, $this->bundle, 'default') + entity_get_display($this->entityTypeId, $this->bundle, 'default') ->setComponent($field->getName()) ->save(); } @@ -456,11 +455,11 @@ protected function getExistingFieldOptions($field_type) { // entity type that are not already present in the current bundle. $field_map = $this->fieldInfo->getFieldMap(); $instance_ids = array(); - if (!empty($field_map[$this->entityType])) { - foreach ($field_map[$this->entityType] as $field_name => $data) { + if (!empty($field_map[$this->entityTypeId])) { + foreach ($field_map[$this->entityTypeId] as $field_name => $data) { if ($data['type'] == $field_type && !in_array($this->bundle, $data['bundles'])) { $bundle = reset($data['bundles']); - $instance_ids[] = $this->entityType . '.' . $bundle . '.' . $field_name; + $instance_ids[] = $this->entityTypeId . '.' . $bundle . '.' . $field_name; } } } @@ -502,7 +501,7 @@ public function fieldNameExists($value) { // Get the configured field prefix. $field_prefix = $this->config('field_ui.settings')->get('field_prefix'); - return (bool) $this->fieldInfo->getField($this->entityType, $field_prefix . $value); + return (bool) $this->fieldInfo->getField($this->entityTypeId, $field_prefix . $value); } }