本文整理汇总了PHP中Events::extendPageType方法的典型用法代码示例。如果您正苦于以下问题:PHP Events::extendPageType方法的具体用法?PHP Events::extendPageType怎么用?PHP Events::extendPageType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Events
的用法示例。
在下文中一共展示了Events::extendPageType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extendPageType
/**
* When passed an "event" as a string, a user-defined method will be run INSIDE this page's controller
* whenever an event takes place. The name/location of this event is not customizable. If you want more
* customization, used extend() below.
*/
public static function extendPageType($ctHandle, $event = false, $params = array()) {
Events::enableEvents();
if ($event == false) {
// then we're registering ALL the page type events for this particular page type
Events::extendPageType($ctHandle, 'on_page_add', $params);
Events::extendPageType($ctHandle, 'on_page_update', $params);
Events::extendPageType($ctHandle, 'on_page_duplicate', $params);
Events::extendPageType($ctHandle, 'on_page_move', $params);
Events::extendPageType($ctHandle, 'on_page_view', $params);
Events::extendPageType($ctHandle, 'on_page_version_approve', $params);
Events::extendPageType($ctHandle, 'on_page_delete', $params);
} else {
$ce = Events::getInstance();
$class = Object::camelcase($ctHandle) . 'PageTypeController';
$method = $event;
$filename = Loader::pageTypeControllerPath($ctHandle);
$ce->registeredEvents[$event][] = array(
Events::EVENT_TYPE_PAGETYPE,
$class,
$method,
$filename,
$params
);
}
}
示例2: on_start
public function on_start()
{
// stuff here will run on every page request before anything else.
// if full page cache is turned on, this will not run on cached pages
//
// events are the most common use case
// for more details on events, check out the documentation here:
// http://www.concrete5.org/documentation/developers/system/events
//
Events::extendPageType('boilerplate', 'on_page_add');
$html = Loader::helper("html");
$v = View::getInstance();
$v->addHeaderItem($html->css("boilerplate.css", "c5_boilerplate"));
$v->addHeaderItem($html->javascript("boilerplate.js", "c5_boilerplate"));
}
示例3:
<?php
Events::extendPageType('walk', 'on_page_update');
// Setup user when created
Events::extend('on_user_add', '\\JanesWalk\\Models\\Users\\WalkLeader', 'setupUserJoinInfo', 'models/users/WalkLeader.php');