Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • DelegatingLoader
  • FileLoader
  • Loader
  • LoaderResolver

Interfaces

  • LoaderInterface
  • LoaderResolverInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: /*
 4:  * This file is part of the Symfony package.
 5:  *
 6:  * (c) Fabien Potencier <fabien@symfony.com>
 7:  *
 8:  * For the full copyright and license information, please view the LICENSE
 9:  * file that was distributed with this source code.
10:  */
11: 
12: namespace Symfony\Component\Config\Loader;
13: 
14: use Symfony\Component\Config\Exception\FileLoaderLoadException;
15: 
16: /**
17:  * Loader is the abstract class used by all built-in loaders.
18:  *
19:  * @author Fabien Potencier <fabien@symfony.com>
20:  */
21: abstract class Loader implements LoaderInterface
22: {
23:     protected $resolver;
24: 
25:     /**
26:      * Gets the loader resolver.
27:      *
28:      * @return LoaderResolverInterface A LoaderResolverInterface instance
29:      */
30:     public function getResolver()
31:     {
32:         return $this->resolver;
33:     }
34: 
35:     /**
36:      * Sets the loader resolver.
37:      *
38:      * @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
39:      */
40:     public function setResolver(LoaderResolverInterface $resolver)
41:     {
42:         $this->resolver = $resolver;
43:     }
44: 
45:     /**
46:      * Imports a resource.
47:      *
48:      * @param mixed  $resource A Resource
49:      * @param string $type     The resource type
50:      *
51:      * @return mixed
52:      */
53:     public function import($resource, $type = null)
54:     {
55:         return $this->resolve($resource)->load($resource, $type);
56:     }
57: 
58:     /**
59:      * Finds a loader able to load an imported resource.
60:      *
61:      * @param mixed  $resource A Resource
62:      * @param string $type     The resource type
63:      *
64:      * @return LoaderInterface A LoaderInterface instance
65:      *
66:      * @throws FileLoaderLoadException if no loader is found
67:      */
68:     public function resolve($resource, $type = null)
69:     {
70:         if ($this->supports($resource, $type)) {
71:             return $this;
72:         }
73: 
74:         $loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type);
75: 
76:         if (false === $loader) {
77:             throw new FileLoaderLoadException($resource);
78:         }
79: 
80:         return $loader;
81:     }
82: }
83: 
php-coveralls API documentation generated by ApiGen 2.8.0