1 | <?php |
||
19 | class CollectionManager extends TrackingManager |
||
20 | { |
||
21 | /** |
||
22 | * A copy of the collection definitions to be available for later usage. |
||
23 | * |
||
24 | * @var string[][] |
||
25 | */ |
||
26 | private $collectionDefinitions; |
||
27 | |||
28 | /** |
||
29 | * Get all of the ContentItems grouped by Collection name. |
||
30 | * |
||
31 | * @return ContentItem[][] |
||
32 | */ |
||
33 | 16 | public function &getCollections() |
|
37 | |||
38 | /** |
||
39 | * Get a ContentItem from a Collection pased on it's path. |
||
40 | * |
||
41 | * @param string $filePath |
||
42 | * |
||
43 | * @throws TrackedItemNotFoundException |
||
44 | * |
||
45 | * @return ContentItem |
||
46 | */ |
||
47 | 1 | public function &getContentItem($filePath) |
|
56 | |||
57 | /** |
||
58 | * A jailed representation of CollectionManager::getCollections(). |
||
59 | * |
||
60 | * @return JailedDocument[][] |
||
|
|||
61 | */ |
||
62 | 19 | public function getJailedCollections() |
|
66 | |||
67 | /** |
||
68 | * Parse every collection and store them in the manager. |
||
69 | * |
||
70 | * @param string[][] $collections An array of definitions for collections |
||
71 | */ |
||
72 | 37 | public function parseCollections($collections) |
|
73 | { |
||
74 | 37 | if ($collections === null) |
|
75 | { |
||
76 | $this->output->debug('No collections found, nothing to parse.'); |
||
77 | |||
78 | return; |
||
79 | } |
||
80 | |||
81 | 37 | $this->collectionDefinitions = $collections; |
|
82 | |||
83 | /** |
||
84 | * The information which each collection has taken from the configuration file. |
||
85 | * |
||
86 | * $collection['name'] string The name of the collection |
||
87 | * ['folder'] string The folder where this collection has its ContentItems |
||
88 | * |
||
89 | * @var array |
||
90 | */ |
||
91 | 37 | foreach ($collections as $collection) |
|
92 | { |
||
93 | 37 | $this->output->notice("Loading '{$collection['name']}' collection..."); |
|
94 | |||
95 | 37 | $collectionFolder = $this->fs->absolutePath($collection['folder']); |
|
96 | |||
97 | 37 | if (!$this->fs->exists($collectionFolder)) |
|
98 | { |
||
99 | $this->output->warning("The folder '{$collection['folder']}' could not be found for the '{$collection['name']}' collection"); |
||
100 | continue; |
||
101 | } |
||
102 | |||
103 | 37 | $this->saveFolderDefinition($collection['folder'], $collection); |
|
104 | 37 | $this->scanTrackableItems($collectionFolder, array( |
|
105 | 37 | 'namespace' => $collection['name'], |
|
106 | )); |
||
107 | } |
||
108 | 37 | } |
|
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function createNewItem($filePath) |
||
114 | { |
||
115 | $collection = $this->getTentativeCollectionName($filePath); |
||
116 | |||
117 | return $this->handleTrackableItem($filePath, array( |
||
118 | 'namespace' => $collection, |
||
119 | )); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | public function refreshItem($filePath) |
||
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | 37 | protected function handleTrackableItem($filePath, $options = array()) |
|
149 | |||
150 | /** |
||
151 | * Get the name of the Collection this Content Item belongs to. |
||
152 | * |
||
153 | * @param string $filePath |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | private function getTentativeCollectionName($filePath) |
||
169 | } |
||
170 |
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.