Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gallery
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
gallery
Commits
534f901b
Commit
534f901b
authored
Feb 10, 2008
by
Thilo Viereck
Browse files
Options
Downloads
Patches
Plain Diff
- task: establish event listener infrastructure
parent
cc868a6c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
G2DrupalHelper.class
+77
-0
77 additions, 0 deletions
G2DrupalHelper.class
with
77 additions
and
0 deletions
G2DrupalHelper.class
0 → 100644
+
77
−
0
View file @
534f901b
<?php
// $Id: $
/**
* Class G2DrupalHelper {}.
*/
class
G2DrupalHelper
{
function
registerEventListeners
(
$listeners
)
{
foreach
(
$listeners
as
$listener
)
{
// Default path to event listener class
if
(
!
isset
(
$listener
[
'path'
]))
{
$listener
[
'path'
]
=
drupal_get_path
(
'module'
,
'gallery'
)
.
'/G2DrupalHelper.class'
;
}
// Store event parameters
$listener
[
'events'
]
=
is_array
(
$listener
[
'events'
])
?
$listener
[
'events'
]
:
array
(
$listener
[
'events'
]);
foreach
(
$listener
[
'events'
]
as
$event
)
{
G2DrupalHelper
::
eventParams
(
$event
,
$listener
[
'params'
]);
}
// Register event listener
$ret
=
GalleryCoreApi
::
registerFactoryImplementationForRequest
(
'GalleryEventListener'
,
$listener
[
'class'
],
'G2Drupal'
,
$listener
[
'path'
],
'G2Drupal'
,
$listener
[
'events'
]
);
// G2 register call failed
if
(
$ret
)
{
return
$ret
;
}
}
return
false
;
}
function
eventParams
(
$event
,
$params
=
NULL
)
{
static
$storage
=
NULL
;
// Save event params
if
(
isset
(
$params
))
{
$storage
[
$event
]
=
$params
;
}
// Get event params
if
(
isset
(
$storage
[
$event
]))
{
return
$storage
[
$event
];
}
return
array
();
}
}
/**
* Class G2DrupalSimpleThemeEventListener {}.
*/
class
G2DrupalSimpleThemeEventListener
/* extends GalleryEventListener */
{
function
handleEvent
(
$event
)
{
$eventParams
=
G2DrupalHelper
::
eventParams
(
$event
->
getEventName
());
if
(
count
(
$eventParams
))
{
return
array
(
null
,
$eventParams
);
}
return
array
(
null
,
null
);
}
}
/**
* Class G2DrupalPageCacheEventListener {}.
*/
class
G2DrupalPageCacheEventListener
/* extends GalleryEventListener */
{
function
handleEvent
(
$event
)
{
// Clear the page cache, so that the updated G2 item shows correctly
cache_clear_all
();
return
array
(
null
,
null
);
}
}
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