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
|
@ -23,3 +23,19 @@ migrate.source.d6_taxonomy_vocabulary_per_type:
|
|||
constants:
|
||||
type: migrate_entity_constant
|
||||
label: 'Constants'
|
||||
|
||||
migrate.source.d6_term_node:
|
||||
type: migrate_source_sql
|
||||
label: 'Drupal 6 terms per node'
|
||||
mapping:
|
||||
vid:
|
||||
type: integer
|
||||
label: 'Vocabulary ID'
|
||||
|
||||
migrate.source.d6_term_node_revision:
|
||||
type: migrate_source_sql
|
||||
label: 'Drupal 6 terms per node revision'
|
||||
mapping:
|
||||
vid:
|
||||
type: integer
|
||||
label: 'Vocabulary ID'
|
||||
|
|
|
@ -2,6 +2,8 @@ id: d6_term_node
|
|||
label: Drupal 6 term/node relationships
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
builder:
|
||||
plugin: d6_term_node
|
||||
load:
|
||||
plugin: d6_term_node
|
||||
|
||||
|
@ -19,4 +21,4 @@ migration_dependencies:
|
|||
required:
|
||||
- d6_vocabulary_entity_display
|
||||
- d6_vocabulary_entity_form_display
|
||||
- d6_node
|
||||
- d6_node:*
|
||||
|
|
|
@ -2,6 +2,8 @@ id: d6_term_node_revision
|
|||
label: Drupal 6 term/node relationship revisions
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
builder:
|
||||
plugin: d6_term_node
|
||||
load:
|
||||
plugin: d6_term_node
|
||||
bundle_migration: d6_vocabulary_field
|
||||
|
@ -18,5 +20,5 @@ destination:
|
|||
plugin: entity_revision:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_term_node
|
||||
- d6_node_revision
|
||||
- d6_term_node:*
|
||||
- d6_node_revision:*
|
||||
|
|
|
@ -13,9 +13,13 @@ process:
|
|||
entity_type: 'constants/entity_type'
|
||||
type: 'constants/type'
|
||||
field_name:
|
||||
plugin: migration
|
||||
migration: d6_taxonomy_vocabulary
|
||||
source: vid
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_taxonomy_vocabulary
|
||||
source: vid
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
'settings/target_type': 'constants/target_entity_type'
|
||||
cardinality: 'constants/cardinality'
|
||||
destination:
|
||||
|
|
|
@ -12,9 +12,13 @@ process:
|
|||
entity_type: 'constants/entity_type'
|
||||
bundle: type
|
||||
field_name:
|
||||
plugin: migration
|
||||
migration: d6_taxonomy_vocabulary
|
||||
source: vid
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_taxonomy_vocabulary
|
||||
source: vid
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
'settings/handler': 'constants/selection_handler'
|
||||
'settings/handler_settings/target_bundles/0': @field_name
|
||||
'settings/handler_settings/auto_create': 'constants/auto_create'
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* Move a block in the blocks table from one region to another via select list.
|
||||
* Move a block in the blocks table from one region to another.
|
||||
*
|
||||
* This behavior is dependent on the tableDrag behavior, since it uses the
|
||||
* objects initialized in that behavior to update the row.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches the drag behavior to a applicable table element.
|
||||
*/
|
||||
Drupal.behaviors.termDrag = {
|
||||
attach: function (context, settings) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Builds placeholder replacement tokens for taxonomy terms and vocabularies.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
@ -109,7 +109,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
|
|||
break;
|
||||
|
||||
case 'name':
|
||||
$replacements[$original] = $sanitize ? SafeMarkup::checkPlain($term->getName()) : $term->getName();
|
||||
$replacements[$original] = $sanitize ? Html::escape($term->getName()) : $term->getName();
|
||||
break;
|
||||
|
||||
case 'description':
|
||||
|
@ -131,14 +131,14 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
|
|||
case 'vocabulary':
|
||||
$vocabulary = Vocabulary::load($term->bundle());
|
||||
$bubbleable_metadata->addCacheableDependency($vocabulary);
|
||||
$replacements[$original] = SafeMarkup::checkPlain($vocabulary->label());
|
||||
$replacements[$original] = Html::escape($vocabulary->label());
|
||||
break;
|
||||
|
||||
case 'parent':
|
||||
if ($parents = $taxonomy_storage->loadParents($term->id())) {
|
||||
$parent = array_pop($parents);
|
||||
$bubbleable_metadata->addCacheableDependency($parent);
|
||||
$replacements[$original] = SafeMarkup::checkPlain($parent->getName());
|
||||
$replacements[$original] = Html::escape($parent->getName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable
|
|||
break;
|
||||
|
||||
case 'name':
|
||||
$replacements[$original] = $sanitize ? SafeMarkup::checkPlain($vocabulary->label()) : $vocabulary->label();
|
||||
$replacements[$original] = $sanitize ? Html::escape($vocabulary->label()) : $vocabulary->label();
|
||||
break;
|
||||
|
||||
case 'description':
|
||||
|
|
|
@ -162,7 +162,7 @@ display:
|
|||
cache_metadata:
|
||||
contexts:
|
||||
- 'languages:language_interface'
|
||||
- 'url.query_args.pagers:0'
|
||||
- url.query_args
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
cacheable: false
|
||||
|
@ -177,7 +177,82 @@ display:
|
|||
cache_metadata:
|
||||
contexts:
|
||||
- 'languages:language_interface'
|
||||
- 'url.query_args.pagers:0'
|
||||
- url.query_args
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
cacheable: false
|
||||
page_2:
|
||||
display_plugin: page
|
||||
id: page_2
|
||||
display_title: 'Token tests'
|
||||
position: 2
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
display_description: ''
|
||||
fields:
|
||||
term_node_tid:
|
||||
id: term_node_tid
|
||||
table: node_field_data
|
||||
field: term_node_tid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: true
|
||||
text: "Term: {{ term_node_tid }}<br />\nThe taxonomy term ID for the term: {{ term_node_tid__tid }}<br />\nThe taxonomy term name for the term: {{ term_node_tid__name }}<br />\nThe machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }}<br />\nThe name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }}<br />"
|
||||
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: 0
|
||||
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: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
type: separator
|
||||
separator: '<br />'
|
||||
link_to_taxonomy: false
|
||||
limit: false
|
||||
vids:
|
||||
tags: '0'
|
||||
entity_type: node
|
||||
plugin_id: taxonomy_index_tid
|
||||
defaults:
|
||||
fields: false
|
||||
path: taxonomy_all_terms_token_test
|
||||
cache_metadata:
|
||||
contexts:
|
||||
- 'languages:language_interface'
|
||||
- url.query_args
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
cacheable: false
|
||||
|
|
|
@ -19,7 +19,6 @@ abstract class TermTestBase extends MigrateSqlSourceTestCase {
|
|||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'highWaterProperty' => array('field' => 'test'),
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_taxonomy_term',
|
||||
),
|
||||
|
|
|
@ -22,8 +22,6 @@ class VocabularyTest extends MigrateSqlSourceTestCase {
|
|||
protected $migrationConfiguration = [
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => [],
|
||||
'source' => [
|
||||
'plugin' => 'd6_vocabulary',
|
||||
],
|
||||
|
|
Reference in a new issue