Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
9281f04c
Commit
9281f04c
authored
Nov 12, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor refactorings.
parent
41ca8169
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
70 deletions
+53
-70
factory.php
laravel/cache/drivers/factory.php
+0
-34
manager.php
laravel/cache/manager.php
+28
-6
factory.php
laravel/database/connectors/factory.php
+0
-29
manager.php
laravel/database/manager.php
+25
-1
No files found.
laravel/cache/drivers/factory.php
deleted
100644 → 0
View file @
41ca8169
<?php
namespace
Laravel\Cache\Drivers
;
use
Laravel\Config
;
class
Factory
{
/**
* Create a new cache driver instance.
*
* @param string $driver
* @return Driver
*/
public
static
function
make
(
$driver
)
{
switch
(
$driver
)
{
case
'apc'
:
return
new
APC
(
Config
::
get
(
'cache.key'
));
case
'file'
:
return
new
File
(
CACHE_PATH
);
case
'memcached'
:
return
new
Memcached
(
\Laravel\Memcached
::
instance
(),
Config
::
get
(
'cache.key'
));
case
'redis'
:
return
new
Redis
(
\Laravel\Redis
::
db
());
default
:
throw
new
\Exception
(
"Cache driver
{
$driver
}
is not supported."
);
}
}
}
\ No newline at end of file
laravel/cache/manager.php
View file @
9281f04c
...
...
@@ -36,17 +36,39 @@ class Manager {
if
(
!
array_key_exists
(
$driver
,
static
::
$drivers
))
{
if
(
!
IoC
::
registered
(
"laravel.cache.
{
$driver
}
"
))
{
throw
new
\Exception
(
"Cache driver [
$driver
] is not supported."
);
}
return
static
::
$drivers
[
$driver
]
=
Drivers\Factory
::
make
(
$driver
);
return
static
::
$drivers
[
$driver
]
=
static
::
factory
(
$driver
);
}
return
static
::
$drivers
[
$driver
];
}
/**
* Create a new cache driver instance.
*
* @param string $driver
* @return Driver
*/
protected
static
function
factory
(
$driver
)
{
switch
(
$driver
)
{
case
'apc'
:
return
new
Drivers\APC
(
Config
::
get
(
'cache.key'
));
case
'file'
:
return
new
Drivers\File
(
CACHE_PATH
);
case
'memcached'
:
return
new
Drivers\Memcached
(
Memcached
::
instance
(),
Config
::
get
(
'cache.key'
));
case
'redis'
:
return
new
Drivers\Redis
(
Redis
::
db
());
default
:
throw
new
\Exception
(
"Cache driver
{
$driver
}
is not supported."
);
}
}
/**
* Pass all other methods to the default cache driver.
*
...
...
laravel/database/connectors/factory.php
deleted
100644 → 0
View file @
41ca8169
<?php
namespace
Laravel\Database\Connectors
;
class
Factory
{
/**
* Create a new database connector instance.
*
* @param string $driver
* @return Connector
*/
public
static
function
make
(
$driver
)
{
switch
(
$driver
)
{
case
'sqlite'
:
return
new
SQLite
(
DATABASE_PATH
);
case
'mysql'
:
return
new
MySQL
;
case
'pgsql'
:
return
new
Postgres
;
default
:
throw
new
\Exception
(
"Database driver [
$driver
] is not supported."
);
}
}
}
\ No newline at end of file
laravel/database/manager.php
View file @
9281f04c
...
...
@@ -65,7 +65,31 @@ class Manager {
return
call_user_func
(
$config
[
'connector'
],
$config
);
}
return
Connectors\Factory
::
make
(
$config
[
'driver'
])
->
connect
(
$config
);
return
static
::
connector
(
$config
[
'driver'
])
->
connect
(
$config
);
}
/**
* Create a new database connector instance.
*
* @param string $driver
* @return Connector
*/
protected
static
function
connector
(
$driver
)
{
switch
(
$driver
)
{
case
'sqlite'
:
return
new
Connectors\SQLite
(
DATABASE_PATH
);
case
'mysql'
:
return
new
Connectors\MySQL
;
case
'pgsql'
:
return
new
Connectors\Postgres
;
default
:
throw
new
\Exception
(
"Database driver [
$driver
] is not supported."
);
}
}
/**
...
...
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