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 602cba8..d77d9a1 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 @@ -8,30 +8,6 @@ views.field.block_content: type: boolean label: 'Link this field to the original piece of block content' -views.field.block_content_link: - type: views_field - label: 'Block Content link' - mapping: - text: - type: label - label: 'Text to display' - -views.field.block_content_link_delete: - type: views_field - label: 'Block Content delete link' - mapping: - text: - type: label - label: 'Text to display' - -views.field.block_content_path: - type: views_field - label: 'Block Content path' - mapping: - absolute: - type: boolean - label: 'Use absolute link (begins with "http://")' - # @todo Fix this when we support block content revision links. # @see https://www.drupal.org/node/1984588 #views.field.block_content_revision: diff --git a/core/modules/block_content/src/BlockContentViewsData.php b/core/modules/block_content/src/BlockContentViewsData.php index 9d744b1..ca4a9bd 100644 --- a/core/modules/block_content/src/BlockContentViewsData.php +++ b/core/modules/block_content/src/BlockContentViewsData.php @@ -21,8 +21,6 @@ public function getViewsData() { $data = parent::getViewsData(); - $data['block_content']['table']['wizard_id'] = 'block_content'; - $data['block_content']['id']['field']['id'] = 'block_content'; $data['block_content_field_data']['info']['field']['id'] = 'block_content'; @@ -30,10 +28,6 @@ public function getViewsData() { $data['block_content_field_data']['type']['field']['id'] = 'block_content_type'; - // @todo Figure out do we need this or not. - // $data['block_content_field_data']['langcode']['help'] = $this->t('The language of the block content or translation.'); - // $data['block_content_field_data']['langcode']['field']['id'] = 'block_content_language'; - if ($this->moduleHandler->moduleExists('content_translation')) { $data['block_content']['translation_link'] = array( 'title' => $this->t('Translation link'), @@ -43,31 +37,6 @@ public function getViewsData() { ), ); } - // Block content view link is actually an edit link. So we don't need an - // edit link. - $data['block_content']['view_link'] = array( - 'field' => array( - 'title' => $this->t('Link to block content'), - 'help' => $this->t('Provide a simple link to the block content.'), - 'id' => 'block_content_link', - ), - ); - - $data['block_content']['delete_link'] = array( - 'field' => array( - 'title' => $this->t('Link to delete block content'), - 'help' => $this->t('Provide a simple link to delete the block content.'), - 'id' => 'block_content_delete_link', - ), - ); - - $data['block_content']['path'] = array( - 'field' => array( - 'title' => $this->t('Path'), - 'help' => $this->t('The aliased path to this block content.'), - 'id' => 'block_content_path', - ), - ); // @todo Fix this when we support block content bulk form. // @see https://www.drupal.org/node/2375589 @@ -137,8 +106,6 @@ public function getViewsData() { ), ); - $data['block_content_revision']['table']['wizard_id'] = 'block_content_revision'; - // 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'; @@ -158,12 +125,8 @@ public function getViewsData() { $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.'); - // @todo Figure out do we need this or not. - // $data['block_content_revision']['langcode']['field']['id'] = 'block_content_language'; - $data['block_content_revision']['revision_log']['field']['id'] = 'xss'; - $data['block_content_field_revision']['table']['wizard_id'] = 'block_content_field_revision'; $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'; diff --git a/core/modules/block_content/src/Plugin/views/field/Link.php b/core/modules/block_content/src/Plugin/views/field/Link.php deleted file mode 100644 index f7f588d..0000000 --- a/core/modules/block_content/src/Plugin/views/field/Link.php +++ /dev/null @@ -1,98 +0,0 @@ - ''); - return $options; - } - - /** - * {@inheritdoc} - */ - public function buildOptionsForm(&$form, FormStateInterface $form_state) { - $form['text'] = array( - '#type' => 'textfield', - '#title' => $this->t('Text to display'), - '#default_value' => $this->options['text'], - ); - parent::buildOptionsForm($form, $form_state); - - // The path is set by renderLink function so don't allow to set it. - $form['alter']['path'] = array('#access' => FALSE); - $form['alter']['external'] = array('#access' => FALSE); - } - - /** - * {@inheritdoc} - */ - public function query() { - $this->addAdditionalFields(); - } - - /** - * {@inheritdoc} - */ - public function render(ResultRow $values) { - if ($entity = $this->getEntity($values)) { - return $this->renderLink($entity, $values); - } - } - - /** - * Prepares the link to the block_content. - * - * @param \Drupal\Core\Entity\EntityInterface $block_content - * The block_content entity this field belongs to. - * @param ResultRow $values - * The values retrieved from the view's result set. - * - * @return string - * Returns a string for the link text. - */ - protected function renderLink($block_content, ResultRow $values) { - // Ensure user has access to edit this block_content. - if (!$block_content->access('update')) { - return; - } - - $this->options['alter']['make_link'] = TRUE; - // Block content view link is actually an edit link. So we don't need an - // edit link. - $this->options['alter']['path'] = $block_content->url(); - $this->options['alter']['query'] = drupal_get_destination(); - - $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit'); - return $text; - } - -} diff --git a/core/modules/block_content/src/Plugin/views/field/LinkDelete.php b/core/modules/block_content/src/Plugin/views/field/LinkDelete.php deleted file mode 100644 index e8c5a54..0000000 --- a/core/modules/block_content/src/Plugin/views/field/LinkDelete.php +++ /dev/null @@ -1,38 +0,0 @@ -access('delete')) { - return; - } - - $this->options['alter']['make_link'] = TRUE; - $this->options['alter']['path'] = $block_content->url('delete-form'); - $this->options['alter']['query'] = drupal_get_destination(); - - $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete'); - return $text; - } - -} diff --git a/core/modules/block_content/src/Plugin/views/field/Path.php b/core/modules/block_content/src/Plugin/views/field/Path.php deleted file mode 100644 index 99e25d4..0000000 --- a/core/modules/block_content/src/Plugin/views/field/Path.php +++ /dev/null @@ -1,113 +0,0 @@ -urlGenerator = $url_generator; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('url_generator') - ); - } - - /** - * {@inheritdoc} - */ - public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { - parent::init($view, $display, $options); - - $this->additional_fields['id'] = 'id'; - } - - /** - * {@inheritdoc} - */ - protected function defineOptions() { - $options = parent::defineOptions(); - $options['absolute'] = array('default' => FALSE); - - return $options; - } - - /** - * {@inheritdoc} - */ - public function buildOptionsForm(&$form, FormStateInterface $form_state) { - parent::buildOptionsForm($form, $form_state); - $form['absolute'] = array( - '#type' => 'checkbox', - '#title' => $this->t('Use absolute link (begins with "http://")'), - '#default_value' => $this->options['absolute'], - '#description' => $this->t('Enable this option to output an absolute link. Required if you want to use the path as a link destination (as in "output this field as a link" above).'), - '#fieldset' => 'alter', - ); - } - - /** - * {@inheritdoc} - */ - public function query() { - $this->ensureMyTable(); - $this->addAdditionalFields(); - } - - /** - * {@inheritdoc} - */ - public function render(ResultRow $values) { - $id = $this->getValue($values, 'id'); - return $this->urlGenerator->generateFromRoute('entity.block_content.canonical', ['block_content' => $id], ['absolute' => $this->options['absolute']]); - } - -} diff --git a/core/modules/block_content/src/Plugin/views/wizard/BlockContent.php b/core/modules/block_content/src/Plugin/views/wizard/BlockContent.php deleted file mode 100644 index d5ab851..0000000 --- a/core/modules/block_content/src/Plugin/views/wizard/BlockContent.php +++ /dev/null @@ -1,67 +0,0 @@ -randomMachineName(); - $block_content = $this->createBlockContent(array('info' => $info)); - $this->drupalLogin($this->adminUser); - $this->drupalGet('test-block_content-links'); - $this->assertResponse(200); - $this->assertText('Link to block content'); - $this->assertText('Link to delete block content'); - $this->assertText('Path'); - $this->assertLink($block_content->label()); - $this->assertLink('Edit'); - $this->assertLinkByHref($block_content->url(), 1, 'Found the link to block edit page.'); - $this->assertLink('Delete'); - $this->assertLinkByHref($block_content->url('delete-form'), 0, 'Found the link to block delete page.'); - $this->assertText($block_content->url()); - } - -} diff --git a/core/modules/block_content/src/Tests/Views/BlockContentRevisionWizardTest.php b/core/modules/block_content/src/Tests/Views/BlockContentRevisionWizardTest.php deleted file mode 100644 index 52fb62b..0000000 --- a/core/modules/block_content/src/Tests/Views/BlockContentRevisionWizardTest.php +++ /dev/null @@ -1,80 +0,0 @@ - 'basic', - 'label' => 'Basic', - 'revision' => TRUE, - )); - // Create two block_contents with two revision. - $block_content_storage = \Drupal::entityManager()->getStorage('block_content'); - /** @var \Drupal\block_content\BlockContentInterface $block_content */ - $block_content = $block_content_storage->create(array('info' => $this->randomMachineName(), 'type' => 'basic')); - $block_content->save(); - - $block_content = $block_content->createDuplicate(); - $block_content->setNewRevision(); - $block_content->setInfo($this->randomMachineName()); - $block_content->save(); - - $block_content = $block_content_storage->create(array('info' => $this->randomMachineName(), 'type' => 'basic')); - $block_content->save(); - - $block_content = $block_content->createDuplicate(); - $block_content->setNewRevision(); - $block_content->setInfo($this->randomMachineName()); - $block_content->save(); - - $view = array(); - $view['label'] = $this->randomMachineName(16); - $view['id'] = strtolower($this->randomMachineName(16)); - $view['description'] = $this->randomMachineName(16); - $view['page[create]'] = FALSE; - $view['show[wizard_key]'] = 'block_content_revision'; - $this->drupalPostAjaxForm('admin/structure/views/add', $view, 'show[wizard_key]'); - $view['show[sort]'] = 'block_content_field_revision-changed:DESC'; - $this->drupalPostForm(NULL, $view, t('Save and edit')); - - $view_storage_controller = \Drupal::entityManager()->getStorage('view'); - /** @var \Drupal\views\Entity\View $view */ - $view = $view_storage_controller->load($view['id']); - - $this->assertEqual($view->get('base_table'), 'block_content_revision'); - - $executable = Views::executableFactory()->get($view); - $this->executeView($executable); - - $this->assertIdenticalResultset($executable, array(array('revision_id' => 1), array('revision_id' => 2), array('revision_id' => 3), array('revision_id' => 4)), - array('block_content_revision_id' => 'revision_id')); - } - -} diff --git a/core/modules/block_content/src/Tests/Views/BlockContentWizardTest.php b/core/modules/block_content/src/Tests/Views/BlockContentWizardTest.php deleted file mode 100644 index 8e15525..0000000 --- a/core/modules/block_content/src/Tests/Views/BlockContentWizardTest.php +++ /dev/null @@ -1,78 +0,0 @@ - 'basic', - 'label' => 'Basic', - 'revision' => FALSE, - )); - // Create two block_contents with two revision. - $block_content_storage = \Drupal::entityManager()->getStorage('block_content'); - /** @var \Drupal\block_content\BlockContentInterface $block_content */ - $block_content = $block_content_storage->create(array('info' => $this->randomMachineName(), 'type' => 'basic')); - $block_content->save(); - - $block_content = $block_content->createDuplicate(); - $block_content->setInfo($this->randomMachineName()); - $block_content->save(); - - $block_content = $block_content_storage->create(array('info' => $this->randomMachineName(), 'type' => 'basic')); - $block_content->save(); - - $block_content = $block_content->createDuplicate(); - $block_content->setInfo($this->randomMachineName()); - $block_content->save(); - - $view = array(); - $view['label'] = $this->randomMachineName(16); - $view['id'] = strtolower($this->randomMachineName(16)); - $view['description'] = $this->randomMachineName(16); - $view['page[create]'] = FALSE; - $view['show[wizard_key]'] = 'block_content'; - $this->drupalPostAjaxForm('admin/structure/views/add', $view, 'show[wizard_key]'); - $view['show[sort]'] = 'block_content_field_data-changed:DESC'; - $this->drupalPostForm(NULL, $view, t('Save and edit')); - - $view_storage_controller = \Drupal::entityManager()->getStorage('view'); - /** @var \Drupal\views\Entity\View $view */ - $view = $view_storage_controller->load($view['id']); - - $this->assertEqual($view->get('base_table'), 'block_content'); - - $executable = Views::executableFactory()->get($view); - $this->executeView($executable); - - $this->assertIdenticalResultset($executable, array(array('id' => 1), array('id' => 2), array('id' => 3), array('id' => 4)), - array('id' => 'id')); - } - -} diff --git a/core/modules/block_content/tests/modules/block_content_test_views/test_views/views.view.test_block_content_links.yml b/core/modules/block_content/tests/modules/block_content_test_views/test_views/views.view.test_block_content_links.yml deleted file mode 100644 index 03c5a09..0000000 --- a/core/modules/block_content/tests/modules/block_content_test_views/test_views/views.view.test_block_content_links.yml +++ /dev/null @@ -1,314 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - block_content.type.basic - module: - - block_content -id: test_block_content_links -label: test_block_content_links -module: views -description: '' -tag: '' -base_table: block_content -base_field: id -core: 8.x -display: - default: - display_plugin: default - id: default - display_title: Master - position: 0 - display_options: - access: - type: none - options: { } - cache: - type: none - options: { } - query: - type: views_query - options: - disable_sql_rewrite: false - distinct: false - replica: false - query_comment: false - query_tags: { } - exposed_form: - type: basic - options: - submit_button: Apply - reset_button: false - reset_button_label: Reset - exposed_sorts_label: 'Sort by' - expose_sort_order: true - sort_asc_label: Asc - sort_desc_label: Desc - pager: - type: full - options: - items_per_page: 10 - offset: 0 - id: 0 - total_pages: null - expose: - items_per_page: false - items_per_page_label: 'Items per page' - items_per_page_options: '5, 10, 25, 50' - items_per_page_options_all: false - items_per_page_options_all_label: '- All -' - offset: false - offset_label: Offset - tags: - previous: '‹ previous' - next: 'next ›' - first: '« first' - last: 'last »' - quantity: 9 - style: - type: table - options: - grouping: { } - row_class: '' - default_row_class: true - override: true - sticky: false - caption: '' - summary: '' - description: '' - columns: - info: info - view_link: view_link - delete_link: delete_link - edit_link: edit_link - translation_link: translation_link - info: - info: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - view_link: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - delete_link: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - edit_link: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - translation_link: - align: '' - separator: '' - empty_column: false - responsive: '' - default: '-1' - empty_table: false - row: - type: fields - options: - inline: { } - separator: '' - hide_empty: false - default_field_elements: true - fields: - info: - id: info - table: block_content_field_data - field: info - entity_type: block_content - entity_field: info - label: '' - alter: - alter_text: false - make_link: false - absolute: false - trim: false - word_boundary: false - ellipsis: false - strip_tags: false - html: false - hide_empty: false - empty_zero: false - link_to_block_content: true - plugin_id: block_content - relationship: none - group_type: group - admin_label: '' - exclude: false - element_type: '' - element_class: '' - element_label_type: '' - element_label_class: '' - element_label_colon: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_alter_empty: true - view_link: - id: view_link - table: block_content - field: view_link - relationship: none - group_type: group - admin_label: '' - label: 'Link to block content' - exclude: false - alter: - alter_text: false - text: '' - make_link: false - path: '' - absolute: false - external: false - replace_spaces: false - path_case: none - trim_whitespace: false - alt: '' - rel: '' - link_class: '' - prefix: '' - suffix: '' - target: '' - nl2br: false - max_length: '' - word_boundary: true - ellipsis: true - more_link: false - more_link_text: '' - more_link_path: '' - strip_tags: false - trim: false - preserve_tags: '' - html: false - element_type: '' - element_class: '' - element_label_type: '' - element_label_class: '' - element_label_colon: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_empty: false - empty_zero: false - hide_alter_empty: true - text: '' - entity_type: block_content - plugin_id: block_content_link - delete_link: - id: delete_link - table: block_content - field: delete_link - entity_type: block_content - plugin_id: block_content_delete_link - path: - id: path - table: block_content - field: path - relationship: none - group_type: group - admin_label: '' - label: Path - exclude: false - alter: - alter_text: false - text: '' - make_link: false - path: '' - absolute: false - external: false - replace_spaces: false - path_case: none - trim_whitespace: false - alt: '' - rel: '' - link_class: '' - prefix: '' - suffix: '' - target: '' - nl2br: false - max_length: '' - word_boundary: true - ellipsis: true - more_link: false - more_link_text: '' - more_link_path: '' - strip_tags: false - trim: false - preserve_tags: '' - html: false - element_type: '' - element_class: '' - element_label_type: '' - element_label_class: '' - element_label_colon: true - element_wrapper_type: '' - element_wrapper_class: '' - element_default_classes: true - empty: '' - hide_empty: false - empty_zero: false - hide_alter_empty: true - absolute: false - entity_type: block_content - plugin_id: block_content_path - filters: - type: - id: type - table: block_content - field: type - value: - basic: basic - entity_type: block_content - entity_field: type - plugin_id: bundle - sorts: - changed: - id: changed - table: block_content_field_data - field: changed - order: DESC - entity_type: block_content - entity_field: changed - plugin_id: date - relationship: none - group_type: group - admin_label: '' - exposed: false - expose: - label: '' - granularity: second - header: { } - footer: { } - empty: { } - relationships: { } - arguments: { } - display_extenders: { } - field_langcode: '***LANGUAGE_language_content***' - field_langcode_add_to_query: null - page_1: - display_plugin: page - id: page_1 - display_title: Page - position: 1 - display_options: - display_extenders: { } - field_langcode: '***LANGUAGE_language_content***' - field_langcode_add_to_query: null - path: test-block_content-links