Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
9be65c6b
Commit
9be65c6b
authored
11 years ago
by
Peter Rotich
Committed by
Peter Rotich
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make list of subsribers static and private
parent
8c385edb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.signal.php
+8
-10
8 additions, 10 deletions
include/class.signal.php
with
8 additions
and
10 deletions
include/class.signal.php
+
8
−
10
View file @
9be65c6b
...
...
@@ -25,6 +25,8 @@
* the codebase there exists a Signal::send() for the same named signal.
*/
class
Signal
{
static
private
$subscribers
=
array
();
/**
* Subscribe to a signal.
*
...
...
@@ -51,10 +53,9 @@ class Signal {
* signal handler. The function will receive the signal data and should
* return true if the signal handler should be called.
*/
/*
static
*/
function
connect
(
$signal
,
$callable
,
$object
=
null
,
static
function
connect
(
$signal
,
$callable
,
$object
=
null
,
$check
=
null
)
{
global
$_subscribers
;
if
(
!
isset
(
$_subscribers
[
$signal
]))
$_subscribers
[
$signal
]
=
array
();
if
(
!
isset
(
self
::
$subscribers
[
$signal
]))
self
::
$subscribers
[
$signal
]
=
array
();
// XXX: Ensure $object if set is a class
if
(
$object
&&
!
is_string
(
$object
))
trigger_error
(
"Invalid object:
$object
: Expected class"
);
...
...
@@ -62,7 +63,7 @@ class Signal {
trigger_error
(
"Invalid check function: Must be callable"
);
$check
=
null
;
}
$
_
subscribers
[
$signal
][]
=
array
(
$object
,
$callable
,
$check
);
self
::
$subscribers
[
$signal
][]
=
array
(
$object
,
$callable
,
$check
);
}
/**
...
...
@@ -85,11 +86,10 @@ class Signal {
* possible to propogate changes in the signal handlers back to the
* originating context.
*/
/*static*/
function
send
(
$signal
,
$object
,
&
$data
=
null
)
{
global
$_subscribers
;
if
(
!
isset
(
$_subscribers
[
$signal
]))
static
function
send
(
$signal
,
$object
,
&
$data
=
null
)
{
if
(
!
isset
(
self
::
$subscribers
[
$signal
]))
return
;
foreach
(
$
_
subscribers
[
$signal
]
as
$sub
)
{
foreach
(
self
::
$subscribers
[
$signal
]
as
$sub
)
{
list
(
$s
,
$callable
,
$check
)
=
$sub
;
if
(
$s
&&
!
is_a
(
$object
,
$s
))
continue
;
...
...
@@ -99,6 +99,4 @@ class Signal {
}
}
}
$_subscribers
=
array
();
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment