Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713
This commit is contained in:
parent
c0a0d5a94c
commit
9eae24d844
669 changed files with 3873 additions and 1553 deletions
|
@ -49,7 +49,7 @@ class TermSelection extends DefaultSelection {
|
|||
*/
|
||||
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
|
||||
if ($match || $limit) {
|
||||
return parent::getReferenceableEntities($match , $match_operator, $limit);
|
||||
return parent::getReferenceableEntities($match, $match_operator, $limit);
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
|
|
@ -68,7 +68,7 @@ class Vocabulary extends DrupalSqlBase {
|
|||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('node_types', $node_types);
|
||||
$row->setSourceProperty('cardinality', ($row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 1);
|
||||
$row->setSourceProperty('cardinality', ($row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 1);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
|
|
|
@ -391,8 +391,7 @@ class TaxonomyIndexTid extends ManyToOne {
|
|||
$vocabulary = $this->vocabularyStorage->load($this->options['vid']);
|
||||
$dependencies[$vocabulary->getConfigDependencyKey()][] = $vocabulary->getConfigDependencyName();
|
||||
|
||||
foreach ($this->options['value'] as $tid) {
|
||||
$term = $this->termStorage->load($tid);
|
||||
foreach ($this->termStorage->loadMultiple($this->options['value']) as $term) {
|
||||
$dependencies[$term->getConfigDependencyKey()][] = $term->getConfigDependencyName();
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class TermStorageSchema extends SqlContentEntityStorageSchema {
|
|||
'description' => 'The Unix timestamp when the node was created.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default'=> 0,
|
||||
'default' => 0,
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid', 'tid'),
|
||||
|
|
|
@ -58,7 +58,7 @@ class TermViewsData extends EntityViewsData {
|
|||
'relationship field' => 'tid',
|
||||
'outer field' => 'taxonomy_term_field_data.tid',
|
||||
'argument table' => 'taxonomy_term_field_data',
|
||||
'argument field' => 'tid',
|
||||
'argument field' => 'tid',
|
||||
'base' => 'node_field_data',
|
||||
'field' => 'nid',
|
||||
'relationship' => 'node_field_data:term_node_tid'
|
||||
|
|
|
@ -161,7 +161,7 @@ class TermTest extends TaxonomyTestBase {
|
|||
for ($x = 1; $x <= 17; $x++) {
|
||||
$this->assertNoText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' not found on Page 3');
|
||||
}
|
||||
for ($x =18; $x <= 25; $x++) {
|
||||
for ($x = 18; $x <= 25; $x++) {
|
||||
$this->assertText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' found on Page 3');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,4 +144,3 @@ class TokenReplaceTest extends TaxonomyTestBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\views\Entity\View;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
||||
/**
|
||||
* Test the taxonomy term index filter.
|
||||
*
|
||||
* @see \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TaxonomyIndexTidFilterTest extends TaxonomyTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'taxonomy_test_views', 'views', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $testViews = ['test_filter_taxonomy_index_tid__non_existing_dependency'];
|
||||
|
||||
/**
|
||||
* @var \Drupal\taxonomy\TermInterface[]
|
||||
*/
|
||||
protected $terms = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp(FALSE);
|
||||
|
||||
// Setup vocabulary and terms so the initial import is valid.
|
||||
Vocabulary::create([
|
||||
'vid' => 'tags',
|
||||
'name' => 'Tags',
|
||||
])->save();
|
||||
|
||||
// This will get a term ID of 3.
|
||||
$term = Term::create([
|
||||
'vid' => 'tags',
|
||||
'name' => 'muh',
|
||||
]);
|
||||
$term->save();
|
||||
// This will get a term ID of 4.
|
||||
$this->terms[$term->id()] = $term;
|
||||
$term = Term::create([
|
||||
'vid' => 'tags',
|
||||
'name' => 'muh',
|
||||
]);
|
||||
$term->save();
|
||||
$this->terms[$term->id()] = $term;
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests dependencies are not added for terms that do not exist.
|
||||
*/
|
||||
public function testConfigDependency() {
|
||||
/** @var \Drupal\views\Entity\View $view */
|
||||
$view = View::load('test_filter_taxonomy_index_tid__non_existing_dependency');
|
||||
|
||||
// Dependencies are sorted.
|
||||
$content_dependencies = [
|
||||
$this->terms[3]->getConfigDependencyName(),
|
||||
$this->terms[4]->getConfigDependencyName(),
|
||||
];
|
||||
sort($content_dependencies);
|
||||
|
||||
$this->assertEqual([
|
||||
'config' => [
|
||||
'taxonomy.vocabulary.tags',
|
||||
],
|
||||
'content' => $content_dependencies,
|
||||
'module' => [
|
||||
'node',
|
||||
'taxonomy',
|
||||
'user',
|
||||
],
|
||||
], $view->calculateDependencies()->getDependencies());
|
||||
|
||||
$this->terms[3]->delete();
|
||||
|
||||
$this->assertEqual([
|
||||
'config' => [
|
||||
'taxonomy.vocabulary.tags',
|
||||
],
|
||||
'content' => [
|
||||
$this->terms[4]->getConfigDependencyName(),
|
||||
],
|
||||
'module' => [
|
||||
'node',
|
||||
'taxonomy',
|
||||
'user',
|
||||
],
|
||||
], $view->calculateDependencies()->getDependencies());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests post update function fixes dependencies.
|
||||
*
|
||||
* @see views_post_update_taxonomy_index_tid()
|
||||
*/
|
||||
public function testPostUpdateFunction() {
|
||||
/** @var \Drupal\views\Entity\View $view */
|
||||
$view = View::load('test_filter_taxonomy_index_tid__non_existing_dependency');
|
||||
|
||||
// Dependencies are sorted.
|
||||
$content_dependencies = [
|
||||
$this->terms[3]->getConfigDependencyName(),
|
||||
$this->terms[4]->getConfigDependencyName(),
|
||||
];
|
||||
sort($content_dependencies);
|
||||
|
||||
$this->assertEqual([
|
||||
'config' => [
|
||||
'taxonomy.vocabulary.tags',
|
||||
],
|
||||
'content' => $content_dependencies,
|
||||
'module' => [
|
||||
'node',
|
||||
'taxonomy',
|
||||
'user',
|
||||
],
|
||||
], $view->calculateDependencies()->getDependencies());
|
||||
|
||||
$this->terms[3]->delete();
|
||||
|
||||
\Drupal::moduleHandler()->loadInclude('views', 'post_update.php');
|
||||
views_post_update_taxonomy_index_tid();
|
||||
|
||||
$view = View::load('test_filter_taxonomy_index_tid__non_existing_dependency');
|
||||
$this->assertEqual([
|
||||
'config' => [
|
||||
'taxonomy.vocabulary.tags',
|
||||
],
|
||||
'content' => [
|
||||
$this->terms[4]->getConfigDependencyName(),
|
||||
],
|
||||
'module' => [
|
||||
'node',
|
||||
'taxonomy',
|
||||
'user',
|
||||
],
|
||||
], $view->getDependencies());
|
||||
}
|
||||
|
||||
}
|
|
@ -55,11 +55,13 @@ abstract class TaxonomyTestBase extends ViewTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
$this->mockStandardInstall();
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
|
||||
if ($import_test_views) {
|
||||
ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
|
||||
}
|
||||
|
||||
$this->term1 = $this->createTerm();
|
||||
$this->term2 = $this->createTerm();
|
||||
|
|
|
@ -46,11 +46,11 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) {
|
|||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Managing vocabularies') . '</dt>';
|
||||
$output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission can add and edit vocabularies from the <a href=":taxonomy_admin">Taxonomy administration page</a>. Vocabularies can be deleted from their <em>Edit vocabulary</em> page. Users with the <em>Taxonomy term: Administer fields</em> permission may add additional fields for terms in that vocabulary using the <a href=":field_ui">Field UI module</a>.' , array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'), ':field_ui' => $field_ui_url)) . '</dd>';
|
||||
$output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission can add and edit vocabularies from the <a href=":taxonomy_admin">Taxonomy administration page</a>. Vocabularies can be deleted from their <em>Edit vocabulary</em> page. Users with the <em>Taxonomy term: Administer fields</em> permission may add additional fields for terms in that vocabulary using the <a href=":field_ui">Field UI module</a>.', array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'), ':field_ui' => $field_ui_url)) . '</dd>';
|
||||
$output .= '<dt>' . t('Managing terms') . '</dt>';
|
||||
$output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission or the <em>Edit terms</em> permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the <a href=":taxonomy_admin">Taxonomy administration page</a> and clicking <em>List terms</em> in the <em>Operations</em> column. Users must have the <em>Administer vocabularies and terms</em> permission or the <em>Delete terms</em> permission for a particular vocabulary to delete terms.' , array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'))) . ' </dd>';
|
||||
$output .= '<dd>' . t('Users who have the <em>Administer vocabularies and terms</em> permission or the <em>Edit terms</em> permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the <a href=":taxonomy_admin">Taxonomy administration page</a> and clicking <em>List terms</em> in the <em>Operations</em> column. Users must have the <em>Administer vocabularies and terms</em> permission or the <em>Delete terms</em> permission for a particular vocabulary to delete terms.', array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'))) . ' </dd>';
|
||||
$output .= '<dt>' . t('Classifying entity content') . '</dt>';
|
||||
$output .= '<dd>' . t('A user with the <em>Administer fields</em> permission for a certain entity type may add <em>Taxonomy term</em> reference fields to the entity type, which will allow entities to be classified using taxonomy terms. See the <a href=":entity_reference">Entity Reference help</a> for more information about reference fields. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them.' , array(':field_ui' => $field_ui_url, ':field' => \Drupal::url('help.page', array('name' => 'field')), ':entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '</dd>';
|
||||
$output .= '<dd>' . t('A user with the <em>Administer fields</em> permission for a certain entity type may add <em>Taxonomy term</em> reference fields to the entity type, which will allow entities to be classified using taxonomy terms. See the <a href=":entity_reference">Entity Reference help</a> for more information about reference fields. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them.', array(':field_ui' => $field_ui_url, ':field' => \Drupal::url('help.page', array('name' => 'field')), ':entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '</dd>';
|
||||
$output .= '<dt>' . t('Adding new terms during content creation') . '</dt>';
|
||||
$output .= '<dd>' . t('Allowing users to add new terms gradually builds a vocabulary as content is added and edited. Users can add new terms if either of the two <em>Autocomplete</em> widgets is chosen for the Taxonomy term reference field in the <em>Manage form display</em> page for the field. You will also need to enable the <em>Create referenced entities if they don\'t already exist</em> option, and restrict the field to one vocabulary.') . '</dd>';
|
||||
$output .= '<dt>' . t('Configuring displays and form displays') . '</dt>';
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
* Provides hook implementations for testing purposes.
|
||||
*/
|
||||
|
||||
use Drupal\taxonomy\VocabularyInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave() for taxonomy_vocabulary entities.
|
||||
*/
|
||||
function taxonomy_crud_taxonomy_vocabulary_presave(\Drupal\taxonomy\VocabularyInterface $vocabulary) {
|
||||
function taxonomy_crud_taxonomy_vocabulary_presave(VocabularyInterface $vocabulary) {
|
||||
$vocabulary->setThirdPartySetting('taxonomy_crud', 'foo', 'bar');
|
||||
}
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
- taxonomy
|
||||
- user
|
||||
id: test_filter_taxonomy_index_tid__non_existing_dependency
|
||||
label: test_filter_taxonomy_index_tid__non_existing_dependency
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 1
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'access content'
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
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: default
|
||||
options:
|
||||
grouping: { }
|
||||
row_class: ''
|
||||
default_row_class: true
|
||||
uses_fields: false
|
||||
row:
|
||||
type: fields
|
||||
options:
|
||||
inline: { }
|
||||
separator: ''
|
||||
hide_empty: false
|
||||
default_field_elements: true
|
||||
fields:
|
||||
title:
|
||||
id: title
|
||||
table: node_field_data
|
||||
field: title
|
||||
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
|
||||
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
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
filters:
|
||||
status:
|
||||
value: true
|
||||
table: node_field_data
|
||||
field: status
|
||||
id: status
|
||||
expose:
|
||||
operator: '0'
|
||||
group: 1
|
||||
plugin_id: boolean
|
||||
entity_type: node
|
||||
entity_field: status
|
||||
tid:
|
||||
id: tid
|
||||
table: taxonomy_index
|
||||
field: tid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: or
|
||||
value:
|
||||
- 3
|
||||
- 4
|
||||
group: 1
|
||||
exposed: false
|
||||
expose:
|
||||
operator_id: '0'
|
||||
label: ''
|
||||
description: ''
|
||||
use_operator: false
|
||||
operator: ''
|
||||
identifier: ''
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
reduce: false
|
||||
is_grouped: false
|
||||
group_info:
|
||||
label: ''
|
||||
description: ''
|
||||
identifier: ''
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items: { }
|
||||
reduce_duplicates: false
|
||||
type: select
|
||||
limit: true
|
||||
vid: tags
|
||||
hierarchy: true
|
||||
error_message: true
|
||||
plugin_id: taxonomy_index_tid
|
||||
sorts: { }
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 2
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: test-filter-taxonomy-index-tid
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
namespace Drupal\Tests\taxonomy\Kernel;
|
||||
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\taxonomy\Tests\TaxonomyTestTrait;
|
||||
|
||||
/**
|
||||
* Kernel tests for taxonomy term functions.
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
namespace Drupal\Tests\taxonomy\Kernel;
|
||||
|
||||
use Drupal\system\Tests\Entity\EntityUnitTestBase;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests term validation constraints.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermValidationTest extends EntityUnitTestBase {
|
||||
class TermValidationTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
Reference in a new issue