diff --git a/core/modules/block_content/config/schema/block_content.views.schema.yml b/core/modules/block_content/config/schema/block_content.views.schema.yml index d77d9a1..af39d53 100644 --- a/core/modules/block_content/config/schema/block_content.views.schema.yml +++ b/core/modules/block_content/config/schema/block_content.views.schema.yml @@ -1,47 +1,14 @@ # Schema for the views plugins of the Block Content module. +# @todo Fix this when https://www.drupal.org/node/2322949 is fixed. views.field.block_content: type: views_field label: 'Block Content' mapping: - link_to_block_content: + link_to_entity: type: boolean label: 'Link this field to the original piece of block content' -# @todo Fix this when we support block content revision links. -# @see https://www.drupal.org/node/1984588 -#views.field.block_content_revision: -# type: views.field.node -# label: 'Block Content revision' -# mapping: -# link_to_block_content_revision: -# type: boolean -# label: 'Link this field to its block content revision' - -#views.field.block_content_revision_link: -# type: views_field -# label: 'Link to a block_content revision' -# mapping: -# text: -# type: label -# label: 'Text to display' - -#views.field.block_content_revision_link_delete: -# type: views_field -# label: 'Link to delete a block_content revision' -# mapping: -# text: -# type: label -# label: 'Text to display' - -#views.field.block_content_revision_link_revert: -# type: views_field -# label: 'Link to revert a block_content to a revision' -# mapping: -# text: -# type: label -# label: 'Text to display' - views.field.block_content_type: type: views.field.block_content label: 'Block content type' diff --git a/core/modules/block_content/src/BlockContentViewsData.php b/core/modules/block_content/src/BlockContentViewsData.php index ca4a9bd..e348936 100644 --- a/core/modules/block_content/src/BlockContentViewsData.php +++ b/core/modules/block_content/src/BlockContentViewsData.php @@ -24,10 +24,12 @@ public function getViewsData() { $data['block_content']['id']['field']['id'] = 'block_content'; $data['block_content_field_data']['info']['field']['id'] = 'block_content'; - $data['block_content_field_data']['info']['field']['link_to_block_content default'] = TRUE; + $data['block_content_field_data']['info']['field']['link_to_entity default'] = TRUE; $data['block_content_field_data']['type']['field']['id'] = 'block_content_type'; + // @todo Figure out the way to integrate this automatic in + // content_translation method itself. if ($this->moduleHandler->moduleExists('content_translation')) { $data['block_content']['translation_link'] = array( 'title' => $this->t('Translation link'), @@ -38,144 +40,6 @@ public function getViewsData() { ); } - // @todo Fix this when we support block content bulk form. - // @see https://www.drupal.org/node/2375589 - // $data['block_content']['block_content_bulk_form'] = array( - // 'title' => $this->t('Block Content operations bulk form'), - // 'help' => $this->t('Add a form element that lets you run operations on multiple block contents.'), - // 'field' => array( - // 'id' => 'block_content_bulk_form', - // ), - // ); - - // Bogus fields for aliasing purposes. - - // @todo Add similar support to any date field - // @see https://drupal.org/node/2337507 - $data['block_content_field_data']['changed_fulldate'] = array( - 'title' => $this->t('Updated date'), - 'help' => $this->t('Date in the form of CCYYMMDD.'), - 'argument' => array( - 'field' => 'changed', - 'id' => 'date_fulldate', - ), - ); - - $data['block_content_field_data']['changed_year_month'] = array( - 'title' => $this->t('Updated year + month'), - 'help' => $this->t('Date in the form of YYYYMM.'), - 'argument' => array( - 'field' => 'changed', - 'id' => 'date_year_month', - ), - ); - - $data['block_content_field_data']['changed_year'] = array( - 'title' => $this->t('Updated year'), - 'help' => $this->t('Date in the form of YYYY.'), - 'argument' => array( - 'field' => 'changed', - 'id' => 'date_year', - ), - ); - - $data['block_content_field_data']['changed_month'] = array( - 'title' => $this->t('Updated month'), - 'help' => $this->t('Date in the form of MM (01 - 12).'), - 'argument' => array( - 'field' => 'changed', - 'id' => 'date_month', - ), - ); - - $data['block_content_field_data']['changed_day'] = array( - 'title' => $this->t('Updated day'), - 'help' => $this->t('Date in the form of DD (01 - 31).'), - 'argument' => array( - 'field' => 'changed', - 'id' => 'date_day', - ), - ); - - $data['block_content_field_data']['changed_week'] = array( - 'title' => $this->t('Updated week'), - 'help' => $this->t('Date in the form of WW (01 - 53).'), - 'argument' => array( - 'field' => 'changed', - 'id' => 'date_week', - ), - ); - - // Advertise this table as a possible base table. - $data['block_content_revision']['table']['base']['help'] = $this->t('Block Content revision is a history of changes to block content.'); - $data['block_content_revision']['table']['base']['defaults']['title'] = 'info'; - - // @todo the ID field needs different behaviour on revision/non-revision - // tables. It would be neat if this could be encoded in the base field - // definition. - $data['block_content_revision']['id']['relationship']['id'] = 'standard'; - $data['block_content_revision']['id']['relationship']['base'] = 'block_content'; - $data['block_content_revision']['id']['relationship']['base field'] = 'id'; - $data['block_content_revision']['id']['relationship']['title'] = $this->t('Block Content'); - $data['block_content_revision']['id']['relationship']['label'] = $this->t('Get the actual block content from a block content revision.'); - - $data['block_content_revision']['revision_id']['relationship']['id'] = 'standard'; - $data['block_content_revision']['revision_id']['relationship']['base'] = 'block_content'; - $data['block_content_revision']['revision_id']['relationship']['base field'] = 'revision_id'; - $data['block_content_revision']['revision_id']['relationship']['title'] = $this->t('Block Content'); - $data['block_content_revision']['revision_id']['relationship']['label'] = $this->t('Get the actual block content from a block content revision.'); - - $data['block_content_revision']['revision_log']['field']['id'] = 'xss'; - - $data['block_content_field_revision']['table']['group'] = $this->t('Custom Block revision'); - - $data['block_content_field_revision']['table']['join']['block_content_revision']['left_field'] = 'revision_id'; - $data['block_content_field_revision']['table']['join']['block_content_revision']['field'] = 'revision_id'; - $data['block_content_field_revision']['table']['join']['block_content_revision']['type'] = 'INNER'; - - $data['block_content_field_revision']['table']['join']['block_content']['left_field'] = 'revision_id'; - $data['block_content_field_revision']['table']['join']['block_content']['field'] = 'revision_id'; - - // @todo Fix this when we support block content revision links. - // @see https://www.drupal.org/node/1984588 - // $data['block_content_field_revision']['info']['field']['id'] = 'block_content_revision'; - - // @todo Figure out do we need this or not. - // $data['block_content_field_revision']['langcode']['field']['id'] = 'block_content_language'; - - // @todo Fix this when we support block content revision links. - // @see https://www.drupal.org/node/1984588 - // $data['block_content_revision']['link_to_revision'] = array( - // 'field' => array( - // 'title' => $this->t('Link to revision'), - // 'help' => $this->t('Provide a simple link to the revision.'), - // 'id' => 'block_content_revision_link', - // 'click sortable' => FALSE, - // ), - // ); - - // @todo Fix this when we support block content revision links. - // @see https://www.drupal.org/node/1984588 - // $data['block_content_revision']['revert_revision'] = array( - // 'field' => array( - // 'title' => $this->t('Link to revert revision'), - // 'help' => $this->t('Provide a simple link to revert to the revision.'), - // 'id' => 'block_content_revision_link_revert', - // 'click sortable' => FALSE, - // ), - // ); - - // @todo Fix this when we support block content revision links. - // @see https://www.drupal.org/node/1984588 - // $data['block_content_revision']['delete_revision'] = array( - // 'field' => array( - // 'title' => $this->t('Link to delete revision'), - // 'help' => $this->t('Provide a simple link to delete the content revision.'), - // 'id' => 'block_content_revision_link_delete', - // 'click sortable' => FALSE, - // ), - // ); - return $data; } diff --git a/core/modules/block_content/src/Plugin/views/field/BlockContent.php b/core/modules/block_content/src/Plugin/views/field/BlockContent.php index 3494305..71c7a1a 100644 --- a/core/modules/block_content/src/Plugin/views/field/BlockContent.php +++ b/core/modules/block_content/src/Plugin/views/field/BlockContent.php @@ -83,7 +83,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o parent::init($view, $display, $options); // Don't add the additional fields to groupby - if (!empty($this->options['link_to_block_content'])) { + if (!empty($this->options['link_to_entity'])) { $this->additional_fields['id'] = array('table' => 'block_content', 'field' => 'id'); } } @@ -93,7 +93,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o */ protected function defineOptions() { $options = parent::defineOptions(); - $options['link_to_block_content'] = array('default' => isset($this->definition['link_to_block_content default']) ? $this->definition['link_to_block_content default'] : FALSE); + $options['link_to_entity'] = array('default' => isset($this->definition['link_to_entity default']) ? $this->definition['link_to_entity default'] : FALSE); return $options; } @@ -101,11 +101,11 @@ protected function defineOptions() { * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { - $form['link_to_block_content'] = array( + $form['link_to_entity'] = array( '#title' => $this->t('Link this field to the original piece of block content'), '#description' => $this->t("Enable to override this field's links."), '#type' => 'checkbox', - '#default_value' => !empty($this->options['link_to_block_content']), + '#default_value' => !empty($this->options['link_to_entity']), ); parent::buildOptionsForm($form, $form_state); @@ -123,7 +123,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { * Returns a string for the link text. */ protected function renderLink($data, ResultRow $values) { - if (!empty($this->options['link_to_block_content']) && !empty($this->additional_fields['id'])) { + if (!empty($this->options['link_to_entity']) && !empty($this->additional_fields['id'])) { if ($data !== NULL && $data !== '') { $id = $this->getValue($values, 'id'); $block_content = $this->entityManager->getStorage('block_content')->load($id); diff --git a/core/modules/block_content/src/Plugin/views/field/Type.php b/core/modules/block_content/src/Plugin/views/field/Type.php index dd69a7d..907edec 100644 --- a/core/modules/block_content/src/Plugin/views/field/Type.php +++ b/core/modules/block_content/src/Plugin/views/field/Type.php @@ -13,6 +13,8 @@ /** * Field handler to translate a block content type into its readable form. * + * @todo Remove this when https://www.drupal.org/node/2363811 is fixed. + * * @ingroup views_field_handlers * * @ViewsField("block_content_type")