src/Budkit/Application/Support/Application.php
public function registerServices(array $services = [])
    {

        if (empty($services)) {
            $services = $this->paths['vendor'] . "/services.json";
            //If we can't load this file, throw and error;
            if (!$this->file->exists($services)) {
                return false; //could not
            }
            //decode;
            $services = json_decode($this->file->read($services), true);
        }

        //@TODO This should be moved to the provider handling class
        foreach ($services as $callable) {

            if (!class_exists($callable)) {
                throw new Exception("Could not locate the service provider {$callable}");

                return false;
            }
            //Create an instance of the callback
            $provider = $this->createInstance($callable, [$this]);

            //Check implements Service Interface;
            if (!($provider instanceof Service)) {
                throw new Exception("{$callable} Must implement the Service Interface");

                return false;
            }
            //var_dump($provider);
            //Attach the service provider;
            $this->observer->attach($provider);

        }
        //var_dump($this->observer);

        //Trigger the register event
        $this->observer->trigger(new Event("app.register", $this));

    }
public function registerServices(array $services = [])
    {

        if (empty($services)) {
            $services = $this->paths['vendor'] . "/services.json";
            //If we can't load this file, throw and error;
            if (!$this->file->exists($services)) {
                return false; //could not
            }
            //decode;
            $services = json_decode($this->file->read($services), true);
        }

        //@TODO This should be moved to the provider handling class
        foreach ($services as $callable) {

            if (!class_exists($callable)) {
                throw new Exception("Could not locate the service provider {$callable}");

                return false;
            }
            //Create an instance of the callback
            $provider = $this->createInstance($callable, [$this]);

            //Check implements Service Interface;
            if (!($provider instanceof Service)) {
                throw new Exception("{$callable} Must implement the Service Interface");

                return false;
            }
            //var_dump($provider);
            //Attach the service provider;
            $this->observer->attach($provider);

        }
        //var_dump($this->observer);

        //Trigger the register event
        $this->observer->trigger(new Event("app.register", $this));

    }
public function registerServices ( array $ services = [ ] ) { if ( empty ( $ services ) ) { $ services = $ this -> paths [ 'vendor' ] . "/services.json" ; //If we can't load this file, throw and error; if ( ! $ this -> file -> exists ( $ services ) ) { return false ; //could not } //decode; $ services = json_decode ( $ this -> file -> read ( $ services ) , true ) ; } //@TODO This should be moved to the provider handling class foreach ( $ services as $ callable ) { if ( ! class_exists ( $ callable ) ) { throw new Exception ( "Could not locate the service provider {$callable}" ) ; return false ; } //Create an instance of the callback $ provider = $ this -> createInstance ( $ callable , [ $ this ] ) ; //Check implements Service Interface; if ( ! ( $ provider instanceof Service ) ) { throw new Exception ( "{$callable} Must implement the Service Interface" ) ; return false ; } //var_dump($provider); //Attach the service provider; $ this -> observer -> attach ( $ provider ) ; } //var_dump($this->observer); //Trigger the register event $ this -> observer -> trigger ( new Event ( "app.register" , $ this ) ) ; }
Registers an array of services, to be initiated by the app.

- Triggers the `app.register` event

@param An array of $services e.g [ "Budkit\\Cms\\Provider", .. ]
@return False if the vendor/services.json file could not be loaded, or an Exception was thrown
@throws \Exception if a defined service is not callable, or if its not an instance of Service
Registers an array of services to be initiated by the app .