@@ 175-188 (lines=14) @@ | ||
172 | * @return OpenGraphGeneratorBuilder |
|
173 | * @throws \InvalidArgumentException |
|
174 | */ |
|
175 | public function addMetadataDir($dir, $namespacePrefix = '') |
|
176 | { |
|
177 | if (!is_dir($dir)) { |
|
178 | throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
|
179 | } |
|
180 | ||
181 | if (isset($this->metadataDirectories[$namespacePrefix])) { |
|
182 | throw new \InvalidArgumentException(sprintf('There is already a directory configured for the namespace prefix "%s". Please use replaceMetadataDir() to override directories.', $namespacePrefix)); |
|
183 | } |
|
184 | ||
185 | $this->metadataDirectories[$namespacePrefix] = $dir; |
|
186 | ||
187 | return $this; |
|
188 | } |
|
189 | ||
190 | /** |
|
191 | * Adds a map of namespace prefixes to directories. |
|
@@ 213-226 (lines=14) @@ | ||
210 | * @return OpenGraphGeneratorBuilder |
|
211 | * @throws \InvalidArgumentException |
|
212 | */ |
|
213 | public function replaceMetadataDir($dir, $namespacePrefix = '') |
|
214 | { |
|
215 | if (!is_dir($dir)) { |
|
216 | throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
|
217 | } |
|
218 | ||
219 | if (!isset($this->metadataDirectories[$namespacePrefix])) { |
|
220 | throw new \InvalidArgumentException(sprintf('There is no directory configured for namespace prefix "%s". Please use addMetadataDir() for adding new directories.', $namespacePrefix)); |
|
221 | } |
|
222 | ||
223 | $this->metadataDirectories[$namespacePrefix] = $dir; |
|
224 | ||
225 | return $this; |
|
226 | } |
|
227 | ||
228 | /** |
|
229 | * Create directory |