/** * @param DI $DI */ function __construct(DI $DI) { $this->Modules = $DI->get('\\arh\\library\\Modules'); $this->Settings = $DI->get('\\arh\\library\\Settings'); $this->Access = $DI->get('\\arh\\library\\Access'); $this->Exception = $DI->get('\\arh\\library\\Exception'); }
/** * @param DI $DI */ function __construct(DI $DI) { $this->ROOT_DIR = $DI->get('ROOT_DIR'); $this->Modules = $DI->get('\\library\\Modules'); $this->Config = $DI->get('\\library\\Config'); $this->Access = $DI->get('\\library\\Access'); $this->Exception = $DI->get('\\library\\Exception'); }
/** * @param DI $DI */ function __construct(DI $DI) { $this->ROOT_DIR = $DI->get('ROOT_DIR'); $this->Exception = $DI->get('\\library\\Exception'); $this->configDir = $this->ROOT_DIR . '/' . $this->configDir; $this->modulesDir = $this->ROOT_DIR . '/' . $this->modulesDir; self::$modules = $this->getAll(); self::$current = $this->getInfo('arh'); }
public function __construct($file) { $config = DI::get('config'); $logDir = $config->dir->log; $this->file = $logDir . $file; $this->fp = fopen($this->file, 'a+'); }
/** * Redirects to another page. * * @param string $location The path to redirect to * @param int $status Status code to use * @return bool False if $location is not set */ public static function redirect($location, $status = 302) { $request = DI::get('request'); if ($location == '') { header("Location: " . $request->get_uri('site_url'), true, $status); exit; } header("Location: " . $request->get_uri('site_url') . $location, true, $status); exit; }
/** * get a service from the di * @param $what * @return mixed the service object */ public function get($what) { if (!$this->registered($what)) { $file = $this->directory . "/{$what}.php"; $service = (include $file); if (!is_callable($service)) { throw new Exception(sprintf('Bad service type. The file%s should return a callable', $file)); } $this->set($what, $service); } return parent::get($what); }
public function testService() { $di = new DI(); $di->setService('fake_service', 'OU\\UniqidService'); $this->assertNotEquals($di->get('fake_service'), $di->get('fake_service')); }
public function call() { return $this->container->get('translation')->__get($this->argument); }
protected function getPayloadSaver() { return DI::get('payload.saver', new PayloadSaver()); }
* @param [type] $offset [description] * @param [type] $value [description] * @return [type] [description] */ public function offsetSet($offset, $value) { return self::set($offset, $value); } /** * ArrayAccess接口,以unset($di[$name])方式卸载服务 * @param [type] $offset [description] * @return [type] [description] */ public function offsetUnset($offset) { return self::remove($offset); } } class A { public function abc() { echo 'a'; } } $di = new DI(); $di->set('B', function () { return new A(); }); var_dump($di->get('B'));
public function call() { return $this->container->get('translation')->getLang(); }
/** * @param DI $DI */ function __construct(DI $DI) { $this->Exception = $DI->get('\\arh\\library\\Exception'); self::$modules = $this->getAll(); self::$current = $this->getInfo('arh'); }
/** * @param DI $DI */ function __construct(DI $DI) { $this->Exception = $DI->get('\\library\\Exception'); }
/** * Tests the exception is thrown when we ask for a service that has not * been registered. * @expectedException \Exception * @expectedExceptionMessage No element registered for key: TestElement */ public function testMissingServiceThrowsException() { $di = new DI(); $di->get('TestElement'); }
public function call() { $request = $this->container->get('request'); $address = sprintf("%s://%s%s", $request->getScheme(), $request->getHttpHost(), $this->argument); return file_get_contents($address); }