Pressbooks\Container::init PHP Method

init() static public method

If you add services, don't forget to also edit config/.phpstorm.meta.php
static public init ( Pimple\Container $pimple = null )
$pimple Pimple\Container
    static function init($pimple = null)
    {
        if (null === $pimple) {
            static::$pimple = (require __DIR__ . '/../services.php');
        } else {
            static::$pimple = $pimple;
        }
    }

Usage Example

Example #1
0
 /**
  * @covers \Pressbooks\Container::get
  * @covers \Pressbooks\Container::set
  */
 public function test_getSet()
 {
     Container::init(new FakePimpleContainer());
     Container::set('test1', function () {
         return 'test1';
     });
     Container::set('test2', function () {
         return 'test2';
     }, 'factory');
     Container::set('test3', function () {
         return 'test3';
     }, 'protect');
     $var1 = Container::get('test1');
     $var2 = Container::get('test2');
     $var3 = Container::get('test3');
     $this->assertTrue('test1' == $var1);
     $this->assertTrue('test2' == $var2);
     $this->assertTrue(is_object($var3) && $var3 instanceof Closure);
     $this->assertTrue('test3' == $var3());
 }
All Usage Examples Of Pressbooks\Container::init