| 1 | <?php |
||
| 20 | class PhpFileLoader extends FileLoader |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Loads a PHP file. |
||
| 24 | * |
||
| 25 | * @param mixed $file The resource |
||
| 26 | * @param string $type The resource type |
||
| 27 | * |
||
| 28 | * @throws \InvalidArgumentException |
||
| 29 | * |
||
| 30 | * @return array Array with configuration |
||
| 31 | */ |
||
| 32 | public function load($file, $type = null) |
||
| 33 | { |
||
| 34 | $path = $this->locator->locate($file); |
||
| 35 | $this->setCurrentDir(dirname($path)); |
||
| 36 | |||
| 37 | $config = require $path; |
||
| 38 | |||
| 39 | // not an array |
||
| 40 | if (!is_array($config)) { |
||
| 41 | throw new \InvalidArgumentException(sprintf('The file "%s" must contain a PHP array.', $path)); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $config; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Returns true if this class supports the given resource. |
||
| 49 | * |
||
| 50 | * @param mixed $resource A resource |
||
| 51 | * @param string $type The resource type |
||
| 52 | * |
||
| 53 | * @return bool true if this class supports the given resource, false otherwise |
||
| 54 | */ |
||
| 55 | public function supports($resource, $type = null) |
||
| 59 | } |
||
| 60 |