Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
b73fd34d
Commit
b73fd34d
authored
Aug 23, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed deprecated DatabaseManager
parent
6391c1cd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
202 deletions
+1
-202
DatabaseManager.php
src/Jenssegers/Mongodb/DatabaseManager.php
+0
-195
DB.php
src/Jenssegers/Mongodb/Facades/DB.php
+1
-1
MongodbServiceProvider.php
src/Jenssegers/Mongodb/MongodbServiceProvider.php
+0
-6
No files found.
src/Jenssegers/Mongodb/DatabaseManager.php
deleted
100644 → 0
View file @
6391c1cd
<?php
namespace
Jenssegers\Mongodb
;
/*
|--------------------------------------------------------------------------
| DEPRECATED
|--------------------------------------------------------------------------
*/
use
Illuminate\Database\ConnectionResolverInterface
;
use
Jenssegers\Mongodb\Connection
;
use
Jenssegers\Mongodb\Builder
as
QueryBuilder
;
class
DatabaseManager
implements
ConnectionResolverInterface
{
/**
* The application instance.
*
* @var \Illuminate\Foundation\Application
*/
protected
$app
;
/**
* The active connection instances.
*
* @var array
*/
protected
$connections
=
array
();
/**
* The custom connection resolvers.
*
* @var array
*/
protected
$extensions
=
array
();
/**
* The default database connection.
*
* @var array
*/
protected
$defaultConnection
=
'mongodb'
;
/**
* Create a new database manager instance.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
public
function
__construct
(
$app
)
{
$this
->
app
=
$app
;
}
/**
* Get a database connection instance.
*
* @param string $name
* @return Connection
*/
public
function
connection
(
$name
=
null
)
{
$name
=
$name
?:
$this
->
getDefaultConnection
();
// If we haven't created this connection, we'll create it based on the config
// provided in the application. Once we've created the connections we will
// set the "fetch mode" for PDO which determines the query return types.
if
(
!
isset
(
$this
->
connections
[
$name
]))
{
$connection
=
$this
->
makeConnection
(
$name
);
$this
->
connections
[
$name
]
=
$this
->
prepare
(
$connection
);
}
return
$this
->
connections
[
$name
];
}
/**
* Reconnect to the given database.
*
* @param string $name
* @return Connection
*/
public
function
reconnect
(
$name
=
null
)
{
unset
(
$this
->
connections
[
$name
]);
return
$this
->
connection
(
$name
);
}
/**
* Make the database connection instance.
*
* @param string $name
* @return Connection
*/
protected
function
makeConnection
(
$name
)
{
$config
=
$this
->
getConfig
(
$name
);
if
(
isset
(
$this
->
extensions
[
$name
]))
{
return
call_user_func
(
$this
->
extensions
[
$name
],
$config
);
}
return
new
Connection
(
$config
);
}
/**
* Prepare the database connection instance.
*
* @param Connection $connection
* @return Connection
*/
protected
function
prepare
(
Connection
$connection
)
{
$connection
->
setEventDispatcher
(
$this
->
app
[
'events'
]);
// The database connection can also utilize a cache manager instance when cache
// functionality is used on queries, which provides an expressive interface
// to caching both fluent queries and Eloquent queries that are executed.
$app
=
$this
->
app
;
$connection
->
setCacheManager
(
function
()
use
(
$app
)
{
return
$app
[
'cache'
];
});
// We will setup a Closure to resolve the paginator instance on the connection
// since the Paginator isn't sued on every request and needs quite a few of
// our dependencies. It'll be more efficient to lazily resolve instances.
$connection
->
setPaginator
(
function
()
use
(
$app
)
{
return
$app
[
'paginator'
];
});
return
$connection
;
}
/**
* Get the configuration for a connection.
*
* @param string $name
* @return array
*/
protected
function
getConfig
(
$name
)
{
$name
=
$name
?:
$this
->
getDefaultConnection
();
// To get the database connection configuration, we will just pull each of the
// connection configurations and get the configurations for the given name.
// If the configuration doesn't exist, we'll throw an exception and bail.
$connections
=
$this
->
app
[
'config'
][
'database.connections'
];
if
(
is_null
(
$config
=
array_get
(
$connections
,
$name
)))
{
throw
new
\InvalidArgumentException
(
"Database [
$name
] not configured."
);
}
return
$config
;
}
/**
* Get the default connection name.
*
* @return string
*/
public
function
getDefaultConnection
()
{
return
$this
->
defaultConnection
;
}
/**
* Set the default connection name.
*
* @param string $name
* @return void
*/
public
function
setDefaultConnection
(
$name
)
{
$this
->
defaultConnection
=
$name
;
}
/**
* Dynamically pass methods to the default connection.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public
function
__call
(
$method
,
$parameters
)
{
return
call_user_func_array
(
array
(
$this
->
connection
(),
$method
),
$parameters
);
}
}
\ No newline at end of file
src/Jenssegers/Mongodb/Facades/DB.php
View file @
b73fd34d
...
...
@@ -17,7 +17,7 @@ class DB extends Facade {
*/
protected
static
function
getFacadeAccessor
()
{
return
'
mongo
db'
;
return
'db'
;
}
}
\ No newline at end of file
src/Jenssegers/Mongodb/MongodbServiceProvider.php
View file @
b73fd34d
...
...
@@ -24,12 +24,6 @@ class MongodbServiceProvider extends ServiceProvider {
*/
public
function
register
()
{
// DEPRECATED
$this
->
app
[
'mongodb'
]
=
$this
->
app
->
share
(
function
(
$app
)
{
return
new
DatabaseManager
(
$app
);
});
// Add a mongodb extension to the original database manager
$this
->
app
[
'db'
]
->
extend
(
'mongodb'
,
function
(
$config
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment