1 | <?php |
||
15 | abstract class RepositoryExecutor extends AbstractExecutor implements LanguageAwareInterface |
||
16 | { |
||
17 | /** |
||
18 | * Constant defining the default language code |
||
19 | */ |
||
20 | const DEFAULT_LANGUAGE_CODE = 'eng-GB'; |
||
21 | |||
22 | /** |
||
23 | * Constant defining the default Admin user ID. |
||
24 | * |
||
25 | * @todo inject via config parameter |
||
26 | */ |
||
27 | const ADMIN_USER_ID = 14; |
||
28 | |||
29 | /** @todo inject via config parameter */ |
||
30 | const USER_CONTENT_TYPE = 'user'; |
||
31 | |||
32 | /** |
||
33 | * @var array $dsl The parsed DSL instruction array |
||
34 | */ |
||
35 | protected $dsl; |
||
36 | |||
37 | /** @var array $context The context (configuration) for the execution of the current step */ |
||
38 | protected $context; |
||
39 | |||
40 | /** |
||
41 | * The eZ Publish 5 API repository. |
||
42 | * |
||
43 | * @var \eZ\Publish\API\Repository\Repository |
||
44 | */ |
||
45 | protected $repository; |
||
46 | |||
47 | /** |
||
48 | * Language code for current step. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | private $languageCode; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | private $defaultLanguageCode; |
||
58 | |||
59 | /** |
||
60 | * The bundle object representing the bundle the currently processed migration is in. |
||
61 | * |
||
62 | * @var BundleInterface |
||
63 | */ |
||
64 | protected $bundle; |
||
65 | |||
66 | /** @var ReferenceResolverInterface $referenceResolver */ |
||
67 | protected $referenceResolver; |
||
68 | |||
69 | // to redefine in subclasses if they don't support all methods, or if they support more... |
||
70 | protected $supportedActions = array( |
||
71 | 'create', 'update', 'delete' |
||
72 | ); |
||
73 | |||
74 | public function setRepository(Repository $repository) |
||
78 | |||
79 | public function setReferenceResolver(ReferenceResolverInterface $referenceResolver) |
||
83 | |||
84 | public function execute(MigrationStep $step) |
||
122 | |||
123 | /** |
||
124 | * Method that each executor (subclass) has to implement. |
||
125 | * |
||
126 | * It is used to set references based on the DSL instructions executed in the current step, for later steps to reuse. |
||
127 | * |
||
128 | * @throws \InvalidArgumentException when trying to set a reference to an unsupported attribute. |
||
129 | * @param $object |
||
130 | * @return boolean |
||
131 | */ |
||
132 | abstract protected function setReferences($object); |
||
133 | |||
134 | /** |
||
135 | * Helper method to log in a user that can make changes to the system. |
||
136 | * @param int $userId |
||
137 | * @return int id of the previously logged in user |
||
138 | */ |
||
139 | protected function loginUser($userId) |
||
149 | |||
150 | public function setLanguageCode($languageCode) |
||
154 | |||
155 | public function getLanguageCode() |
||
159 | |||
160 | public function setDefaultLanguageCode($languageCode) |
||
164 | |||
165 | public function getDefaultLanguageCode() |
||
169 | } |
||
170 |