コード例 #1
0
ファイル: TierHTTPApp.php プロジェクト: atawsports2/Tier
 /**
  * @param InjectionParams $injectionParams
  * @param Injector $injector
  * @param ExceptionResolver $exceptionResolver
  */
 public function __construct(InjectionParams $injectionParams, Injector $injector = null, ExceptionResolver $exceptionResolver = null)
 {
     parent::__construct($injectionParams, $injector);
     if ($exceptionResolver === null) {
         $exceptionResolver = $this->createStandardExceptionResolver();
     }
     $this->exceptionResolver = $exceptionResolver;
 }
コード例 #2
0
ファイル: TierAppTest.php プロジェクト: danack/tier
 public function testReturnInjectionParams()
 {
     $tierApp = new TierApp(new Injector(), new NullCallback());
     $addInjectionParamsFn = function () {
         $injectionParams = new InjectionParams();
         $injectionParams->alias('Fixtures\\FooInterface', 'Fixtures\\FooImplementation');
         return $injectionParams;
     };
     // When tier tries to instantiate this, it will fail if the alias
     // hasn't been added.
     $requiresInterfaceFn = function (\Fixtures\FooInterface $foo) {
         return TierApp::PROCESS_END;
     };
     $tierApp->addExecutable(10, $addInjectionParamsFn);
     $tierApp->addExecutable(20, $requiresInterfaceFn);
     $tierApp->executeInternal();
 }
コード例 #3
0
ファイル: JigFastRouterTest.php プロジェクト: danack/tier
 public function testRouting405()
 {
     $request = new CLIRequest("/introduction", 'example.com', 'POST');
     $this->injector->alias('Psr\\Http\\Message\\ServerRequestInterface', get_class($request));
     $this->injector->share($request);
     $renderCallable = $this->injector->execute('Tier\\Bridge\\JigFastRouter::routeRequest');
     $body = TierApp::executeExecutable($renderCallable, $this->injector);
     $this->assertInstanceOf('Room11\\HTTP\\Body\\TextBody', $body);
     /** @var $body \Room11\HTTP\Body\HtmlBody */
     $html = $body->getData();
     $this->assertContains("Method not allowed for route.", $html);
     $this->assertEquals(405, $body->getStatusCode());
 }
コード例 #4
0
ファイル: FastRouterTest.php プロジェクト: danack/tier
 public function testRouting405()
 {
     $request = new CLIRequest("/introduction", 'example.com', 'POST');
     $this->injector->alias('Psr\\Http\\Message\\ServerRequestInterface', get_class($request));
     $this->injector->share($request);
     $router = $this->injector->make('Tier\\Bridge\\FastRouter');
     $fn404ErrorPage = function () {
         return new TextBody("Route not found.", 404);
     };
     $fn405ErrorPage = function () {
         return new TextBody("Method not allowed for route.", 405);
     };
     $result = $router->routeRequest($request, $fn404ErrorPage, $fn405ErrorPage);
     $body = TierApp::executeExecutable($result, $this->injector);
     $this->assertInstanceOf('Room11\\HTTP\\Body\\TextBody', $body);
     /** @var $body \Room11\HTTP\Body\HtmlBody */
     $html = $body->getData();
     $this->assertContains("Method not allowed for route.", $html);
     $this->assertEquals(405, $body->getStatusCode());
 }
コード例 #5
0
ファイル: TierHTTPApp.php プロジェクト: danack/tier
 /**
  * @param Injector $injector
  * @param ExceptionResolver $exceptionResolver
  */
 public function __construct(Injector $injector, ExceptionResolver $exceptionResolver = null)
 {
     parent::__construct($injector, new MaxLoopCallback());
 }
コード例 #6
0
ファイル: index.php プロジェクト: finelinePG/imagick
<?php

ini_set('display_errors', 'off');
define('COMPOSER_OPCACHE_OPTIMIZE', true);
use Tier\Tier;
use Tier\TierApp;
require_once realpath(__DIR__) . '/../vendor/autoload.php';
// Contains helper functions for the 'framework'.
require __DIR__ . "/../vendor/danack/tier/src/Tier/tierFunctions.php";
// Contains helper functions for the application.
require_once "appFunctions.php";
\Tier\setupErrorHandlers();
require __DIR__ . "/../vendor/intahwebz/core/src/Intahwebz/Functions.php";
// Read application config params
$injectionParams = (require_once "injectionParams.php");
$request = \Tier\createRequestFromGlobals();
// Create the first Tier that needs to be run.
$tier = new Tier('routeRequest');
// Create the Tier application
$app = new TierApp($tier, $injectionParams);
$app->setStandardExceptionHandlers();
$app->addPreCallable(['ImagickDemo\\AppTimer', 'timerStart']);
$app->addPostCallable(['ImagickDemo\\AppTimer', 'timerEnd']);
// Run it
$app->execute($request);
コード例 #7
0
ファイル: process.php プロジェクト: biswajit-paul/gittest
error_reporting(E_ALL);
$injectionParams = (require "injectionParams.php");
try {
    $_input = empty($_SERVER['CONTENT-LENGTH']) ? null : fopen('php://input', 'r');
    $request = new Request($_SERVER, $_GET, $_POST, $_FILES, $_COOKIE, $_input);
} catch (\Exception $e) {
    //TODO - exit quickly.
    header("We totally failed", true, 501);
    echo "we ded " . $e->getMessage();
    exit(0);
}
try {
    // Create the first Tier that needs to be run.
    $tier = new Tier('routeRequest');
    // Create the Tier application
    $app = new TierApp($tier, $injectionParams);
    $app->addPreCallable(['ImagickDemo\\AppTimer', 'timerStart']);
    $app->addPostCallable(['ImagickDemo\\AppTimer', 'timerEnd']);
    // Run it
    $app->execute($request);
} catch (InjectionException $ie) {
    // TODO - add custom notifications.
    $bodyText = "InjectionException: " . $ie->getMessage();
    $bodyText .= "<br/>Dependency chain is:<br/>";
    $bodyText .= "<ul>";
    foreach ($ie->getDependencyChain() as $dependency) {
        $bodyText .= "<li>";
        $bodyText .= $dependency;
        $bodyText .= "</li>";
    }
    $bodyText .= "</ul>";
コード例 #8
0
ファイル: TierCLIApp.php プロジェクト: danack/tier
 /**
  * @param \AurynConfig\InjectionParams $injectionParams
  * @param Injector $injector
  */
 public function __construct(Injector $injector)
 {
     parent::__construct($injector, new NullCallback());
 }
コード例 #9
0
ファイル: TierAppTest.php プロジェクト: Zvax/Tier
 public function testReturnArrayError()
 {
     $injectionParams = new InjectionParams();
     $tierApp = new TierApp($injectionParams);
     $fn1 = function () {
         $executables = [];
         $executables[] = "This is not an execuable";
         return $executables;
     };
     $fnEnd = function () {
         return TierApp::PROCESS_END;
     };
     $tierApp->addExecutable(0, $fn1);
     $tierApp->addExecutable(10, $fnEnd);
     $this->setExpectedException('Tier\\InvalidReturnException');
     $tierApp->executeInternal();
 }
コード例 #10
0
ファイル: TierAppTest.php プロジェクト: atawsports2/Tier
 public function testDuplicateExpectedProduct()
 {
     $injectionParams = new InjectionParams();
     $tierApp = new TierApp($injectionParams);
     $tierApp->addExpectedProduct('StdClass');
     $this->setExpectedException('Tier\\TierException');
     $tierApp->addExpectedProduct('StdClass');
 }