Example #1
0
 /**
  * Method to share specified services across application.
  *
  * @return  void
  */
 public function bindServices()
 {
     foreach ($this->getRestServices() as $service) {
         /**
          * Lambda callback function to create new REST service.
          *
          * @return  \App\Services\Interfaces\Rest
          */
         $share = function () use($service) {
             return new $service->class($this->app['db'], $this->app['orm.em'], $this->app['validator']);
         };
         // Register and share service to whole application
         $this->app[$service->name] = $this->app->share($share);
     }
 }
Example #2
0
 public function loadModels(Application $app)
 {
     $app['client'] = $app->share(function () use($app) {
         return new Model\Client($app);
     });
     //        $app['document'] = $app->share(function () use ($app) {
     //            return new Model\Document($app);
     //        });
     //        $app['administrator'] = $app->share(function () use ($app) {
     //            return new Model\Administrator($app);
     //        });
     //        $app['task'] = $app->share(function () use ($app) {
     //            return new Model\Task($app);
     //        });
 }
Example #3
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use App\Application;
$app = new Application();
$app->init();
if ($app['env'] === 'dev') {
    $app['oauth'] = $app->share(function () use($app) {
        return new \App\OAuthMock($app->path('authorize'));
    });
    $app->run();
}
Example #4
0
 /**
  * Wrap a Closure such that it is shared.
  *
  * @param \Closure $closure
  * @return \Closure 
  * @static 
  */
 public static function share($closure)
 {
     //Method inherited from \Illuminate\Container\Container
     return \App\Application::share($closure);
 }