protected function createApplicationContainer()
 {
     $this->app = new \TestContainer();
     $this->app->singleton('config', function () {
         return new \Illuminate\Config\Repository();
     });
     $this->registerConfigure();
     $eventServiceProvider = new \Illuminate\Encryption\EncryptionServiceProvider($this->app);
     $eventServiceProvider->register();
     $eventServiceProvider = new \Illuminate\Events\EventServiceProvider($this->app);
     $eventServiceProvider->register();
     $queueProvider = new \Illuminate\Queue\QueueServiceProvider($this->app);
     $queueProvider->register();
     $sessionProvider = new \Illuminate\Session\SessionServiceProvider($this->app);
     $sessionProvider->register();
     $this->registerDatabase();
     $this->registerCache();
     $couchbaseProvider = new \Ytake\LaravelCouchbase\CouchbaseServiceProvider($this->app);
     $couchbaseProvider->register();
     $couchbaseProvider->boot();
     $this->app->bind(\Illuminate\Container\Container::class, function () {
         return $this->app;
     });
     (new \Illuminate\Events\EventServiceProvider($this->app))->register();
     \Illuminate\Container\Container::setInstance($this->app);
 }
 /**
  * @return \Illuminate\Container\Container
  */
 public static function getContainer()
 {
     if (!self::$container) {
         self::$container = new \Illuminate\Container\Container();
         self::$container->bind('app', self::$container);
     }
     return self::$container;
 }
 public function init()
 {
     $builder = new Container();
     $builder->bind('bicycle_factory_shared', function ($app) {
         return new \PhpBench\Benchmarks\Container\Acme\BicycleFactory();
     }, true);
     $builder->bind('bicycle_factory', function ($app) {
         return new \PhpBench\Benchmarks\Container\Acme\BicycleFactory();
     }, false);
     $this->container = $builder;
 }
Example #4
0
 /**
  * Register repositories Interfaces
  *
  * @return void
  */
 public function registerRepositories()
 {
     //Bind UserRepository interface
     $this->ioc->bind('App\\Repositories\\Contracts\\UserRepositoryInterface', 'App\\Repositories\\UserRepository');
     $this->ioc->bind('UserRepo', function ($app) {
         return $app->make('App\\Repositories\\Contracts\\UserRepositoryInterface');
     });
     //Bind PostRepository interface
     $this->ioc->bind('App\\Repositories\\Contracts\\PostRepositoryInterface', 'App\\Repositories\\PostRepository');
     $this->ioc->bind('PostRepo', function ($app) {
         return $app->make('App\\Repositories\\Contracts\\PostRepositoryInterface');
     });
 }
Example #5
0
 public static function setUpBeforeClass()
 {
     $app = new Container();
     $app->bind('config', function () {
         return Mockery::mock('config', function ($mock) {
             $mock->shouldReceive('get')->with('config.image_engine', '')->andReturn('Gd');
             $mock->shouldReceive('get')->with('config.quality', '')->andReturn(75);
             $mock->shouldReceive('get')->with('config.cache_folder', '')->andReturn('');
         });
     });
     $app['path.public'] = 'tests/public';
     $app->bind('illuminage', function ($app) {
         return new \Illuminage\Illuminage($app);
     });
     Illuminage::setFacadeApplication($app);
 }
 /**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('campfire', function ($app) {
         return new Campfire($app['config']->get('rocketeer-campfire::config'));
     });
     return $app;
 }
 /**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('newrelic', function ($app) {
         return new RocketeerNewrelicConfig($app['config']->get('rocketeer-newrelic::config'));
     });
     return $app;
 }
Example #8
0
 /**
  * Apply various parameters according to form type
  *
  * @param  string $type The original form type provided
  *
  * @return string The final form type
  */
 private function applyType($type)
 {
     // If classic form
     if ($type == 'open') {
         return $this->app['former']->getOption('default_form_type');
     }
     // Look for HTTPS form
     if (Str::contains($type, 'secure')) {
         $type = str_replace('secure', '', $type);
         $this->secure = true;
     }
     // Look for file form
     if (Str::contains($type, 'for_files')) {
         $type = str_replace('for_files', '', $type);
         $this->attributes['enctype'] = 'multipart/form-data';
     }
     // Calculate form type
     $type = str_replace('open', '', $type);
     $type = trim($type, '_');
     // If raw form
     if ($type == 'raw') {
         $this->app->bind('former.form.framework', function ($app) {
             return $app['former']->getFrameworkInstance('Nude');
         });
     }
     // Use default form type if the one provided is invalid
     if ($type !== 'raw' and !in_array($type, $this->app['former.form.framework']->availableTypes())) {
         $type = $this->app['former']->getOption('default_form_type');
     }
     return $type;
 }
 /**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('slack', function ($app) {
         return new Client($app['config']->get('rocketeer-slack::url'));
     });
     return $app;
 }
 /**
  * @return ContainerInterface
  */
 private function createContainer(array $map = [])
 {
     $container = new Container();
     foreach ($map as $key => $value) {
         $container->bind($key, $value);
     }
     return new LaravelContainer($container);
 }
 public function register(Container $app)
 {
     $settings = ['username' => $app['config']->get('rocketeer-slack-unofficial::config')['url'], 'channel' => $app['config']->get('rocketeer-slack-unofficial::config')['channel'], 'link_names' => true, 'icon' => ':rocket:'];
     $app->bind('slack', function ($app) use($settings) {
         return new Client($app['config']->get('rocketeer-slack-unofficial::config')['hook-url'], $settings);
     });
     return $app;
 }
Example #12
0
 /**
  * Register the view finder implementation.
  *
  * @return void
  */
 public function registerViewFinder()
 {
     $me = $this;
     $this->container->bind('view.finder', function ($app) use($me) {
         $paths = $me->viewPaths;
         return new FileViewFinder($app['files'], $paths);
     });
 }
Example #13
0
 /**
  * Shared is a pseudonym for `bind()` as singleton.
  *
  * @param      $abstract
  * @param null $concrete
  *
  * @return void
  */
 public function shared($abstract, $concrete = NULL)
 {
     // translate ['alias','concrete'] to ['alias'=>'concrete'] for embedded DI
     if (is_array($abstract)) {
         $abstract = [$abstract[0] => $abstract[1]];
     }
     static::$container->bind($abstract, $concrete, TRUE);
 }
Example #14
0
 /**
  * Overload the bind method so the services are added to the Slim DI container as well as Illuminate container
  */
 public function bind($abstract, $concrete = null, $shared = false)
 {
     parent::bind($abstract, $concrete, $shared);
     $service_manager = $this;
     $this->app->{$abstract} = function () use($service_manager, $abstract) {
         return $service_manager->make($abstract);
     };
 }
 public function testAliases()
 {
     $container = new Container();
     $container->bind('request', function () {
         return 'input';
     });
     $container->bind('translator', function () {
         return 'lang';
     });
     $container->bind('blade.compiler', function () {
         return 'blade';
     });
     Container::setInstance($container);
     $this->assertEquals('input', $this->input);
     $this->assertEquals('lang', $this->lang);
     $this->assertEquals('blade', $this->blade_compiler);
     $this->assertSame($container, $this->app);
 }
 /** @test */
 public function it_can_retrieve_dynamic_objects_from_the_container()
 {
     $container = new Container();
     $container->bind('foo', function () {
         return 'bar';
     });
     $handler = new EventHandlerStub($container);
     $this->assertSame('bar', $handler->foo);
 }
 protected function createContainer()
 {
     $container = new Container();
     $container->instance('array_iterator', new \ArrayIterator(range(1, 5)));
     $container->bind('error', function () {
         throw new \RuntimeException();
     });
     return new LaravelContainerAdapter($container);
 }
 public function setUp()
 {
     $container = new Container();
     $container->bind('Cat', function () {
         $cat = new stdClass();
         $cat->name = 'lolcat';
         return $cat;
     });
     $this->container = new LaravelContainer($container);
 }
Example #19
0
 /**
  * Switch the framework used by Form
  *
  * @param string $framework The name of the framework to use
  */
 public function framework($framework = null)
 {
     if (!$framework) {
         return $this->app['form.framework']->current();
     }
     $this->setOption('framework', $framework);
     $framework = $this->getFrameworkInstance($framework);
     $this->app->bind('form.framework', function ($app) use($framework) {
         return $framework;
     });
 }
Example #20
0
 protected function createApplicationContainer()
 {
     $this->app = new \Illuminate\Container\Container();
     $this->app->singleton('config', function () {
         return new \Illuminate\Config\Repository();
     });
     $this->app->instance('log', $log = new \Illuminate\Log\Writer(new \Monolog\Logger('testing')));
     $this->app->instance('Psr\\Log\\LoggerInterface', $log = new \Illuminate\Log\Writer(new \Monolog\Logger('testing')));
     $this->registerConfigure();
     $this->registerDatabase();
     $this->registerCache();
     $annotationConfiguration = new \Ytake\LaravelAspect\AnnotationConfiguration($this->app['config']->get('ytake-laravel-aop.annotation'));
     $annotationConfiguration->ignoredAnnotations();
     $this->app->singleton('aspect.manager', function ($app) {
         return new \Ytake\LaravelAspect\AspectManager($app);
     });
     $this->app->bind(\Illuminate\Container\Container::class, function () {
         return $this->app;
     });
     \Illuminate\Container\Container::setInstance($this->app);
 }
Example #21
0
 /**
  * Bind core classes to the Container
  *
  * @param Container $app
  *
  * @return Container
  */
 public function bindCoreClasses(Container $app)
 {
     $app->bindIf('events', function ($app) {
         return new Dispatcher($app);
     }, true);
     $app->bindIf('router', function ($app) {
         return new Router($app['events'], $app);
     }, true);
     $app->bind('url', function ($app) {
         return new UrlGenerator($app['router']->getRoutes(), $app['request']);
     });
     return $app;
 }
Example #22
0
 /**
  * Run the build command.
  *
  * @return bool
  */
 protected function build()
 {
     $container = new Container();
     $container->singleton('files', Filesystem::class);
     $container->bind(Factory::class, function ($app) {
         return new Factory($app->make(EngineResolver::class), new FileViewFinder($app['files'], ['test/source']), new Dispatcher($app));
     });
     $container->afterResolving(function (Factory $factory, $app) {
         $factory->addExtension('php', 'php', function () {
             return new PhpEngine();
         });
         $factory->addExtension('blade.php', 'blade', function () use($app) {
             return new CompilerEngine(new BladeCompiler($app['files'], vfsStream::url('test/.cache')));
         });
     });
     $builder = new Builder($container, [Skip::class . ':_*', Compile::class]);
     return $builder->build(vfsStream::url('test/source'), vfsStream::url('test/build'));
 }
Example #23
0
 /**
  * weaving
  */
 public function weave()
 {
     if (is_null($this->aspectResolver)) {
         return;
     }
     foreach ($this->aspectResolver->getResolver() as $class => $pointcuts) {
         $bind = (new AspectBind($this->filesystem, $this->configure['cache_dir'], $this->cacheable))->bind($class, $pointcuts);
         $compiledClass = $this->compiler->compile($class, $bind);
         if (isset($this->app->contextual[$class])) {
             $this->resolveContextualBindings($class, $compiledClass);
         }
         $this->app->bind($class, function (Container $app) use($bind, $compiledClass) {
             $instance = $app->make($compiledClass);
             $instance->bindings = $bind->getBindings();
             return $instance;
         });
     }
 }
Example #24
0
 public static function setUpBeforeClass()
 {
     $container = new Container();
     $container->bind('config', function () {
         return Mockery::mock('Config', function ($mock) {
             $mock->shouldReceive('get')->andReturnUsing(function ($key) {
                 if ($key == 'database.mongodb.default') {
                     return array('host' => 'localhost', 'port' => 27017, 'database' => 'mongovel_tests');
                 }
                 if ($key == 'profiling.mongo') {
                     return false;
                 }
             });
         });
     });
     $container->singleton('mongoveldb', function () {
         return new DB();
     });
     Mongovel::setContainer($container);
     self::$db = Mongovel::getContainer()->make('mongoveldb');
 }
 public function registerTranslator()
 {
     $this->container->bind('translator', function () {
         return new Translator('en_US', new MessageSelector());
     }, true);
 }
Example #26
0
 /**
  * Get the container with all its bindings
  *
  * @param  \Algorit\Synchronizer\Container  $container
  * @return \Algorit\Synchronizer\Container  $container
  */
 private function bindedContainer(Container $container)
 {
     // Set actual namespace in container.
     $container->namespace = $this->namespace;
     $container->bind('Algorit\\Synchronizer\\Request\\Methods\\MethodInterface', function () {
         return $this->method ?: new Requests();
     });
     // Is it binding the Container to itself? Brain f**k
     // Think we should use an interface here
     $container->bind('Algorit\\Synchronizer\\Container', function () use($container) {
         return $container;
     });
     return $container;
 }
Example #27
0
 /**
  * Add shorthand for pipeline handlers.
  *
  * Allows the simpler "<name>:<args>" style when defining the build pipeline,
  * as opposed to "<FQCN>:<args>"
  *
  * @param Container $app
  */
 protected function bindAliasesForPipeline(Container $app)
 {
     $app->bind('skip', Skip::class);
     $app->bind('compile', Compile::class);
 }
/**
 * @param \Illuminate\Container\Container|\Laravel\Lumen\Application $app
 */
function rebind($app)
{
    unset($app[IAuthBundle::class]);
    $app->bind(IAuthBundle::class, DummyAuthBundle::class);
}
Example #29
0
 public function setUp()
 {
     $container = new Container();
     $container->bind('events', 'Illuminate\\Events\\Dispatcher');
     Facade::setFacadeApplication($container);
 }
Example #30
0
*           illuminate/config
*
* @todo Drivers other than the file driver
*
* @source https://github.com/illuminate/session
* @author Matt Stauffer
* @author Sam Jordan
*/
$app = new \Slim\Slim();
$app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware());
// BOOTSTRAP-------------------------------------------------------------------
// Determine our base path
$path = __DIR__;
// Init the container
$container = new Container();
$container->bind('app', $container);
$container['config'] = new Config(new FileLoader(new Filesystem(), $path), 'production');
$container['files'] = new Filesystem();
// Not 100% sure on how many of these are needed
$container['config']['session.lifetime'] = 120;
// Minutes idleable
$container['config']['session.expire_on_close'] = false;
$container['config']['session.lottery'] = array(2, 100);
// lottery--how often do they sweep storage location to clear old ones?
$container['config']['session.cookie'] = 'laravel_session';
$container['config']['session.path'] = '/';
$container['config']['session.domain'] = null;
$container['config']['session.driver'] = 'file';
$container['config']['session.files'] = $path . '/sessions';
// Cookie time
$container['cookie'] = (new CookieJar())->setDefaultPathAndDomain('/', null);