diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index bcdf86f..62df554 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -130,13 +130,13 @@ public function viewElements(FieldItemListInterface $items) { $this->currentUser->hasPermission('administer comments'))) { $mode = $comment_settings['default_mode']; $comments_per_page = $comment_settings['per_page']; - if ($cids = comment_get_thread($entity, $field_name, $mode, $comments_per_page, $this->settings['pager_id'])) { + if ($cids = comment_get_thread($entity, $field_name, $mode, $comments_per_page, $this->getSetting('pager_id'))) { $comments = $this->storageController->loadMultiple($cids); comment_prepare_thread($comments); $build = $this->viewBuilder->viewMultiple($comments); $build['pager']['#theme'] = 'pager'; - if (!empty($this->settings['pager_id'])) { - $build['pager']['#element'] = $this->settings['pager_id']; + if ($this->getSetting('pager_id')) { + $build['pager']['#element'] = $this->getSetting('pager_id'); } $output['comments'] = $build; } diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 4ec4313..958084d 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -85,7 +85,7 @@ */ public $originalMode; - /* + /** * The renderer objects used for this display, keyed by component name. */ protected $renderers = array(); @@ -98,7 +98,7 @@ protected $handlerManager; /** - * Context in which this entity will be used (e.g. 'display', 'form'). + * Context in which this entity will be used (e.g. 'view', 'form'). * * @var string */ @@ -239,10 +239,14 @@ public function setComponent($name, array $options = array()) { // Massage in some values $handler = $this->getComponentHandlerByElementName($name); - $options = $handler->massageIn($name, $options); + if ($handler) { + // @todo sometimes handler not found. + $options = $handler->massageIn($name, $options); + } $this->content[$name] = $options; unset($this->hidden[$name]); + unset($this->renderers[$name]); return $this; } @@ -277,7 +281,12 @@ public function getHighestWeight() { } /** - * {@inheritdoc} + * Finds component handler by element name. + * + * @param string $name + * The element name. + * + * @return \Drupal\entity\Plugin\Type\DisplayComponentHandlerBase */ public function getComponentHandlerByElementName($name) { if (!isset($this->handlers[$name])) { @@ -295,7 +304,12 @@ public function getComponentHandlerByElementName($name) { return $this->handlers[$name]; } /** - * {@inheritdoc} + * Instantiates component handler. + * + * @param string $type + * The type of component handler (field, extra_field). + * + * @return \Drupal\entity\Plugin\Type\DisplayComponentHandlerBase */ public function getComponentHandler($type) { $handler = $this->handlerManager->getInstance(array('type' => $type)); diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/DisplayComponent/ExtraFieldDisplayComponentHandler.php b/core/modules/entity/lib/Drupal/entity/Plugin/DisplayComponent/ExtraFieldDisplayComponentHandler.php index ce661f7..799c6cb 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/DisplayComponent/ExtraFieldDisplayComponentHandler.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/DisplayComponent/ExtraFieldDisplayComponentHandler.php @@ -46,4 +46,5 @@ public function hasElement($name) { $extra_fields = field_info_extra_fields($this->context['entity_type'], $this->context['bundle'], ($this->context['display_context'] == 'view' ? 'display' : $this->context['display_context'])); return isset($extra_fields[$name]); } + } diff --git a/core/modules/field/lib/Drupal/field/Plugin/DisplayComponent/FieldDisplayComponentHandler.php b/core/modules/field/lib/Drupal/field/Plugin/DisplayComponent/FieldDisplayComponentHandler.php index 6a9bdc5..65cf61f 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/DisplayComponent/FieldDisplayComponentHandler.php +++ b/core/modules/field/lib/Drupal/field/Plugin/DisplayComponent/FieldDisplayComponentHandler.php @@ -96,7 +96,7 @@ public function massageIn($name, array $options = array()) { // The field in process of removal from display. return $options; } - if ($this->context['display_context'] == 'display') { + if ($this->context['display_context'] == 'view') { return $this->formatterPluginManager->prepareConfiguration($field_definition->getType(), $options); } else { @@ -124,7 +124,7 @@ public function massageOut($properties) { * {@inheritdoc} */ public function prepareDisplayComponents(array &$components, array &$hidden_components) { - if ($this->context['display_context'] == 'display') { + if ($this->context['display_context'] == 'view') { $plugin_manager = $this->formatterPluginManager; } else { @@ -190,13 +190,8 @@ public function hasElement($name) { * Returns the field definition of a field. */ protected function getFieldDefinition($field_name) { - if (isset($definitions[$field_name])) { - return $definitions[$field_name]; - } - else { - $definitions = $this->getFieldDefinitions(); - return isset($definitions[$field_name]) ? $definitions[$field_name] : NULL; - } + $definitions = $this->getFieldDefinitions(); + return isset($definitions[$field_name]) ? $definitions[$field_name] : NULL; } /** @@ -226,4 +221,5 @@ protected function getFieldDefinitions() { return $this->fieldDefinitions; } + }