/** * Resolves item from the container using overloading. * * @access public * @param string $key Key * @return mixed */ public function __get($key) { if (!isset($this->resolved[$key])) { if (!$this->container->has($key)) { throw new RuntimeException(vsprintf("%s::%s(): Unable to resolve [ %s ].", [__TRAIT__, __FUNCTION__, $key])); } $this->resolved[$key] = $this->container->get($key); } return $this->resolved[$key]; }
/** * Boots the package. * * @access public */ public function boot() { // Register configuration namespace $this->container->get('config')->registerNamespace($this->getFileNamespace(), $this->getConfigPath()); // Register i18n namespace if (($path = $this->getI18nPath()) !== false && $this->container->has('i18n')) { $this->container->get('i18n')->getLoader()->registerNamespace($this->getFileNamespace(), $path); } // Register view namespace if (($path = $this->getViewPath()) !== false && $this->container->has('view')) { $this->container->get('view')->registerNamespace($this->getFileNamespace(), $path); } // Bootstrap package $this->bootstrap(); }
/** * */ public function testHas() { $container = new Container(); $container->register(['mako\\tests\\unit\\syringe\\Foo', 'foo'], 'mako\\tests\\unit\\syringe\\Foo'); $this->assertTrue($container->has('mako\\tests\\unit\\syringe\\Foo')); $this->assertTrue($container->has('foo')); $this->assertFalse($container->has('mako\\tests\\unit\\syringe\\Bar')); $this->assertFalse($container->has('bar')); }