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
ef6076b2
Commit
ef6076b2
authored
May 11, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added event queues.
parent
af9f875e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
changes.md
laravel/documentation/changes.md
+1
-0
event.php
laravel/event.php
+61
-0
No files found.
laravel/documentation/changes.md
View file @
ef6076b2
...
...
@@ -73,6 +73,7 @@
-
Fixed bug when using many-to-many relationships on non-default database connection.
-
Added true reflection based IoC to container.
-
Added
`Request::route()->controller`
and
`Request::route()->controller_action`
.
-
Added
`Event::queue`
,
`Event::flusher`
, and
`Event::flush`
methods to Event class.
<a
name=
"upgrade-3.2"
></a>
## Upgrading From 3.1
...
...
laravel/event.php
View file @
ef6076b2
...
...
@@ -9,6 +9,20 @@ class Event {
*/
public
static
$events
=
array
();
/**
* The queued events waiting for flushing.
*
* @var array
*/
public
static
$queued
=
array
();
/**
* All of the registered queue flusher callbacks.
*
* @var array
*/
public
static
$flushers
=
array
();
/**
* Determine if an event has any registered listeners.
*
...
...
@@ -54,6 +68,31 @@ class Event {
static
::
listen
(
$event
,
$callback
);
}
/**
* Add an item to an event queue for processing.
*
* @param string $queue
* @param string $key
* @param mixed $data
* @return void
*/
public
static
function
queue
(
$queue
,
$key
,
$data
)
{
static
::
$queued
[
$queue
][
$key
]
=
$data
;
}
/**
* Register a queue flusher callback.
*
* @param string $queue
* @param mixed $callback
* @return void
*/
public
static
function
flusher
(
$queue
,
$callback
)
{
static
::
$flushers
[
$queue
][]
=
$callback
;
}
/**
* Clear all event listeners for a given event.
*
...
...
@@ -99,6 +138,28 @@ class Event {
return
static
::
fire
(
$event
,
$parameters
,
true
);
}
/**
* Flush an event queue, firing the flusher for each payload.
*
* @param string $queue
* @return void
*/
public
static
function
flush
(
$queue
)
{
foreach
(
static
::
$flushers
[
$queue
]
as
$flusher
)
{
// We will simply spin through each payload registered for the event and
// fire the flusher, passing each payloads as we go. This allows all
// the events on the queue to be processed by the flusher easily.
foreach
(
static
::
$queued
[
$queue
]
as
$key
=>
$payload
)
{
array_unshift
(
$payload
,
$key
);
call_user_func_array
(
$flusher
,
$payload
);
}
}
}
/**
* Fire an event so that all listeners are called.
*
...
...
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