コード例 #1
0
ファイル: App.php プロジェクト: neatphp/neat
 /**
  * Retrieves the services.
  *
  * @param string $name
  *
  * @return Container|mixed
  */
 public function getServices($name = null)
 {
     if (!$this->services) {
         $path = $this->basedir . '/etc/config/services.php';
         $this->services = new Container(require $path);
         $this->services->set('app', $this);
         $this->services->set('Neat\\Loader\\ClassLoader', $this->getLoader());
     }
     return isset($name) ? $this->services->get($name) : $this->services;
 }
コード例 #2
0
ファイル: ContainerTest.php プロジェクト: neatphp/neat
 public function testSet_withExistingIdAndReadonly_throwsException()
 {
     $this->subject->get(Service1::class);
     $this->setExpectedException('Neat\\Container\\Exception\\ReadonlyException');
     $this->subject->set(Service1::class, Definition::object(Service2::class));
 }