Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\taxonomy\Controller;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\taxonomy\TermInterface;
|
||||
|
@ -19,20 +18,7 @@ use Drupal\taxonomy\VocabularyInterface;
|
|||
class TaxonomyController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Title callback for term pages.
|
||||
*
|
||||
* @param \Drupal\taxonomy\TermInterface $term
|
||||
* A taxonomy term entity.
|
||||
*
|
||||
* @return
|
||||
* The term name to be used as the page title.
|
||||
*/
|
||||
public function getTitle(TermInterface $term) {
|
||||
return $term->label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rendered edit form to create a new term associated to the given vocabulary.
|
||||
* Returns a form to add a new term to a vocabulary.
|
||||
*
|
||||
* @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary
|
||||
* The vocabulary this term will be added to.
|
||||
|
@ -49,13 +35,13 @@ class TaxonomyController extends ControllerBase {
|
|||
* Route title callback.
|
||||
*
|
||||
* @param \Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary
|
||||
* The taxonomy term.
|
||||
* The vocabulary.
|
||||
*
|
||||
* @return string
|
||||
* The term label.
|
||||
* The vocabulary label as a render array.
|
||||
*/
|
||||
public function vocabularyTitle(VocabularyInterface $taxonomy_vocabulary) {
|
||||
return SafeMarkup::xssFilter($taxonomy_vocabulary->label());
|
||||
return ['#markup' => $taxonomy_vocabulary->label(), '#allowed_tags' => Xss::getHtmlTagList()];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,11 +50,11 @@ class TaxonomyController extends ControllerBase {
|
|||
* @param \Drupal\taxonomy\TermInterface $taxonomy_term
|
||||
* The taxonomy term.
|
||||
*
|
||||
* @return string
|
||||
* The term label.
|
||||
* @return array
|
||||
* The term label as a render array.
|
||||
*/
|
||||
public function termTitle(TermInterface $taxonomy_term) {
|
||||
return SafeMarkup::xssFilter($taxonomy_term->getName());
|
||||
return ['#markup' => $taxonomy_term->getName(), '#allowed_tags' => Xss::getHtmlTagList()];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
109
core/modules/taxonomy/src/Plugin/migrate/builder/d6/TermNode.php
Normal file
109
core/modules/taxonomy/src/Plugin/migrate/builder/d6/TermNode.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\builder\d6\TermNode.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\builder\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\MigrateMessage;
|
||||
use Drupal\migrate\MigrateTemplateStorage;
|
||||
use Drupal\migrate\Plugin\migrate\builder\BuilderBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @PluginID("d6_term_node")
|
||||
*/
|
||||
class TermNode extends BuilderBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The migration template storage service.
|
||||
*
|
||||
* @var \Drupal\migrate\MigrateTemplateStorage
|
||||
*/
|
||||
protected $templateStorage;
|
||||
|
||||
/**
|
||||
* Constructs a TermNode builder.
|
||||
*
|
||||
* @param array $configuration
|
||||
* Plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate\MigrateTemplateStorage $template_storage
|
||||
* The migration template storage handler.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateTemplateStorage $template_storage) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->templateStorage = $template_storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('migrate.template_storage')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a map of source vocabulary IDs to expected destination IDs.
|
||||
*
|
||||
* @param array $source
|
||||
* Additional configuration for the d6_taxonomy_vocabulary source.
|
||||
*
|
||||
* @return array
|
||||
* The vid map. The keys are the source IDs and the values are the
|
||||
* (expected) destination IDs.
|
||||
*/
|
||||
protected function getVocabularyIdMap(array $source) {
|
||||
$map = [];
|
||||
|
||||
$template = $this->templateStorage->getTemplateByName('d6_taxonomy_vocabulary');
|
||||
$template['source'] += $source;
|
||||
|
||||
$migration = Migration::create($template);
|
||||
$executable = new MigrateExecutable($migration, new MigrateMessage());
|
||||
// Only process the destination ID properties.
|
||||
$process = array_intersect_key($template['process'], $migration->getDestinationPlugin()->getIds());
|
||||
|
||||
foreach ($migration->getSourcePlugin()->getIterator() as $source_row) {
|
||||
$row = new Row($source_row, $source_row);
|
||||
// Process the row to generate the expected destination ID.
|
||||
$executable->processRow($row, $process);
|
||||
$map[$row->getSourceProperty('vid')] = $row->getDestinationProperty('vid');
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildMigrations(array $template) {
|
||||
$migrations = [];
|
||||
|
||||
foreach ($this->getVocabularyIdMap($template['source']) as $source_vid => $destination_vid) {
|
||||
$values = $template;
|
||||
$values['id'] .= '__' . $source_vid;
|
||||
$values['source']['vid'] = $source_vid;
|
||||
$migration = Migration::create($values);
|
||||
$migration->setProcessOfProperty($destination_vid, 'tid');
|
||||
$migrations[] = $migration;
|
||||
}
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
|
@ -19,7 +18,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
|||
* source_provider = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class TermNode extends DrupalSqlBase implements SourceEntityInterface {
|
||||
class TermNode extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The join options between the node and the term node table.
|
||||
|
@ -76,18 +75,4 @@ class TermNode extends DrupalSqlBase implements SourceEntityInterface {
|
|||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'taxonomy_term';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class IndexTid extends ManyToOne {
|
|||
$titles = array();
|
||||
$terms = Term::loadMultiple($this->value);
|
||||
foreach ($terms as $term) {
|
||||
$titles[] = SafeMarkup::checkPlain(\Drupal::entityManager()->getTranslationFromContext($term)->label());
|
||||
$titles[] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
|
|
@ -169,16 +169,15 @@ class TaxonomyIndexTid extends PrerenderList {
|
|||
}
|
||||
|
||||
protected function documentSelfTokens(&$tokens) {
|
||||
$tokens['[' . $this->options['id'] . '-tid' . ']'] = $this->t('The taxonomy term ID for the term.');
|
||||
$tokens['[' . $this->options['id'] . '-name' . ']'] = $this->t('The taxonomy term name for the term.');
|
||||
$tokens['[' . $this->options['id'] . '-vocabulary-vid' . ']'] = $this->t('The machine name for the vocabulary the term belongs to.');
|
||||
$tokens['[' . $this->options['id'] . '-vocabulary' . ']'] = $this->t('The name for the vocabulary the term belongs to.');
|
||||
$tokens['{{ ' . $this->options['id'] . '__tid' . ' }}'] = $this->t('The taxonomy term ID for the term.');
|
||||
$tokens['{{ ' . $this->options['id'] . '__name' . ' }}'] = $this->t('The taxonomy term name for the term.');
|
||||
$tokens['{{ ' . $this->options['id'] . '__vocabulary_vid' . ' }}'] = $this->t('The machine name for the vocabulary the term belongs to.');
|
||||
$tokens['{{ ' . $this->options['id'] . '__vocabulary' . ' }}'] = $this->t('The name for the vocabulary the term belongs to.');
|
||||
}
|
||||
|
||||
protected function addSelfTokens(&$tokens, $item) {
|
||||
foreach (array('tid', 'name', 'vocabulary_vid', 'vocabulary') as $token) {
|
||||
// Replace _ with - for the vocabulary vid.
|
||||
$tokens['[' . $this->options['id'] . '-' . str_replace('_', '-', $token) . ']'] = isset($item[$token]) ? $item[$token] : '';
|
||||
$tokens['{{ ' . $this->options['id'] . '__' . $token . ' }}'] = isset($item[$token]) ? $item[$token] : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\taxonomy;
|
||||
|
||||
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
|
||||
use Drupal\Core\Breadcrumb\Breadcrumb;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
|
@ -29,7 +30,7 @@ class TermBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
|||
/**
|
||||
* The taxonomy storage.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityStorageInterface
|
||||
* @var \Drupal\Taxonomy\TermStorageInterface
|
||||
*/
|
||||
protected $termStorage;
|
||||
|
||||
|
@ -56,18 +57,28 @@ class TermBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function build(RouteMatchInterface $route_match) {
|
||||
$breadcrumb = new Breadcrumb();
|
||||
$breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>'));
|
||||
$term = $route_match->getParameter('taxonomy_term');
|
||||
// Breadcrumb needs to have terms cacheable metadata as a cacheable
|
||||
// dependency even though it is not shown in the breadcrumb because e.g. its
|
||||
// parent might have changed.
|
||||
$breadcrumb->addCacheableDependency($term);
|
||||
// @todo This overrides any other possible breadcrumb and is a pure
|
||||
// hard-coded presumption. Make this behavior configurable per
|
||||
// vocabulary or term.
|
||||
$breadcrumb = array();
|
||||
while ($parents = $this->termStorage->loadParents($term->id())) {
|
||||
$term = array_shift($parents);
|
||||
$parents = $this->termStorage->loadAllParents($term->id());
|
||||
// Remove current term being accessed.
|
||||
array_shift($parents);
|
||||
foreach (array_reverse($parents) as $term) {
|
||||
$term = $this->entityManager->getTranslationFromContext($term);
|
||||
$breadcrumb[] = Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', array('taxonomy_term' => $term->id()));
|
||||
$breadcrumb->addCacheableDependency($term);
|
||||
$breadcrumb->addLink(Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', array('taxonomy_term' => $term->id())));
|
||||
}
|
||||
$breadcrumb[] = Link::createFromRoute($this->t('Home'), '<front>');
|
||||
$breadcrumb = array_reverse($breadcrumb);
|
||||
|
||||
// This breadcrumb builder is based on a route parameter, and hence it
|
||||
// depends on the 'route' cache context.
|
||||
$breadcrumb->setCacheContexts(['route']);
|
||||
|
||||
return $breadcrumb;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Upgrade variables to taxonomy.settings.yml.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -31,7 +31,6 @@ class MigrateTaxonomyConfigsTest extends MigrateDrupal6TestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadDumps(['Variable.php']);
|
||||
$this->executeMigration('d6_taxonomy_settings');
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Upgrade taxonomy terms.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -33,12 +33,6 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase {
|
|||
array(array(2), array('vocabulary_2_i_1_')),
|
||||
array(array(3), array('vocabulary_3_i_2_')),
|
||||
)));
|
||||
$this->loadDumps([
|
||||
'TermData.php',
|
||||
'TermHierarchy.php',
|
||||
'Vocabulary.php',
|
||||
'VocabularyNodeTypes.php',
|
||||
]);
|
||||
$this->executeMigration('d6_taxonomy_term');
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Migrate taxonomy vocabularies to taxonomy.vocabulary.*.yml.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -29,7 +29,6 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal6TestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
|
||||
$this->executeMigration('d6_taxonomy_vocabulary');
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
|
||||
/**
|
||||
* Upgrade taxonomy term node associations.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTermNodeRevisionTest extends MigrateTermNodeTestBase {
|
||||
|
||||
|
@ -22,20 +22,17 @@ class MigrateTermNodeRevisionTest extends MigrateTermNodeTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$id_mappings = array(
|
||||
'd6_term_node' => array(
|
||||
'd6_term_node:*' => array(
|
||||
array(array(2), array(1)),
|
||||
),
|
||||
'd6_node_revision' => array(
|
||||
'd6_node_revision:*' => array(
|
||||
array(array(2), array(2)),
|
||||
),
|
||||
);
|
||||
$this->prepareMigrations($id_mappings);
|
||||
/** @var \Drupal\migrate\entity\Migration $migration */
|
||||
$migrations = entity_load_multiple('migration', array('d6_term_node_revision:*'));
|
||||
foreach ($migrations as $migration) {
|
||||
$executable = new MigrateExecutable($migration, $this);
|
||||
$executable->import();
|
||||
}
|
||||
|
||||
$migrations = Migration::loadMultiple(['d6_term_node_revision:*']);
|
||||
array_walk($migrations, [$this, 'executeMigration']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
|
||||
namespace Drupal\taxonomy\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
* Upgrade taxonomy term node associations.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateTermNodeTest extends MigrateTermNodeTestBase {
|
||||
|
||||
|
@ -22,12 +23,17 @@ class MigrateTermNodeTest extends MigrateTermNodeTestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
/** @var \Drupal\migrate\entity\Migration $migration */
|
||||
$migrations = entity_load_multiple('migration', array('d6_term_node:*'));
|
||||
foreach ($migrations as $migration) {
|
||||
$executable = new MigrateExecutable($migration, $this);
|
||||
$executable->import();
|
||||
}
|
||||
$id_mappings = array(
|
||||
'd6_node:*' => array(
|
||||
array(
|
||||
array(0),
|
||||
array(0),
|
||||
),
|
||||
),
|
||||
);
|
||||
$this->prepareMigrations($id_mappings);
|
||||
$migrations = Migration::loadMultiple(['d6_term_node:*']);
|
||||
array_walk($migrations, [$this, 'executeMigration']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,6 +71,7 @@ abstract class MigrateTermNodeTestBase extends MigrateDrupal6TestBase {
|
|||
'type' => 'story',
|
||||
'nid' => $i,
|
||||
'vid' => array_shift($vids),
|
||||
'title' => $this->randomString(),
|
||||
));
|
||||
$node->enforceIsNew();
|
||||
$node->save();
|
||||
|
@ -82,17 +83,6 @@ abstract class MigrateTermNodeTestBase extends MigrateDrupal6TestBase {
|
|||
$node->save();
|
||||
}
|
||||
}
|
||||
$this->loadDumps([
|
||||
'Node.php',
|
||||
'NodeRevisions.php',
|
||||
'ContentTypeStory.php',
|
||||
'ContentTypeTestPlanet.php',
|
||||
'TermNode.php',
|
||||
'TermHierarchy.php',
|
||||
'TermData.php',
|
||||
'Vocabulary.php',
|
||||
'VocabularyNodeTypes.php',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Vocabulary entity display migration.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -69,8 +69,6 @@ class MigrateVocabularyEntityDisplayTest extends MigrateDrupal6TestBase {
|
|||
)
|
||||
);
|
||||
$this->prepareMigrations($id_mappings);
|
||||
|
||||
$this->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
|
||||
$this->executeMigration('d6_vocabulary_entity_display');
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Vocabulary entity form display migration.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -69,8 +69,6 @@ class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupal6TestBase {
|
|||
)
|
||||
);
|
||||
$this->prepareMigrations($id_mappings);
|
||||
|
||||
$this->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
|
||||
$this->executeMigration('d6_vocabulary_entity_form_display');
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Vocabulary field instance migration.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -68,7 +68,6 @@ class MigrateVocabularyFieldInstanceTest extends MigrateDrupal6TestBase {
|
|||
),
|
||||
))->save();
|
||||
|
||||
$this->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
|
||||
$this->executeMigration('d6_vocabulary_field_instance');
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
/**
|
||||
* Vocabulary field migration.
|
||||
*
|
||||
* @group taxonomy
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
|
||||
|
||||
|
@ -44,7 +44,6 @@ class MigrateVocabularyFieldTest extends MigrateDrupal6TestBase {
|
|||
'vid' => 'test_vocab',
|
||||
))->save();
|
||||
|
||||
$this->loadDumps(['Vocabulary.php', 'VocabularyNodeTypes.php']);
|
||||
$this->executeMigration('d6_vocabulary_field');
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,22 @@ class TermTest extends TaxonomyTestBase {
|
|||
*/
|
||||
protected $field;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public static $modules = ['block'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access']));
|
||||
$this->vocabulary = $this->createVocabulary();
|
||||
|
||||
|
@ -308,10 +322,7 @@ class TermTest extends TaxonomyTestBase {
|
|||
// Submitting a term takes us to the add page; we need the List page.
|
||||
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
|
||||
|
||||
// Test edit link as accessed from Taxonomy administration pages.
|
||||
// Because Simpletest creates its own database when running tests, we know
|
||||
// the first edit link found on the listing page is to our term.
|
||||
$this->clickLink(t('Edit'), 1);
|
||||
$this->clickLink(t('Edit'));
|
||||
|
||||
$this->assertRaw($edit['name[0][value]'], 'The randomly generated term name is present.');
|
||||
$this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.');
|
||||
|
@ -339,12 +350,12 @@ class TermTest extends TaxonomyTestBase {
|
|||
$this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.');
|
||||
|
||||
// Did this page request display a 'term-listing-heading'?
|
||||
$this->assertTrue($this->xpath('//div[contains(@class, "field-taxonomy-term--description")]'), 'Term page displayed the term description element.');
|
||||
$this->assertTrue($this->xpath('//div[contains(@class, "field--name-description")]'), 'Term page displayed the term description element.');
|
||||
// Check that it does NOT show a description when description is blank.
|
||||
$term->setDescription(NULL);
|
||||
$term->save();
|
||||
$this->drupalGet('taxonomy/term/' . $term->id());
|
||||
$this->assertFalse($this->xpath('//div[contains(@class, "field-taxonomy-term--description")]'), 'Term page did not display the term description when description was blank.');
|
||||
$this->assertFalse($this->xpath('//div[contains(@class, "field--entity-taxonomy-term--description")]'), 'Term page did not display the term description when description was blank.');
|
||||
|
||||
// Check that the description value is processed.
|
||||
$value = $this->randomMachineName();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\taxonomy\Tests;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
|
@ -86,13 +86,13 @@ class TokenReplaceTest extends TaxonomyTestBase {
|
|||
// Generate and test sanitized tokens for term1.
|
||||
$tests = array();
|
||||
$tests['[term:tid]'] = $term1->id();
|
||||
$tests['[term:name]'] = SafeMarkup::checkPlain($term1->getName());
|
||||
$tests['[term:name]'] = Html::escape($term1->getName());
|
||||
$tests['[term:description]'] = $term1->description->processed;
|
||||
$tests['[term:url]'] = $term1->url('canonical', array('absolute' => TRUE));
|
||||
$tests['[term:node-count]'] = 0;
|
||||
$tests['[term:parent:name]'] = '[term:parent:name]';
|
||||
$tests['[term:vocabulary:name]'] = SafeMarkup::checkPlain($this->vocabulary->label());
|
||||
$tests['[term:vocabulary]'] = SafeMarkup::checkPlain($this->vocabulary->label());
|
||||
$tests['[term:vocabulary:name]'] = Html::escape($this->vocabulary->label());
|
||||
$tests['[term:vocabulary]'] = Html::escape($this->vocabulary->label());
|
||||
|
||||
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($term1);
|
||||
|
||||
|
@ -117,14 +117,14 @@ class TokenReplaceTest extends TaxonomyTestBase {
|
|||
// Generate and test sanitized tokens for term2.
|
||||
$tests = array();
|
||||
$tests['[term:tid]'] = $term2->id();
|
||||
$tests['[term:name]'] = SafeMarkup::checkPlain($term2->getName());
|
||||
$tests['[term:name]'] = Html::escape($term2->getName());
|
||||
$tests['[term:description]'] = $term2->description->processed;
|
||||
$tests['[term:url]'] = $term2->url('canonical', array('absolute' => TRUE));
|
||||
$tests['[term:node-count]'] = 1;
|
||||
$tests['[term:parent:name]'] = SafeMarkup::checkPlain($term1->getName());
|
||||
$tests['[term:parent:name]'] = Html::escape($term1->getName());
|
||||
$tests['[term:parent:url]'] = $term1->url('canonical', array('absolute' => TRUE));
|
||||
$tests['[term:parent:parent:name]'] = '[term:parent:parent:name]';
|
||||
$tests['[term:vocabulary:name]'] = SafeMarkup::checkPlain($this->vocabulary->label());
|
||||
$tests['[term:vocabulary:name]'] = Html::escape($this->vocabulary->label());
|
||||
|
||||
// Test to make sure that we generated something for each token.
|
||||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
|
||||
|
@ -148,7 +148,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
|
|||
// Generate and test sanitized tokens.
|
||||
$tests = array();
|
||||
$tests['[vocabulary:vid]'] = $this->vocabulary->id();
|
||||
$tests['[vocabulary:name]'] = SafeMarkup::checkPlain($this->vocabulary->label());
|
||||
$tests['[vocabulary:name]'] = Html::escape($this->vocabulary->label());
|
||||
$tests['[vocabulary:description]'] = Xss::filter($this->vocabulary->getDescription());
|
||||
$tests['[vocabulary:node-count]'] = 1;
|
||||
$tests['[vocabulary:term-count]'] = 2;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\taxonomy\Tests\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Tests the "All terms" taxonomy term field handler.
|
||||
|
@ -23,7 +24,10 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
|
|||
*/
|
||||
public static $testViews = array('taxonomy_all_terms_test');
|
||||
|
||||
function testViewsHandlerAllTermsField() {
|
||||
/**
|
||||
* Tests the "all terms" field handler.
|
||||
*/
|
||||
public function testViewsHandlerAllTermsField() {
|
||||
$view = Views::getView('taxonomy_all_terms_test');
|
||||
$this->executeView($view);
|
||||
$this->drupalGet('taxonomy_all_terms_test');
|
||||
|
@ -39,4 +43,28 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
|
|||
$this->assertEqual($actual[1]->__toString(), $this->term2->label());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests token replacement in the "all terms" field handler.
|
||||
*/
|
||||
public function testViewsHandlerAllTermsWithTokens() {
|
||||
$view = Views::getView('taxonomy_all_terms_test');
|
||||
$this->drupalGet('taxonomy_all_terms_token_test');
|
||||
|
||||
// Term itself: {{ term_node_tid }}
|
||||
$this->assertText('Term: ' . $this->term1->getName());
|
||||
|
||||
// The taxonomy term ID for the term: {{ term_node_tid__tid }}
|
||||
$this->assertText('The taxonomy term ID for the term: ' . $this->term1->id());
|
||||
|
||||
// The taxonomy term name for the term: {{ term_node_tid__name }}
|
||||
$this->assertText('The taxonomy term name for the term: ' . $this->term1->getName());
|
||||
|
||||
// The machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }}
|
||||
$this->assertText('The machine name for the vocabulary the term belongs to: ' . $this->term1->getVocabularyId());
|
||||
|
||||
// The name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }}
|
||||
$vocabulary = Vocabulary::load($this->term1->bundle());
|
||||
$this->assertText('The name for the vocabulary the term belongs to: ' . $vocabulary->label());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ class VocabularyUiTest extends TaxonomyTestBase {
|
|||
parent::setUp();
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));
|
||||
$this->vocabulary = $this->createVocabulary();
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,7 +68,7 @@ class VocabularyListBuilder extends DraggableListBuilder {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildRow(EntityInterface $entity) {
|
||||
$row['label'] = $this->getLabel($entity);
|
||||
$row['label'] = $entity->label();
|
||||
return $row + parent::buildRow($entity);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue