Created
June 22, 2017 10:27
-
-
Save michael-e/3d755e43a0b3fcfe9ab697f8c1fd444c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Extension driver | |
* | |
* @package Lalala | |
* @author Michael E. | |
*/ | |
class extension_lalala extends Extension | |
{ | |
/** | |
* Delegates and callbacks | |
* | |
* @return array | |
*/ | |
public function getSubscribedDelegates() | |
{ | |
return array( | |
array( | |
'page' => '/blueprints/events/new/', | |
'delegate' => 'AppendEventFilter', | |
'callback' => 'appendEventFilter' | |
), | |
array( | |
'page' => '/blueprints/events/edit/', | |
'delegate' => 'AppendEventFilter', | |
'callback' => 'appendEventFilter' | |
), | |
array( | |
'page' => '/frontend/', | |
'delegate' => 'EventPreSaveFilter', | |
'callback' => 'eventPreSaveFilter' | |
), | |
array( | |
'page' => '/frontend/', | |
'delegate' => 'EventPostSaveFilter', | |
'callback' => 'eventPostSaveFilter' | |
), | |
array( | |
'page' => '/frontend/', | |
'delegate' => 'EventFinalSaveFilter', | |
'callback' => 'eventFinalSaveFilter' | |
), | |
); | |
} | |
/** | |
* Append event filters to event pages | |
* | |
* @param string $context | |
* @return void | |
*/ | |
public function appendEventFilter($context) | |
{ | |
$selected = !is_array($context['selected']) ? array() : $context['selected']; | |
$context['options'][] = array( | |
'my-filter', | |
in_array('my-filter', $selected), | |
__('My Filter') | |
); | |
$context['options'][] = array( | |
'my-filter-2', | |
in_array('my-filter-2', $selected), | |
__('My Filter 2') | |
); | |
$context['options'][] = array( | |
'my-filter-3', | |
in_array('my-filter-3', $selected), | |
__('My Filter 3') | |
); | |
} | |
/** | |
* eventPreSaveFilter | |
* | |
* @uses EventPreSaveFilter | |
* @param string $context | |
* @return void | |
*/ | |
public function eventPreSaveFilter($context) | |
{ | |
if (in_array('my-filter-2', $context['event']->eParamFILTERS)) { | |
// do something | |
} | |
} | |
/** | |
* eventPostSaveFilter | |
* | |
* @uses EventPostSaveFilter | |
* @param string $context | |
* @return void | |
*/ | |
public function eventPostSaveFilter($context) | |
{ | |
if (in_array('my-filter-3', $context['event']->eParamFILTERS)) { | |
// do something | |
} | |
} | |
/** | |
* eventFinalSaveFilter | |
* | |
* @uses EventFinalSaveFilter | |
* @param string $context | |
* @return void | |
*/ | |
public function eventFinalSaveFilter($context) | |
{ | |
if (in_array('my-filter', $context['event']->eParamFILTERS)) { | |
// do something | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment