Skip to content

Commit

Permalink
Move common method for a CapsuleManager to trait, this would reduce t…
Browse files Browse the repository at this point in the history
…he requirement to produce new CapsuleManager for other component in the future (e.g: laravel/framework#5032)

Also remove duplicate "require-dev" component (when already explicitly declare in "require").

Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jul 21, 2014
1 parent baa8577 commit 214c662
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 63 deletions.
63 changes: 2 additions & 61 deletions Capsule/Manager.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
<?php namespace Illuminate\Database\Capsule;

use PDO;
use Illuminate\Support\Fluent;
use Illuminate\Events\Dispatcher;
use Illuminate\Cache\CacheManager;
use Illuminate\Container\Container;
use Illuminate\Database\DatabaseManager;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Support\Traits\CapsuleManagerTrait;

class Manager {

/**
* The current globally used instance.
*
* @var \Illuminate\Database\Capsule\Manager
*/
protected static $instance;
use CapsuleManagerTrait;

/**
* The database manager instance.
Expand All @@ -25,13 +20,6 @@ class Manager {
*/
protected $manager;

/**
* The container instance.
*
* @var \Illuminate\Container\Container
*/
protected $container;

/**
* Create a new database capsule manager.
*
Expand All @@ -50,22 +38,6 @@ public function __construct(Container $container = null)
$this->setupManager();
}

/**
* Setup the IoC container instance.
*
* @param \Illuminate\Container\Container|null $container
* @return void
*/
protected function setupContainer($container)
{
$this->container = $container ?: new Container;

if ( ! $this->container->bound('config'))
{
$this->container->instance('config', new Fluent);
}
}

/**
* Setup the default database configuration options.
*
Expand Down Expand Up @@ -182,16 +154,6 @@ public function setFetchMode($fetchMode)
return $this;
}

/**
* Make this capsule instance available globally.
*
* @return void
*/
public function setAsGlobal()
{
static::$instance = $this;
}

/**
* Get the database manager instance.
*
Expand Down Expand Up @@ -250,27 +212,6 @@ public function setCacheManager(CacheManager $cache)
$this->container->instance('cache', $cache);
}

/**
* Get the IoC container instance.
*
* @return \Illuminate\Container\Container
*/
public function getContainer()
{
return $this->container;
}

/**
* Set the IoC container instance.
*
* @param \Illuminate\Container\Container $container
* @return void
*/
public function setContainer(Container $container)
{
$this->container = $container;
}

/**
* Dynamically pass methods to the default connection.
*
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"illuminate/cache": "4.2.*",
"illuminate/console": "4.2.*",
"illuminate/filesystem": "4.2.*",
"illuminate/pagination": "4.2.*",
"illuminate/support": "4.2.*"
"illuminate/pagination": "4.2.*"
},
"autoload": {
"psr-0": {
Expand Down

0 comments on commit 214c662

Please sign in to comment.