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
c9eb7bdf
Commit
c9eb7bdf
authored
Jan 24, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated session task to run through migration system.
parent
27fdb1e3
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
195 additions
and
26 deletions
+195
-26
artisan.php
laravel/cli/artisan.php
+2
-12
console.php
laravel/cli/console.php
+55
-0
dependencies.php
laravel/cli/dependencies.php
+1
-1
migrator.php
laravel/cli/tasks/migrate/migrator.php
+14
-8
resolver.php
laravel/cli/tasks/migrate/resolver.php
+1
-1
session.php
laravel/cli/tasks/session.php
+3
-3
manager.php
laravel/cli/tasks/session/manager.php
+77
-0
migration.php
laravel/cli/tasks/session/migration.php
+40
-0
core.php
laravel/core.php
+2
-1
No files found.
laravel/cli/artisan.php
View file @
c9eb7bdf
...
...
@@ -15,17 +15,7 @@ Bundle::start(DEFAULT_BUNDLE);
* retrieve them from the various parts of the CLI code. We can use
* the Request class to access them conveniently.
*/
$_SERVER
[
'cli'
]
=
array
();
foreach
(
$_SERVER
[
'argv'
]
as
$key
=>
$value
)
{
if
(
starts_with
(
$value
,
'--'
))
{
$option
=
array_get
(
$_SERVER
[
'argv'
],
$key
+
1
,
true
);
array_set
(
$_SERVER
,
'cli.'
.
substr
(
$value
,
2
),
$option
);
}
}
list
(
$arguments
,
$_SERVER
[
'cli'
])
=
Console
::
options
(
$_SERVER
[
'argv'
]);
/**
* The Laravel environment may be specified on the CLI using the "env"
...
...
@@ -65,7 +55,7 @@ require SYS_PATH.'cli/dependencies'.EXT;
*/
try
{
Command
::
run
(
array_slice
(
$
_SERVER
[
'argv'
]
,
1
));
Command
::
run
(
array_slice
(
$
arguments
,
1
));
}
catch
(
\Exception
$e
)
{
...
...
laravel/cli/console.php
0 → 100644
View file @
c9eb7bdf
<?php
namespace
Laravel\CLI
;
class
Console
{
/**
* Parse the command line arguments and return the results.
*
* The returned array contains the arguments and the options.
*
* @param array $argv
* @param array
*/
public
static
function
options
(
$argv
)
{
$options
=
array
();
$arguments
=
array
();
for
(
$i
=
0
,
$count
=
count
(
$argv
);
$i
<
$count
;
$i
++
)
{
$argument
=
$argv
[
$i
];
// If the CLI argument starts with a double hyphen, it is an option,
// so we will extract the value and add it to the array of options
// to be returned by the method.
if
(
starts_with
(
$argument
,
'--'
))
{
// By default, we will assume the value of the options is true,
// but if the option contains an equals sign, we will take the
// value to the right of the equals sign as the value and
// remove the value from the option key.
list
(
$key
,
$value
)
=
array
(
substr
(
$argument
,
2
),
true
);
if
((
$equals
=
strpos
(
$argument
,
'='
))
!==
false
)
{
$key
=
substr
(
$argument
,
2
,
$equals
-
2
);
$value
=
substr
(
$argument
,
$equals
+
1
);
}
$options
[
$key
]
=
$value
;
}
// If the CLI argument does not start with a double hyphen it is
// simply an argument to be passed to the console task so we'll
// add it to the array of "regular" arguments.
else
{
$arguments
[]
=
$argument
;
}
}
return
array
(
$arguments
,
$options
);
}
}
\ No newline at end of file
laravel/cli/dependencies.php
View file @
c9eb7bdf
...
...
@@ -43,7 +43,7 @@ IoC::singleton('task: key', function()
*/
IoC
::
singleton
(
'task: session'
,
function
()
{
return
new
Tasks\Session
;
return
new
Tasks\Session
\Manager
;
});
/**
...
...
laravel/cli/tasks/migrate/migrator.php
View file @
c9eb7bdf
...
...
@@ -124,7 +124,7 @@ class Migrator extends Task {
// By only removing the migration after it has successfully rolled back,
// we can re-run the rollback command in the event of any errors with
// the migration. When we re-run, only the migrations that have not
// been rolled back
for the batch
will still be in the database.
// been rolled back will still be in the database.
$this
->
database
->
delete
(
$migration
[
'bundle'
],
$migration
[
'name'
]);
}
...
...
@@ -176,8 +176,8 @@ class Migrator extends Task {
/**
* Generate a new migration file.
*
* @param array $arguments
* @return
void
* @param array
$arguments
* @return
string
*/
public
function
make
(
$arguments
=
array
())
{
...
...
@@ -188,11 +188,11 @@ class Migrator extends Task {
list
(
$bundle
,
$migration
)
=
Bundle
::
parse
(
$arguments
[
0
]);
// The migration path is prefixed with the
UNIX
timestamp, which
// The migration path is prefixed with the
date
timestamp, which
// is a better way of ordering migrations than a simple integer
// incrementation, since developers may start working on the
// next migration at the same time unknowingly.
$
date
=
date
(
'Y_m_d'
)
.
'_'
.
time
(
);
$
prefix
=
date
(
'Y_m_d'
);
$path
=
Bundle
::
path
(
$bundle
)
.
'migrations'
.
DS
;
...
...
@@ -201,9 +201,16 @@ class Migrator extends Task {
// when we try to write the migration file.
if
(
!
is_dir
(
$path
))
mkdir
(
$path
);
File
::
put
(
$path
.
$date
.
'_'
.
$migration
.
EXT
,
$this
->
stub
(
$bundle
,
$migration
));
$file
=
$path
.
$prefix
.
'_'
.
$migration
.
EXT
;
File
::
put
(
$file
,
$this
->
stub
(
$bundle
,
$migration
));
echo
"Great! New migration created!"
;
// Once the migration has been created, we'll return the
// migration file name so it can be used by the task
// consumer if necessary.
return
$file
;
}
/**
...
...
@@ -219,8 +226,7 @@ class Migrator extends Task {
// The class name is formatted simialrly to tasks and controllers,
// where the bundle name is prefixed to the class if it is not in
// the default bundle. However, unlike tasks, there is nothing
// appended to the class name since they're already unique.
// the default bundle.
$class
=
Bundle
::
class_prefix
(
$bundle
)
.
Str
::
classify
(
$migration
);
return
str_replace
(
'{{class}}'
,
$class
,
$stub
);
...
...
laravel/cli/tasks/migrate/resolver.php
View file @
c9eb7bdf
...
...
@@ -116,7 +116,7 @@ class Resolver {
// naming collisions with other bundle's migrations.
$prefix
=
Bundle
::
class_prefix
(
$bundle
);
$class
=
$prefix
.
substr
(
$name
,
22
);
$class
=
$prefix
.
substr
(
$name
,
11
);
$migration
=
new
$class
;
...
...
laravel/cli/tasks/session.php
View file @
c9eb7bdf
<?php
namespace
Laravel\CLI\Tasks
;
<?php
namespace
Laravel\CLI\Tasks
\Session
;
use
Laravel\File
;
use
Laravel\Config
;
use
Laravel\Database\Schema
;
use
Laravel\Session\Drivers\Sweeper
;
class
Session
extends
Task
{
class
Manager
extends
Task
{
/**
* Generate the session table on the database.
...
...
@@ -19,7 +19,7 @@ class Session extends Task {
{
$table
->
create
();
// The session table consists simply of a ID, a UNIX timestamp to
// The session table consists simply of a
n
ID, a UNIX timestamp to
// indicate the expiration time, and a blob field which will hold
// the serialized form of the session payload.
$table
->
string
(
'id'
)
->
length
(
40
)
->
primary
(
'session_primary'
);
...
...
laravel/cli/tasks/session/manager.php
0 → 100644
View file @
c9eb7bdf
<?php
namespace
Laravel\CLI\Tasks\Session
;
use
Laravel\IoC
;
use
Laravel\File
;
use
Laravel\Config
;
use
Laravel\Session
;
use
Laravel\CLI\Tasks\Task
;
use
Laravel\Database\Schema
;
use
Laravel\Session\Drivers\Sweeper
;
use
Laravel\CLI\Tasks\Migrate\Migrator
;
class
Manager
extends
Task
{
/**
* Generate the session table on the database.
*
* @param array $arguments
* @return void
*/
public
function
table
(
$arguments
=
array
())
{
$migrator
=
IoC
::
resolve
(
'task: migrate'
);
// To create the session table, we will actually create a database
// migration and then run it. This allows the application to stay
// portable through migrations while still having a session table
// generated on the database.
$migration
=
$migrator
->
make
(
array
(
'create_session_table'
));
$stub
=
SYS_PATH
.
'cli/tasks/session/migration'
.
EXT
;
File
::
put
(
$migration
,
File
::
get
(
$stub
));
// By default no session driver is specified in the configuration.
// Since the developer is requesting that the session table be
// created on the database, we'll set the driver to database
// to save an extra step for the developer.
$config
=
File
::
get
(
APP_PATH
.
'config/session'
.
EXT
);
$config
=
str_replace
(
"'driver' => '',"
,
"'driver' => 'database',"
,
$config
);
File
::
put
(
APP_PATH
.
'config/session'
.
EXT
,
$config
);
echo
PHP_EOL
;
$migrator
->
run
();
}
/**
* Sweep the expired sessions from storage.
*
* @param array $arguments
* @return void
*/
public
function
sweep
(
$arguments
=
array
())
{
$driver
=
Session
::
factory
(
Config
::
get
(
'session.driver'
));
// If the driver implements the "Sweeper" interface, we know that
// it can sweep expired sessions from storage. Not all drivers
// need be sweepers, as stores like Memcached and APC will
// perform their own garbage collection.
if
(
$driver
instanceof
Sweeper
)
{
$lifetime
=
Config
::
get
(
'session.lifetime'
);
$driver
->
sweep
(
time
()
-
(
$lifetime
*
60
));
}
echo
"The session table has been swept!"
;
}
}
\ No newline at end of file
laravel/cli/tasks/session/migration.php
0 → 100644
View file @
c9eb7bdf
<?php
class
Create_Session_Table
{
/**
* Make changes to the database.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
Config
::
get
(
'session.table'
),
function
(
$table
)
{
$table
->
create
();
// The session table consists simply of an ID, a UNIX timestamp to
// indicate the expiration time, and a blob field which will hold
// the serialized form of the session payload.
$table
->
string
(
'id'
)
->
length
(
40
)
->
primary
(
'session_primary'
);
$table
->
integer
(
'last_activity'
);
$table
->
text
(
'data'
);
});
}
/**
* Revert the changes to the database.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
Config
::
get
(
'session.table'
),
function
(
$table
)
{
$table
->
drop
();
});
}
}
\ No newline at end of file
laravel/core.php
View file @
c9eb7bdf
...
...
@@ -81,6 +81,7 @@ Autoloader::$mappings = array(
'Laravel\\Cache\\Drivers\\Redis'
=>
SYS_PATH
.
'cache/drivers/redis'
.
EXT
,
'Laravel\\Cache\\Drivers\\Database'
=>
SYS_PATH
.
'cache/drivers/database'
.
EXT
,
'Laravel\\CLI\\Console'
=>
SYS_PATH
.
'cli/console'
.
EXT
,
'Laravel\\CLI\\Command'
=>
SYS_PATH
.
'cli/command'
.
EXT
,
'Laravel\\CLI\\Tasks\\Task'
=>
SYS_PATH
.
'cli/tasks/task'
.
EXT
,
'Laravel\\CLI\\Tasks\\Bundle\\Bundler'
=>
SYS_PATH
.
'cli/tasks/bundle/bundler'
.
EXT
,
...
...
@@ -92,7 +93,7 @@ Autoloader::$mappings = array(
'Laravel\\CLI\\Tasks\\Migrate\\Resolver'
=>
SYS_PATH
.
'cli/tasks/migrate/resolver'
.
EXT
,
'Laravel\\CLI\\Tasks\\Migrate\\Database'
=>
SYS_PATH
.
'cli/tasks/migrate/database'
.
EXT
,
'Laravel\\CLI\\Tasks\\Key'
=>
SYS_PATH
.
'cli/tasks/key'
.
EXT
,
'Laravel\\CLI\\Tasks\\Session
'
=>
SYS_PATH
.
'cli/tasks/session
'
.
EXT
,
'Laravel\\CLI\\Tasks\\Session
\\Manager'
=>
SYS_PATH
.
'cli/tasks/session/manager
'
.
EXT
,
'Laravel\\Database\\Connection'
=>
SYS_PATH
.
'database/connection'
.
EXT
,
'Laravel\\Database\\Expression'
=>
SYS_PATH
.
'database/expression'
.
EXT
,
...
...
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