1 | <?php |
||
13 | class SkeletonProvider extends AbstractProvider |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * Registers services on the given app. |
||
18 | * |
||
19 | * @param Application $app An Application instance |
||
20 | */ |
||
21 | public function register(Application $app) |
||
22 | { |
||
23 | $app['skeleton'] = $this; |
||
24 | $this->app = $app; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param \ArrayObject $project The project |
||
29 | * @param AbstractSkeleton $skeleton The skeleton |
||
30 | * @return bool |
||
31 | */ |
||
32 | public function hasSkeleton(\ArrayObject $project, AbstractSkeleton $skeleton) |
||
33 | { |
||
34 | return isset($project["skeletons"]) && array_key_exists($skeleton->getName(), $project["skeletons"]); |
||
35 | } |
||
36 | |||
37 | |||
38 | /** |
||
39 | * @param \ArrayObject $project The project |
||
40 | * @param AbstractSkeleton $skeleton The skeleton |
||
41 | */ |
||
42 | public function applySkeleton(\ArrayObject $project, AbstractSkeleton $skeleton) |
||
43 | { |
||
44 | $dependencies = new DependencySolver(); |
||
45 | $this->resolveDependencies($skeleton, $dependencies); |
||
46 | foreach ($dependencies->getLoadOrder() as $theSkeletonName) { |
||
47 | $theSkeleton = $this->findSkeleton($theSkeletonName); |
||
48 | if (!$this->hasSkeleton($project, $theSkeleton)) { |
||
49 | $this->dialogProvider->logTask("Running skeleton create for " . $theSkeleton->getName()); |
||
50 | $theSkeleton->create($project); |
||
51 | $project["skeletons"][$theSkeleton->getName()] = $theSkeleton->getName(); |
||
52 | } |
||
53 | } |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param AbstractSkeleton $theSkeleton |
||
58 | * @param \Kunstmaan\Skylab\Utility\DependencySolver $dependencies |
||
59 | * @return \ArrayObject |
||
|
|||
60 | */ |
||
61 | private function resolveDependencies(AbstractSkeleton $theSkeleton, DependencySolver $dependencies) |
||
74 | |||
75 | /** |
||
76 | * @param string $skeletonname |
||
77 | * @return AbstractSkeleton |
||
78 | * @throws \RuntimeException |
||
79 | */ |
||
80 | public function findSkeleton($skeletonname) |
||
92 | |||
93 | /** |
||
94 | * @return void |
||
95 | */ |
||
96 | public function listSkeletons() |
||
102 | |||
103 | /** |
||
104 | * @return array |
||
105 | */ |
||
106 | public function getSkeletons() |
||
114 | |||
115 | /** |
||
116 | * @param \Closure $callback |
||
117 | * @param \ArrayObject $skeletons |
||
118 | */ |
||
119 | public function skeletonLoop($callback, \ArrayObject $skeletons = null) |
||
138 | |||
139 | } |
||
140 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.