} /* * Put Doozr (Middleware) on stack for processing */ /** * Fill queue for running "Doozr" middleware * * @param \Psr\Http\Message\ServerRequestInterface $request Request (PSR) to process * @param \Psr\Http\Message\ResponseInterface $response Response (PSR) to use * @param callable $next Next middleware in stack * * @return \Psr\Http\Message\ResponseInterface A PSR compatible response */ $queue[] = function (Request $request, Response $response, callable $next) { // Boot the App kernel $app = Doozr_Kernel_App::boot(DOOZR_APP_ENVIRONMENT, DOOZR_RUNTIME_ENVIRONMENT, DOOZR_UNIX, DOOZR_DEBUGGING, DOOZR_CACHING, DOOZR_CACHING_CONTAINER, DOOZR_LOGGING, DOOZR_PROFILING, DOOZR_APP_ROOT, DOOZR_APP_NAMESPACE, DOOZR_DIRECTORY_TEMP, DOOZR_DOCUMENT_ROOT, DOOZR_NAMESPACE, DOOZR_NAMESPACE_FLAT); // Invoke Middleware return $app($request, $response, $next); }; /* * Execute the configured stack by running it via \Relay\Runner() */ // Create a Relay Runner instance ... $runner = new Runner($queue); // ... and run it with the queue defined above $response = $runner(new \Doozr_Request_Web(new \Doozr_Request_State()), new \Doozr_Response_Web(new \Doozr_Response_State())); /* * Send the response as Web response (PSR) */ // After running the whole queue send the response (HTTP way) $responseSender = new Doozr_Response_Sender_Web($response);
/** * Prepares setup for Tests. * * @author Benjamin Carl <*****@*****.**> */ protected function setUp() { /* @var $app Doozr_Kernel_App Get kernel instance */ self::$kernel = Doozr_Kernel_App::boot(DOOZR_APP_ENVIRONMENT, DOOZR_RUNTIME_ENVIRONMENT, DOOZR_UNIX, DOOZR_DEBUGGING, DOOZR_CACHING, DOOZR_CACHING_CONTAINER, DOOZR_LOGGING, DOOZR_PROFILING, DOOZR_APP_ROOT, DOOZR_DIRECTORY_TEMP, DOOZR_DOCUMENT_ROOT, DOOZR_NAMESPACE, DOOZR_NAMESPACE_FLAT); // Store className self::$serviceClassName = 'Doozr_' . self::$serviceName . '_Service'; // Get registry self::$registry = Doozr_Registry::getInstance(); // Load service self::$service = Doozr_Loader_Serviceloader::load(self::$serviceName); }
/** * Purges content from cache. * * @param array $scopes The scope to purge content for. * @param array $argumentBag The arguments bag * * @author Benjamin Carl <*****@*****.**> * @return int The number of elements purged * @access protected * @throws Doozr_Exception */ protected function purge(array $scopes = [self::SCOPE_EVERYTHING], array $argumentBag = []) { $result = 0; // Iterate the scopes passed ... foreach ($scopes as $scope) { // Build scope for cache if (false === in_array($scope, $this->validScopes)) { throw new Doozr_Exception(sprintf('Scope %s not allowed!', $scope)); } // Check for multi scope if (self::SCOPE_EVERYTHING === $scope) { $scope = $this->validScopes; array_shift($scope); } else { $scope = [$scope]; } $app = Doozr_Kernel_App::boot(DOOZR_APP_ENVIRONMENT, DOOZR_RUNTIME_ENVIRONMENT, DOOZR_UNIX, DOOZR_DEBUGGING, DOOZR_CACHING, DOOZR_CACHING_CONTAINER, DOOZR_LOGGING, DOOZR_PROFILING, DOOZR_APP_ROOT, DOOZR_APP_NAMESPACE, DOOZR_DIRECTORY_TEMP, DOOZR_DOCUMENT_ROOT, DOOZR_NAMESPACE, DOOZR_NAMESPACE_FLAT); // Scope foreach ($scope as $singleScope) { /* @var Doozr_Cache_Service $cache */ $cache = Doozr_Loader_Serviceloader::load('cache', DOOZR_CACHING_CONTAINER, $singleScope, [], DOOZR_UNIX, DOOZR_CACHING); // We can purge simply everything from passed scope! try { $result += $cache->garbageCollection($singleScope, -1, true); } catch (Exception $exception) { break; } } } return $result; }
/** * Test: Bootstrap Doozr. * * @author Benjamin Carl <*****@*****.**> * @return void * @access protected */ public function testInit() { /* @var $app Doozr_Kernel_App Get kernel instance */ $app = Doozr_Kernel_App::boot(DOOZR_APP_ENVIRONMENT, DOOZR_RUNTIME_ENVIRONMENT, DOOZR_UNIX, DOOZR_DEBUGGING, DOOZR_CACHING, DOOZR_CACHING_CONTAINER, DOOZR_LOGGING, DOOZR_PROFILING, DOOZR_APP_ROOT, DOOZR_APP_NAMESPACE, DOOZR_DIRECTORY_TEMP, DOOZR_DOCUMENT_ROOT, DOOZR_NAMESPACE, DOOZR_NAMESPACE_FLAT); $this->assertInstanceOf('Doozr_Kernel', $app); }