Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / taxonomy / src / Plugin / migrate / process / ForumVocabulary.php
1 <?php
2
3 namespace Drupal\taxonomy\Plugin\migrate\process;
4
5 use Drupal\migrate\MigrateExecutableInterface;
6 use Drupal\migrate\ProcessPluginBase;
7 use Drupal\migrate\Row;
8
9 /**
10  * Checks if the vocabulary being migrated is the one used for forums.
11  *
12  * Drupal 8 Forum is expecting specific machine names for its field and
13  * vocabulary names. This process plugin forces a given machine name to the
14  * field or vocabulary that is being migrated.
15  *
16  * The 'forum_vocabulary' source property is evaluated in the
17  * d6_taxonomy_vocabulary or d7_taxonomy_vocabulary source plugins and is set to
18  * true if the vocabulary vid being migrated is the same as the one in the
19  * 'forum_nav_vocabulary' variable on the source site.
20  *
21  * Example:
22  *
23  * @code
24  * process:
25  *   field_name:
26  *     plugin: forum_vocabulary
27  *     machine_name: taxonomy_forums
28  * @endcode
29  *
30  * @MigrateProcessPlugin(
31  *   id = "forum_vocabulary"
32  * )
33  */
34 class ForumVocabulary extends ProcessPluginBase {
35
36   /**
37    * {@inheritdoc}
38    */
39   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
40     if ($row->getSourceProperty('forum_vocabulary') && !empty($this->configuration['machine_name'])) {
41       $value = $this->configuration['machine_name'];
42     }
43     return $value;
44   }
45
46 }