upgrades core to 8.4.2

This commit is contained in:
Bachir Soussi Chiadmi
2017-11-14 16:09:54 +01:00
parent bd60eff9b3
commit c2b4e25be4
3504 changed files with 140306 additions and 38684 deletions
+3 -1
View File
@@ -46,6 +46,7 @@ use Drupal\taxonomy\TermInterface;
* "canonical" = "/taxonomy/term/{taxonomy_term}",
* "delete-form" = "/taxonomy/term/{taxonomy_term}/delete",
* "edit-form" = "/taxonomy/term/{taxonomy_term}/edit",
* "create" = "/taxonomy/term",
* },
* permission_granularity = "bundle"
* )
@@ -229,7 +230,8 @@ class Term extends ContentEntityBase implements TermInterface {
* {@inheritdoc}
*/
public function getVocabularyId() {
return $this->get('vid')->target_id;
@trigger_error('The ' . __METHOD__ . ' method is deprecated since version 8.4.0 and will be removed before 9.0.0. Use ' . __CLASS__ . '::bundle() instead to get the vocabulary ID.', E_USER_DEPRECATED);
return $this->bundle();
}
/**
@@ -227,7 +227,7 @@ class OverviewTerms extends FormBase {
];
}
$form['terms'][$key]['term'] = [
'#prefix' => !empty($indentation) ? drupal_render($indentation) : '',
'#prefix' => !empty($indentation) ? \Drupal::service('renderer')->render($indentation) : '',
'#type' => 'link',
'#title' => $term->getName(),
'#url' => $term->urlInfo(),
@@ -3,7 +3,6 @@
namespace Drupal\taxonomy\Plugin\EntityReferenceSelection;
use Drupal\Component\Utility\Html;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\Form\FormStateInterface;
use Drupal\taxonomy\Entity\Vocabulary;
@@ -24,8 +23,13 @@ class TermSelection extends DefaultSelection {
/**
* {@inheritdoc}
*/
public function entityQueryAlter(SelectInterface $query) {
// @todo: How to set access, as vocabulary is now config?
public function defaultConfiguration() {
return [
'sort' => [
'field' => 'name',
'direction' => 'asc',
]
] + parent::defaultConfiguration();
}
/**
@@ -49,15 +53,13 @@ class TermSelection extends DefaultSelection {
*/
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
if ($match || $limit) {
$this->configuration['handler_settings']['sort'] = ['field' => 'name', 'direction' => 'asc'];
return parent::getReferenceableEntities($match, $match_operator, $limit);
}
$options = [];
$bundles = $this->entityManager->getBundleInfo('taxonomy_term');
$handler_settings = $this->configuration['handler_settings'];
$bundle_names = !empty($handler_settings['target_bundles']) ? $handler_settings['target_bundles'] : array_keys($bundles);
$bundle_names = $this->getConfiguration()['target_bundles'] ?: array_keys($bundles);
foreach ($bundle_names as $bundle) {
if ($vocabulary = Vocabulary::load($bundle)) {
@@ -2,6 +2,8 @@
namespace Drupal\taxonomy\Plugin\migrate\cckfield;
@trigger_error('TaxonomyTermReference is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\taxonomy\Plugin\migrate\field\TaxonomyTermReference instead.', E_USER_DEPRECATED);
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
@@ -13,16 +15,14 @@ use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
* },
* core = {6,7}
* )
*
* @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use
* \Drupal\taxonomy\Plugin\migrate\field\TaxonomyTermReference instead.
*
* @see https://www.drupal.org/node/2751897
*/
class TaxonomyTermReference extends CckFieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
return [];
}
/**
* {@inheritdoc}
*/
@@ -0,0 +1,33 @@
<?php
namespace Drupal\taxonomy\Plugin\migrate\field;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
/**
* @MigrateField(
* id = "taxonomy_term_reference",
* type_map = {
* "taxonomy_term_reference" = "entity_reference"
* },
* core = {6,7}
* )
*/
class TaxonomyTermReference extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'iterator',
'source' => $field_name,
'process' => [
'target_id' => 'tid',
],
];
$migration->setProcessOfProperty($field_name, $process);
}
}
@@ -0,0 +1,46 @@
<?php
namespace Drupal\taxonomy\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Checks if the vocabulary being migrated is the one used for forums.
*
* Drupal 8 Forum is expecting specific machine names for its field and
* vocabulary names. This process plugin forces a given machine name to the
* field or vocabulary that is being migrated.
*
* The 'forum_vocabulary' source property is evaluated in the
* d6_taxonomy_vocabulary or d7_taxonomy_vocabulary source plugins and is set to
* true if the vocabulary vid being migrated is the same as the one in the
* 'forum_nav_vocabulary' variable on the source site.
*
* Example:
*
* @code
* process:
* field_name:
* plugin: forum_vocabulary
* machine_name: taxonomy_forums
* @endcode
*
* @MigrateProcessPlugin(
* id = "forum_vocabulary"
* )
*/
class ForumVocabulary extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if ($row->getSourceProperty('forum_vocabulary') && !empty($this->configuration['machine_name'])) {
$value = $this->configuration['machine_name'];
}
return $value;
}
}
@@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "taxonomy_term",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*
* @deprecated in Drupal 8.3.0, intended to be removed in Drupal 9.0.0.
@@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "d6_taxonomy_term",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class Term extends DrupalSqlBase {
@@ -10,7 +10,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "d6_term_node",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class TermNode extends DrupalSqlBase {
@@ -6,7 +6,8 @@ namespace Drupal\taxonomy\Plugin\migrate\source\d6;
* Source returning tids from the term_node table for the non-current revision.
*
* @MigrateSource(
* id = "d6_term_node_revision"
* id = "d6_term_node_revision",
* source_module = "taxonomy"
* )
*/
class TermNodeRevision extends TermNode {
@@ -11,7 +11,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class Vocabulary extends DrupalSqlBase {
@@ -69,6 +69,14 @@ class Vocabulary extends DrupalSqlBase {
->fetchCol();
$row->setSourceProperty('node_types', $node_types);
$row->setSourceProperty('cardinality', ($row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 1);
// If the vocabulary being migrated is the one defined in the
// 'forum_nav_vocabulary' variable, set the 'forum_vocabulary' source
// property to true so we know this is the vocabulary used by Forum.
if ($this->variableGet('forum_nav_vocabulary', 0) == $row->getSourceProperty('vid')) {
$row->setSourceProperty('forum_vocabulary', TRUE);
}
return parent::prepareRow($row);
}
@@ -7,7 +7,7 @@ namespace Drupal\taxonomy\Plugin\migrate\source\d6;
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary_per_type",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class VocabularyPerType extends Vocabulary {
@@ -9,7 +9,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "d6_taxonomy_vocabulary_translation",
* source_provider = "taxonomy"
* source_module = "i18ntaxonomy"
* )
*/
class VocabularyTranslation extends DrupalSqlBase {
@@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
*
* @MigrateSource(
* id = "d7_taxonomy_term",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class Term extends FieldableEntity {
@@ -70,6 +70,11 @@ class Term extends FieldableEntity {
->fetchCol();
$row->setSourceProperty('parent', $parents);
// Determine if this is a forum container.
$forum_container_tids = $this->variableGet('forum_containers', []);
$current_tid = $row->getSourceProperty('tid');
$row->setSourceProperty('is_container', in_array($current_tid, $forum_container_tids));
return parent::prepareRow($row);
}
@@ -2,6 +2,7 @@
namespace Drupal\taxonomy\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
@@ -9,7 +10,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
*
* @MigrateSource(
* id = "d7_taxonomy_vocabulary",
* source_provider = "taxonomy"
* source_module = "taxonomy"
* )
*/
class Vocabulary extends DrupalSqlBase {
@@ -46,6 +47,20 @@ class Vocabulary extends DrupalSqlBase {
];
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// If the vocabulary being migrated is the one defined in the
// 'forum_nav_vocabulary' variable, set the 'forum_vocabulary' source
// property to true so we know this is the vocabulary used by Forum.
if ($this->variableGet('forum_nav_vocabulary', 0) == $row->getSourceProperty('vid')) {
$row->setSourceProperty('forum_vocabulary', TRUE);
}
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
@@ -2,6 +2,7 @@
namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@@ -106,7 +107,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
// Now build the subqueries.
$subquery = db_select('taxonomy_index', 'tn');
$subquery->addField('tn', 'nid');
$where = db_or()->condition('tn.tid', $tids, $operator);
$where = (new Condition('OR'))->condition('tn.tid', $tids, $operator);
$last = "tn";
if ($this->options['depth'] > 0) {
@@ -17,9 +17,9 @@ use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
*/
class IndexTidDepthModifier extends ArgumentPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) { }
public function buildOptionsForm(&$form, FormStateInterface $form_state) {}
public function query($group_by = FALSE) { }
public function query($group_by = FALSE) {}
public function preQuery() {
// We don't know our argument yet, but it's based upon our position:
@@ -116,7 +116,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
];
$form['node'] = [
'#type' => 'checkbox',
'#title' => $this->t('Load default filter from node page, that\'s good for related taxonomy blocks'),
'#title' => $this->t("Load default filter from node page, that's good for related taxonomy blocks"),
'#default_value' => $this->options['node'],
];
@@ -194,7 +194,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
$taxonomy_terms = $node->{$field->getName()}->referencedEntities();
/** @var \Drupal\taxonomy\TermInterface $taxonomy_term */
foreach ($taxonomy_terms as $taxonomy_term) {
$taxonomy[$taxonomy_term->id()] = $taxonomy_term->getVocabularyId();
$taxonomy[$taxonomy_term->id()] = $taxonomy_term->bundle();
}
}
}
@@ -145,8 +145,8 @@ class TaxonomyIndexTid extends PrerenderList {
foreach ($data as $tid => $term) {
$this->items[$node_nid][$tid]['name'] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
$this->items[$node_nid][$tid]['tid'] = $tid;
$this->items[$node_nid][$tid]['vocabulary_vid'] = $term->getVocabularyId();
$this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->getVocabularyId()]->label();
$this->items[$node_nid][$tid]['vocabulary_vid'] = $term->bundle();
$this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->bundle()]->label();
if (!empty($this->options['link_to_taxonomy'])) {
$this->items[$node_nid][$tid]['make_link'] = TRUE;
@@ -82,7 +82,9 @@ class TaxonomyIndexTid extends ManyToOne {
}
}
public function hasExtraOptions() { return TRUE; }
public function hasExtraOptions() {
return TRUE;
}
/**
* {@inheritdoc}
@@ -2,6 +2,7 @@
namespace Drupal\taxonomy\Plugin\views\filter;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Form\FormStateInterface;
/**
@@ -54,7 +55,7 @@ class TaxonomyIndexTidDepth extends TaxonomyIndexTid {
$operator = '=';
}
else {
$operator = 'IN';# " IN (" . implode(', ', array_fill(0, sizeof($this->value), '%d')) . ")";
$operator = 'IN';
}
// The normal use of ensureMyTable() here breaks Views.
@@ -72,7 +73,7 @@ class TaxonomyIndexTidDepth extends TaxonomyIndexTid {
// Now build the subqueries.
$subquery = db_select('taxonomy_index', 'tn');
$subquery->addField('tn', 'nid');
$where = db_or()->condition('tn.tid', $this->value, $operator);
$where = (new Condition('OR'))->condition('tn.tid', $this->value, $operator);
$last = "tn";
if ($this->options['depth'] > 0) {
+1 -1
View File
@@ -85,7 +85,7 @@ class TermForm extends ContentEntityForm {
'#value' => $term->id(),
];
return parent::form($form, $form_state, $term);
return parent::form($form, $form_state);
}
/**
@@ -87,6 +87,9 @@ interface TermInterface extends ContentEntityInterface, EntityChangedInterface {
*
* @return string
* The id of the vocabulary.
*
* @deprecated Scheduled for removal before Drupal 9.0.0. Use
* TermInterface::bundle() instead.
*/
public function getVocabularyId();
@@ -52,7 +52,7 @@ interface TermStorageInterface extends ContentEntityStorageInterface {
* Finds all children of a term ID.
*
* @param int $tid
* Term ID to retrieve parents for.
* Term ID to retrieve children for.
* @param string $vid
* An optional vocabulary ID to restrict the child search.
*
@@ -65,7 +65,7 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
'terms[tid:' . $term2->id() . ':0][weight]' => 1,
];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid' ) . '/overview', $edit, t('Save'));
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview', $edit, t('Save'));
// All terms back at the root level, no indentation should be present.
$this->assertNoPattern('|<div class="js-indentation indentation">&nbsp;</div>|');
@@ -78,10 +78,6 @@ trait TaxonomyTranslationTestTrait {
/**
* Adds term reference field for the article content type.
*
* @param bool $translatable
* (optional) If TRUE, create a translatable term reference field. Defaults
* to FALSE.
*/
protected function setUpTermReferenceField() {
$handler_settings = [