Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\DependencyInjection\Loader; Chris@0: Chris@0: use Symfony\Component\Config\Resource\FileResource; Chris@0: Chris@0: /** Chris@0: * PhpFileLoader loads service definitions from a PHP file. Chris@0: * Chris@0: * The PHP file is required and the $container variable can be Chris@0: * used within the file to change the container. Chris@0: * Chris@0: * @author Fabien Potencier Chris@0: */ Chris@0: class PhpFileLoader extends FileLoader Chris@0: { Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function load($resource, $type = null) Chris@0: { Chris@0: // the container and loader variables are exposed to the included file below Chris@0: $container = $this->container; Chris@0: $loader = $this; Chris@0: Chris@0: $path = $this->locator->locate($resource); Chris@0: $this->setCurrentDir(dirname($path)); Chris@0: $this->container->addResource(new FileResource($path)); Chris@0: Chris@0: include $path; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function supports($resource, $type = null) Chris@0: { Chris@0: return is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION); Chris@0: } Chris@0: }