コード例 #1
0
 /**
  * Resolve the subscriber instance.
  *
  * @param  mixed  $subscriber
  * @return mixed
  */
 protected function resolveSubscriber($subscriber)
 {
     if (is_string($subscriber)) {
         return $this->container->make($subscriber);
     }
     return $subscriber;
 }
コード例 #2
0
ファイル: Files.php プロジェクト: nova-framework/app
 /**
  * Return a Files Dispatcher instance
  *
  * @return \Routing\FileDispatcher
  */
 protected function getFileDispatcher()
 {
     if (isset($this->fileDispatcher)) {
         return $this->fileDispatcher;
     }
     return $this->fileDispatcher = $this->container->make('Nova\\Routing\\Assets\\DispatcherInterface');
 }
コード例 #3
0
 /**
  * Create a new connection instance.
  *
  * @param  string   $driver
  * @param  \PDO     $connection
  * @param  string   $database
  * @param  string   $prefix
  * @param  array    $config
  * @return \Database\Connection
  *
  * @throws \InvalidArgumentException
  */
 protected function createConnection($driver, PDO $connection, $database, $prefix = '', array $config = array())
 {
     if ($this->container->bound($key = "db.connection.{$driver}")) {
         return $this->container->make($key, array($connection, $database, $prefix, $config));
     }
     switch ($driver) {
         case 'mysql':
             return new MySqlConnection($connection, $database, $prefix, $config);
         case 'pgsql':
             return new PostgresConnection($connection, $database, $prefix, $config);
         case 'sqlite':
             return new SQLiteConnection($connection, $database, $prefix, $config);
         case 'sqlsrv':
             return new SqlServerConnection($connection, $database, $prefix, $config);
     }
     throw new \InvalidArgumentException("Unsupported driver [{$driver}]");
 }
コード例 #4
0
 /**
  * Make a controller instance via the IoC container.
  *
  * @param  string  $controller
  * @return mixed
  */
 protected function makeController($controller)
 {
     Controller::setFilterer($this->filterer);
     return $this->container->make($controller);
 }
コード例 #5
0
ファイル: index.php プロジェクト: konopelkosergeyv/test
<?php

use container\Container;
require_once 'autoload.php';
$testBlock = new Container();
$testBlock->initialize();
$testBlock->run();
コード例 #6
0
 /**
  * "Extend" an abstract type in the container.
  *
  * (Overriding Container::extend)
  *
  * @param  string   $abstract
  * @param  \Closure  $closure
  * @return void
  *
  * @throws \InvalidArgumentException
  */
 public function extend($abstract, Closure $closure)
 {
     $abstract = $this->getAlias($abstract);
     if (isset($this->deferredServices[$abstract])) {
         $this->loadDeferredProvider($abstract);
     }
     return parent::extend($abstract, $closure);
 }