Ejemplo n.º 1
0
Archivo: Foo.php Proyecto: recck/proem
 public function pre($e)
 {
     $a = new Asset();
     $a->set('\\Namespaced\\Foo', function ($a) {
         return new \Namespaced\Foo();
     });
     $e->getServiceManager()->set('foo', $a);
 }
 /**
  * Method to be called on the way into the filter.
  *
  * If not already provided, this method will add a default
  * Proem\Api\IO\Response\Template implementation to the main service
  * manager under the index of *response*.
  *
  * @param Proem\Api\Service\Manager\Template $assets
  */
 public function inBound(Manager $assets)
 {
     if (!$assets->provides('Proem\\IO\\Response\\Template')) {
         $asset = new Asset();
         $assets->set('response', $asset->set('Proem\\IO\\Response\\Template', $asset->single(function () {
             return new HTTPResponse();
         })));
     }
 }
 /**
  * Method to be called on the way into the filter.
  *
  * If not already provided, this method will add a default
  * Proem\Api\Dispatch\Template implementation to the main service
  * manager under the index of *dispatch*.
  *
  * @see Proem\Api\Dispatch\Template
  * @param Proem\Api\Service\Manager\Template
  */
 public function inBound(Manager $assets)
 {
     if (!$assets->provides('Proem\\Dispatch\\Template')) {
         $asset = new Asset();
         $assets->set('dispatch', $asset->set('Proem\\Dispatch\\Template', $asset->single(function () use($assets) {
             return new DispatchStandard($assets);
         })));
     }
 }
Ejemplo n.º 4
0
 /**
  * Method to be called on the way into the filter.
  *
  * This method is responsible for setting up the default routes.
  *
  * @param Proem\Service\Manager\Template $assets
  */
 public function inBound(Manager $assets)
 {
     if (!$assets->provides('Proem\\Routing\\Router\\Template')) {
         $asset = new Asset();
         $assets->set('router', $asset->set('Proem\\Routing\\Router\\Template', $asset->single(function () use($assets) {
             return new Router($assets->get('request'));
         })));
     }
 }
Ejemplo n.º 5
0
 /**
  * Method to be called on the way into the filter.
  *
  * This method is responsible for setting up the default routes.
  *
  * @param Proem\Api\Service\Manager\Template $assets
  */
 public function inBound(Manager $assets)
 {
     if (!$assets->provides('Proem\\Routing\\Router\\Template')) {
         $asset = new Asset();
         $assets->set('router', $asset->set('Proem\\Routing\\Router\\Template', $asset->single(function () use($assets) {
             $router = (new Router($assets->get('request')))->attach('default-module-controller-action-params', new StandardRoute(['rule' => '/:module/:controller/:action/:params']))->attach('default-module-controller-action-noparams', new StandardRoute(['rule' => '/:module/:controller/:action']))->attach('default-module-controller-noaction', new StandardRoute(['rule' => '/:module/:controller', 'targets' => ['action' => 'index']]))->attach('default-nomodule-controller-action', new StandardRoute(['rule' => '/:controller/:action', 'targets' => ['module' => 'index']]))->attach('default-module-nocontroller', new StandardRoute(['rule' => '/:module', 'targets' => ['controller' => 'index', 'action' => 'index']]))->attach('default-nomodule-controller', new StandardRoute(['rule' => '/:controller', 'targets' => ['module' => 'index', 'action' => 'index']]))->attach('default-params', new StandardRoute(['rule' => '/:params', 'targets' => ['module' => 'index', 'controller' => 'index', 'action' => 'index']]))->attach('default-noparams', new StandardRoute(['rule' => '/', 'targets' => ['module' => 'index', 'controller' => 'index', 'action' => 'index']]));
             return $router;
         })));
     }
 }
Ejemplo n.º 6
0
 public function testManagerHasMultiple()
 {
     $bar = new Asset();
     $bar->set('Proem\\Service\\Asset\\Bar', function () {
         return new Bar();
     });
     $foo = new Asset();
     $foo->set('Proem\\Service\\Asset\\Foo', function () {
         return new Foo();
     });
     $am = new Manager();
     $am->set('Foo', $foo)->set('Bar', $bar);
     $this->assertTrue($am->provides(['Proem\\Service\\Asset\\Foo', 'Proem\\Service\\Asset\\Bar']));
 }
Ejemplo n.º 7
0
 public function testValidServiceManager()
 {
     $asset = new GenericAsset();
     $asset->set('StdClass', function () {
         return new \StdClass();
     });
     $proem = new GenericAsset();
     $proem->set('Proem', function () {
         return new Proem();
     });
     $man = new ServiceManager();
     $man->set('StdClass', $asset)->set('Proem', $proem);
     $fixture = new OptionsFixture(['boo' => [], 'bar' => 'this is bar', 'bob' => new Proem(), 'asset' => $man, 'am' => $man]);
 }