本文整理汇总了PHP中PerchAPI::on方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchAPI::on方法的具体用法?PHP PerchAPI::on怎么用?PHP PerchAPI::on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchAPI
的用法示例。
在下文中一共展示了PerchAPI::on方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PerchAPI
<?php
if (PERCH_RUNWAY) {
$varnish_config = PerchConfig::get('varnish');
if ($varnish_config && $varnish_config['enabled']) {
PerchUtil::debug("Varnish enavled!");
$API = new PerchAPI(1.0, 'perch_varnish');
$API->on('page.publish', function ($Event) use($API) {
$PerchVarnish = new PerchVarnish($API);
$PerchVarnish->purge($Event->subject);
});
spl_autoload_register(function ($class_name) {
if (strpos($class_name, 'PerchVarnish') === 0) {
include 'PerchVarnish.class.php';
return true;
}
if ($class_name == 'PerchPageRoutes') {
include PERCH_CORE . '/runway/PerchPageRoutes.class.php';
include PERCH_CORE . '/runway/PerchPageRoute.class.php';
}
return false;
});
}
}
示例2: perch_members_init
}
if (!defined('PERCH_MEMBERS_COOKIE')) {
define('PERCH_MEMBERS_COOKIE', 'p_m');
}
spl_autoload_register(function ($class_name) {
if (strpos($class_name, 'PerchMembers') === 0) {
include __DIR__ . '/' . $class_name . '.class.php';
return true;
}
return false;
});
PerchSystem::register_template_handler('PerchMembers_Template');
if (PERCH_RUNWAY) {
$members_init = function () {
$API = new PerchAPI(1.0, 'perch_members');
$API->on('page.loaded', 'perch_members_init');
};
$members_init();
} else {
perch_members_init();
}
function perch_members_init()
{
perch_members_recover_session();
perch_members_check_page_access();
}
function perch_members_form_handler($SubmittedForm)
{
if ($SubmittedForm->validate()) {
$API = new PerchAPI(1.0, 'perch_members');
switch ($SubmittedForm->formID) {
示例3: PerchAPI
include_once 'JwActivityLog_Actions.class.php';
include_once 'JwActivityLog_Action.class.php';
$API = new PerchAPI(1.0, 'jw_activity_log');
$Actions = new JwActivityLog_Actions($API);
/**
* Regions
*/
$API->on('region.add_item', function (PerchSystemEvent $Event) use($Actions) {
$data = array();
$user = $Event->user->to_array();
$subject = $Event->subject->to_array();
$data['actionKey'] = $Event->event;
$data['userAccountID'] = $user['userID'];
$data['userAccountData'] = $user;
$data['resourceType'] = LOG_REGION_TYPE;
$data['resourceID'] = $subject['regionID'];
$data['resourceTitle'] = $subject['regionKey'];
$data['resourceModification'] = $subject['regionHTML'];
// Save
$Actions->create($data);
// Debug
PerchUtil::debug('Inserting new action log data:');
PerchUtil::debug($data);
});
$API->on('region.publish', function (PerchSystemEvent $Event) use($Actions) {
$data = array();
$user = $Event->user->to_array();
$subject = $Event->subject->to_array();
$data['actionKey'] = $Event->event;
$data['userAccountID'] = $user['userID'];
$data['userAccountData'] = $user;
示例4: perch_blog_form_handler
<?php
spl_autoload_register(function ($class_name) {
if (strpos($class_name, 'PerchBlog') === 0) {
include __DIR__ . '/' . $class_name . '.class.php';
return true;
}
return false;
});
PerchSystem::register_search_handler('PerchBlog_SearchHandler');
if (PERCH_RUNWAY) {
$blog_init = function () {
$API = new PerchAPI(1.0, 'perch_blog');
$API->on('page.loaded', 'perch_blog_check_preview');
};
$blog_init();
} else {
perch_blog_check_preview();
}
function perch_blog_form_handler($SubmittedForm)
{
if ($SubmittedForm->formID == 'comment' && $SubmittedForm->validate()) {
$API = new PerchAPI(1.0, 'perch_blog');
$Comments = new PerchBlog_Comments($API);
$Comments->receive_new_comment($SubmittedForm);
}
$Perch = Perch::fetch();
PerchUtil::debug($Perch->get_form_errors($SubmittedForm->formID));
}
function perch_blog_recent_posts($count = 10, $return_or_opts = false, $return = false)
{