src/Core/Injector/Injector.php
public function load($config = array())
    {
        foreach ($config as $specId => $spec) {
            if (is_string($spec)) {
                $spec = array('class' => $spec);
            }

            $file = isset($spec['src']) ? $spec['src'] : null;

            // class is whatever's explicitly set,
            $class = isset($spec['class']) ? $spec['class'] : null;

            // or the specid if nothing else available.
            if (!$class && is_string($specId)) {
                $class = $specId;
            }

            // make sure the class is set...
            if (empty($class)) {
                throw new InvalidArgumentException('Missing spec class');
            }
            $spec['class'] = $class;

            $id = is_string($specId)
                ? $specId
                : (isset($spec['id']) ? $spec['id'] : $class);

            $priority = isset($spec['priority']) ? $spec['priority'] : 1;

            // see if we already have this defined. If so, check priority weighting
            if (isset($this->specs[$id]) && isset($this->specs[$id]['priority'])) {
                if ($this->specs[$id]['priority'] > $priority) {
                    return $this;
                }
            }

            // okay, actually include it now we know we're going to use it
            if (file_exists($file)) {
                require_once $file;
            }

            // make sure to set the id for later when instantiating
            // to ensure we get cached
            $spec['id'] = $id;

//          We've removed this check because new functionality means that the 'class' field doesn't need to refer
//          specifically to a class anymore - it could be a compound statement, ala SilverStripe's old Object::create
//          functionality
//
//          if (!class_exists($class)) {
//              throw new Exception("Failed to load '$class' from $file");
//          }

            // store the specs for now - we lazy load on demand later on.
            $this->specs[$id] = $spec;

            // EXCEPT when there's already an existing instance at this id.
            // if so, we need to instantiate and replace immediately
            if (isset($this->serviceCache[$id])) {
                $this->updateSpecConstructor($spec);
                $this->instantiate($spec, $id);
            }
        }

        return $this;
    }
public function load($config = array())
    {
        foreach ($config as $specId => $spec) {
            if (is_string($spec)) {
                $spec = array('class' => $spec);
            }

            $file = isset($spec['src']) ? $spec['src'] : null;

            // class is whatever's explicitly set,
            $class = isset($spec['class']) ? $spec['class'] : null;

            // or the specid if nothing else available.
            if (!$class && is_string($specId)) {
                $class = $specId;
            }

            // make sure the class is set...
            if (empty($class)) {
                throw new InvalidArgumentException('Missing spec class');
            }
            $spec['class'] = $class;

            $id = is_string($specId)
                ? $specId
                : (isset($spec['id']) ? $spec['id'] : $class);

            $priority = isset($spec['priority']) ? $spec['priority'] : 1;

            // see if we already have this defined. If so, check priority weighting
            if (isset($this->specs[$id]) && isset($this->specs[$id]['priority'])) {
                if ($this->specs[$id]['priority'] > $priority) {
                    return $this;
                }
            }

            // okay, actually include it now we know we're going to use it
            if (file_exists($file)) {
                require_once $file;
            }

            // make sure to set the id for later when instantiating
            // to ensure we get cached
            $spec['id'] = $id;

//          We've removed this check because new functionality means that the 'class' field doesn't need to refer
//          specifically to a class anymore - it could be a compound statement, ala SilverStripe's old Object::create
//          functionality
//
//          if (!class_exists($class)) {
//              throw new Exception("Failed to load '$class' from $file");
//          }

            // store the specs for now - we lazy load on demand later on.
            $this->specs[$id] = $spec;

            // EXCEPT when there's already an existing instance at this id.
            // if so, we need to instantiate and replace immediately
            if (isset($this->serviceCache[$id])) {
                $this->updateSpecConstructor($spec);
                $this->instantiate($spec, $id);
            }
        }

        return $this;
    }
public function load ( $ config = array ( ) ) { foreach ( $ config as $ specId => $ spec ) { if ( is_string ( $ spec ) ) { $ spec = array ( 'class' => $ spec ) ; } $ file = isset ( $ spec [ 'src' ] ) ? $ spec [ 'src' ] : null ; // class is whatever's explicitly set, $ class = isset ( $ spec [ 'class' ] ) ? $ spec [ 'class' ] : null ; // or the specid if nothing else available. if ( ! $ class && is_string ( $ specId ) ) { $ class = $ specId ; } // make sure the class is set... if ( empty ( $ class ) ) { throw new InvalidArgumentException ( 'Missing spec class' ) ; } $ spec [ 'class' ] = $ class ; $ id = is_string ( $ specId ) ? $ specId : ( isset ( $ spec [ 'id' ] ) ? $ spec [ 'id' ] : $ class ) ; $ priority = isset ( $ spec [ 'priority' ] ) ? $ spec [ 'priority' ] : 1 ; // see if we already have this defined. If so, check priority weighting if ( isset ( $ this -> specs [ $ id ] ) && isset ( $ this -> specs [ $ id ] [ 'priority' ] ) ) { if ( $ this -> specs [ $ id ] [ 'priority' ] > $ priority ) { return $ this ; } } // okay, actually include it now we know we're going to use it if ( file_exists ( $ file ) ) { require_once $ file ; } // make sure to set the id for later when instantiating // to ensure we get cached $ spec [ 'id' ] = $ id ; //          We've removed this check because new functionality means that the 'class' field doesn't need to refer //          specifically to a class anymore - it could be a compound statement, ala SilverStripe's old Object::create //          functionality // //          if (!class_exists($class)) { //              throw new Exception("Failed to load '$class' from $file"); //          } // store the specs for now - we lazy load on demand later on. $ this -> specs [ $ id ] = $ spec ; // EXCEPT when there's already an existing instance at this id. // if so, we need to instantiate and replace immediately if ( isset ( $ this -> serviceCache [ $ id ] ) ) { $ this -> updateSpecConstructor ( $ spec ) ; $ this -> instantiate ( $ spec , $ id ) ; } } return $ this ; }
Load services using the passed in configuration for those services

@param array $config
@return $this
Load services using the passed in configuration for those services