Example #1
0
 /**
  * {@inheritDoc}
  */
 public function register(HttpKernelInterface $app = null, $name = '', array $parameters = array())
 {
     $lastServiceName = call_user_func('end', array_keys($this->services));
     $lastFactoryName = array_pop($this->services);
     $builder = new \Stack\Builder();
     $container = $this->container;
     foreach ($this->services as $serviceName => $serviceParameters) {
         $factory = $this->getFactory($serviceName);
         $configuration = $this->getConfiguration($serviceName, $parameters);
         $builder->push(function ($app) use($container, $factory, $serviceName, $configuration) {
             list($stackName, $stack) = $factory->register($app, $serviceName, $configuration);
             return $stack;
         });
     }
     $factory = $this->getFactory($lastServiceName);
     $configuration = $this->getConfiguration($lastServiceName, $parameters);
     list($stackName, $stack) = $factory->register($app, $lastServiceName, $configuration);
     //Register stack in container @TODO
     //$container->bind($stackName, $stack);
     $stackResolved = $builder->resolve($stack);
     return array($name, $stackResolved);
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function register(HttpKernelInterface $app = null, $name = '', array $parameters = array())
 {
     $lastServiceName = call_user_func('end', array_keys($this->services));
     $builder = new \Stack\Builder();
     $container = $this->container;
     foreach ($this->services as $serviceName => $serviceParameters) {
         $originalServiceName = $serviceName;
         if (preg_match('`^(.*)\\[.+$`i', $serviceName, $matches)) {
             $serviceName = $matches[1];
         }
         $factory = $this->getFactory($serviceName);
         $configuration = $this->getConfiguration($originalServiceName, $parameters);
         $builder->push(function ($app) use($container, $factory, $serviceName, $configuration) {
             list($stackName, $stack) = $factory->register($app, $serviceName, $configuration);
             return $stack;
         });
     }
     $factory = $this->getFactory($lastServiceName);
     $configuration = $this->getConfiguration($lastServiceName, $parameters);
     list($stackName, $stack) = $factory->register($app, $lastServiceName, $configuration);
     $stackResolved = $builder->resolve($stack);
     return array($name, $stackResolved);
 }
Example #3
0
/**
 * User: alkuk
 * Date: 03.04.14
 * Time: 15:00
 */
use StackCI\Application as CIApplication;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use LanguageSelector\I18nSelector;
require_once __DIR__ . '/vendor/autoload.php';
$session = new Session();
$session->start();
$request = Request::createFromGlobals();
$request->setSession($session);
//$ciApp = new CIApplication(__DIR__, 'development');
$ciApp = new CIApplication(__DIR__, 'production');
$ciApp->beforeKernelLoad(function () {
    define('PUBPATH', FCPATH . "public");
    if (!ini_get('date.timezone')) {
        date_default_timezone_set('UTC');
    }
    require_once APPPATH . 'third_party/datamapper/bootstrap.php';
})->init();
$stackBuilder = new Stack\Builder();
//$languageSelector = new I18nSelector($ciApp);
//$stackBuilder->push($languageSelector);
$app = $stackBuilder->resolve($ciApp);
$response = $app->handle($request);
$response->send();
$app->terminate($request, $response);
Example #4
0
require_once dirname(__DIR__) . '/vendor/autoload.php';
//Create an instance of cubex, with the web root defined
$cubex = new \Cubex\Cubex(__DIR__);
$cubex->boot();
//Create and configure a new dispatcher
$dispatcher = new \Packaged\Dispatch\Dispatch($cubex, $cubex->getConfiguration()->getSection('dispatch'));
//Set the correct working directory for dispatcher
$dispatcher->setBaseDirectory(dirname(__DIR__));
//Load in the cache of file hashes to improve performance of dispatched assets
$fileHash = 'conf/dispatch.filehash.ini';
if (file_exists($fileHash)) {
    $hashTable = parse_ini_file($fileHash, false);
    if (!empty($hashTable)) {
        $dispatcher->setFileHashTable($hashTable);
    }
}
$stack = new \Stack\Builder();
// Uncomment to handle cookies
//$stack->push('Illuminate\Cookie\Queue', $cubex['cookie']);
// Inject dispatch to handle assets
$stack->push([$dispatcher, 'prepare']);
// Resolve the stack
$app = $stack->resolve($cubex);
//Create a request object
$request = \Cubex\Http\Request::createFromGlobals();
//Tell Cubex to handle the request, and do its magic
$response = $app->handle($request);
//Send the generated response to the user
$response->send();
//Shutdown Cubex
$app->terminate($request, $response);