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