Exemple #1
0
 /**
  * Resolve an instance of the given seeder class.
  *
  * @param  string  $class
  * @return \Nova\Database\Seeder
  */
 protected function resolve($class)
 {
     if (isset($this->container)) {
         $instance = $this->container->make($class);
         $instance->setContainer($this->container);
     } else {
         $instance = new $class();
     }
     if (isset($this->command)) {
         $instance->setCommand($this->command);
     }
     return $instance;
 }
Exemple #2
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;
 }
Exemple #3
0
 /**
  * Return a Files Dispatcher instance
  *
  * @return \Nova\Routing\Assets\DispatcherInterface
  */
 protected function getFileDispatcher()
 {
     if (isset($this->fileDispatcher)) {
         return $this->fileDispatcher;
     }
     return $this->fileDispatcher = $this->container->make('Nova\\Routing\\Assets\\DispatcherInterface');
 }
 /**
  * Create a new connection instance.
  *
  * @param  string   $driver
  * @param  \PDO     $connection
  * @param  string   $database
  * @param  string   $prefix
  * @param  array    $config
  * @return \Nova\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}]");
 }
 /**
  * "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);
 }
 /**
  * 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);
 }