コード例 #1
0
ファイル: TestCase.php プロジェクト: liftkit/liftkit
 protected function initializeModule()
 {
     $app = new App($this->container);
     $app->initialize();
     $scriptLoader = $this->container->getObject('App.TestScriptLoader');
     $scriptLoader->load('dependency-injection/utility', ['container' => $this->container]);
     return $app;
 }
コード例 #2
0
 /**
  * @group current
  */
 public function testWithOptionalParams()
 {
     $this->container->bindRuleToClass('F', ClassF::class);
     $object = $this->container->getObject('F');
     $this->assertSame(ClassA::class, get_class($object->getA()));
     $this->assertEquals(true, $object->getParam());
     $object = $this->container->getObject('F', [false]);
     $this->assertSame(ClassA::class, get_class($object->getA()));
     $this->assertEquals(false, $object->getParam());
 }
コード例 #3
0
ファイル: bootstrap.php プロジェクト: liftkit/liftkit
<?php

require_once __DIR__ . '/vendor/autoload.php';
use LiftKit\DependencyInjection\Container\Container;
use LiftKit\Router\Exception\NoMatchingRoute as RouteException;
// Initialize Container
$container = new Container();
require __DIR__ . '/config/dependency-injection/default.php';
// Initialize Module
$appModule = $container->getObject('App.Module');
$appModule->initialize();
$application = $container->getObject('App.Application');
$request = $container->getObject('App.Request');
// Route Request
try {
    $appModule->execute($request)->render();
} catch (RouteException $e) {
    $application->triggerHook('404')->render();
} catch (Exception $e) {
    $application->triggerHook('500')->render();
}