Version 1
[yaffs-website] / web / core / modules / migrate / src / Annotation / MigrateSource.php
1 <?php
2
3 namespace Drupal\migrate\Annotation;
4
5 use Drupal\Component\Annotation\Plugin;
6
7 /**
8  * Defines a migration source plugin annotation object.
9  *
10  * Plugin Namespace: Plugin\migrate\source
11  *
12  * For a working example, check
13  * \Drupal\migrate\Plugin\migrate\source\EmptySource
14  * \Drupal\migrate_drupal\Plugin\migrate\source\UrlAlias
15  *
16  * @see \Drupal\migrate\Plugin\MigratePluginManager
17  * @see \Drupal\migrate\Plugin\MigrateSourceInterface
18  * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
19  * @see \Drupal\migrate\Annotation\MigrateProcessPlugin
20  * @see \Drupal\migrate\Annotation\MigrateDestination
21  * @see plugin_api
22  *
23  * @ingroup migration
24  *
25  * @Annotation
26  */
27 class MigrateSource extends Plugin implements MultipleProviderAnnotationInterface {
28
29   /**
30    * A unique identifier for the process plugin.
31    *
32    * @var string
33    */
34   public $id;
35
36   /**
37    * Whether requirements are met.
38    *
39    * @var bool
40    */
41   public $requirements_met = TRUE;
42
43   /**
44    * Identifies the system providing the data the source plugin will read.
45    *
46    * This can be any type, and the source plugin itself determines how the value
47    * is used. For example, Migrate Drupal's source plugins expect
48    * source_provider to be the name of a module that must be installed and
49    * enabled in the source database.
50    *
51    * @see \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase::checkRequirements
52    *
53    * @var mixed
54    */
55   public $source_provider;
56
57   /**
58    * Specifies the minimum version of the source provider.
59    *
60    * This can be any type, and the source plugin itself determines how it is
61    * used. For example, Migrate Drupal's source plugins expect this to be an
62    * integer representing the minimum installed database schema version of the
63    * module specified by source_provider.
64    *
65    * @var mixed
66    */
67   public $minimum_version;
68
69   /**
70    * {@inheritdoc}
71    */
72   public function getProvider() {
73     if (isset($this->definition['provider'])) {
74       return is_array($this->definition['provider']) ? reset($this->definition['provider']) : $this->definition['provider'];
75     }
76     return FALSE;
77   }
78
79   /**
80    * {@inheritdoc}
81    */
82   public function getProviders() {
83     if (isset($this->definition['provider'])) {
84       // Ensure that we return an array even if
85       // \Drupal\Component\Annotation\AnnotationInterface::setProvider() has
86       // been called.
87       return (array) $this->definition['provider'];
88     }
89     return [];
90   }
91
92   /**
93    * {@inheritdoc}
94    */
95   public function setProviders(array $providers) {
96     $this->definition['provider'] = $providers;
97   }
98
99 }