FeaturesAssignerInterface.php
5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
/**
* @file
* Contains \Drupal\features\FeaturesAssignerInterface.
*/
namespace Drupal\features;
/**
* Common interface for features assignment services.
*
* The feature API is based on two major concepts:
* - Packages: modules into which configuration is packaged.
* - Package assignment methods: responsible for `determining
* which package to assign a given piece of configuration to.
* Assignment methods are customizable.
*
* Features defines several package assignment methods, which are simple plugin
* classes that implement a particular logic to assign pieces of configuration
* to a given package (module).
*
* Modules can define additional package assignment methods by simply providing
* the related plugins, and alter existing methods through
* hook_features_assignment_method_info_alter(). Here is an example
* snippet:
* @code
* function mymodule_features_assignment_method_info_alter(&$assignment_info) {
* // Replace the original plugin with our own implementation.
* $method_id = \Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentBaseType::METHOD_ID;
* $assignment_info[$method_id]['class'] = 'Drupal\my_module\Plugin\FeaturesAssignment\MyFeaturesAssignmentBaseType';
* }
*
* class MyFeaturesAssignmentBaseType extends FeaturesAssignmentBaseType {
* public function assignPackages($force = FALSE) {
* // Insert customization here.
* }
* }
* ?>
* @endcode
*
* For more information, see
* @link http://drupal.org/node/2404473 Developing for Features 3.x @endlink
*/
interface FeaturesAssignerInterface {
/**
* The package assignment method id for the package assigner itself.
*/
const METHOD_ID = 'assigner-default';
/**
* Resets the assigned packages and the method instances.
*/
public function reset();
/**
* Apply all enabled package assignment methods.
*
* @param bool $force
* (optional) If TRUE, assign config regardless of restrictions such as it
* being already assigned to a package.
*/
public function assignConfigPackages($force = FALSE);
/**
* Returns the enabled package assignment methods.
*
* @return array
* An array of package assignment method IDs.
*/
public function getAssignmentMethods();
/**
* Resaves the configuration to purge missing assignment methods.
*/
public function purgeConfiguration();
/**
* Returns a FeaturesBundle object.
*
* @param string $name
* machine name of package set. If omitted, returns the current bundle.
*
* @return \Drupal\features\FeaturesBundleInterface
* A features bundle object.
*/
public function getBundle($name = NULL);
/**
* Stores a features bundle.
*
* Added to list if machine_name is new.
*
* @param \Drupal\features\FeaturesBundleInterface $bundle
* A features bundle.
* @param bool $current
* Determine if the current bundle is set to $bundle.
* If False, the current bundle is only updated if it already has the same
* machine name as the $bundle.
*/
public function setBundle(FeaturesBundleInterface $bundle, $current = TRUE);
/**
* Searches for a bundle that matches the $info.yml export.
*
* Creates a new bundle as needed.
*
* @param array $info
* The bundle info.
*
* @return \Drupal\features\FeaturesBundleInterface
* A bundle.
*/
public function findBundle(array $info);
/**
* Sets the currently active bundle.
*
* Updates value in current SESSION.
*
* @param \Drupal\features\FeaturesBundleInterface $bundle
* A features bundle object.
*/
public function setCurrent(FeaturesBundleInterface $bundle);
/**
* Returns an array of all existing features bundles.
*
* @return array
* Keyed by machine_name with value of
* \Drupal\features\FeaturesBundleInterface.
*/
public function getBundleList();
/**
* Returns a named bundle.
*
* First searches by Human name, then by machine_name.
*
* @param string $name
* The bundle name to search by.
*
* @return \Drupal\features\FeaturesBundleInterface
* A features bundle object.
*/
public function findBundleByName($name);
/**
* Creates a new bundle.
*
* @param string $name
* Human readable name of the bundle.
* @param string $machine_name
* Machine name. If omitted, auto-generated from Name.
* @param string $description
* Optional description.
*
* @return \Drupal\features\FeaturesBundleInterface
* A features bundle object.
*/
public function createBundle($name, $machine_name = '', $description = '');
/**
* Returns an array of bundle names suitable for a select option list.
*
* @param string $default_text
* The optional label for the default bundle in the list.
*
* @return array
* An array of bundles, keyed by machine_name, with values being human
* readable names.
*/
public function getBundleOptions($default_text = NULL);
/**
* Makes the named bundle the current bundle.
*
* @param string $machine_name
* The name of a features bundle. If omitted, gets the last bundle from the
* Session.
*
* @return \Drupal\features\FeaturesBundleInterface
* A features bundle object.
*/
public function applyBundle($machine_name = NULL);
/**
* Renames a bundle.
*
* @param string $old_machine
* The old machine name of a bundle.
* @param string $new_machine
* The new machine name of a bundle.
*
* @return \Drupal\features\FeaturesBundleInterface
* A features bundle object.
*/
public function renameBundle($old_machine, $new_machine);
/**
* Loads a named bundle.
*
* @param string $bundle_name
* The name of a features bundle. If omitted, gets the last bundle from the
* Session.
*
* @return \Drupal\features\FeaturesBundleInterface
* A features bundle object.
*/
public function loadBundle($machine_name = NULL);
}