本文整理汇总了PHP中Hooks::addHook方法的典型用法代码示例。如果您正苦于以下问题:PHP Hooks::addHook方法的具体用法?PHP Hooks::addHook怎么用?PHP Hooks::addHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hooks
的用法示例。
在下文中一共展示了Hooks::addHook方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
// Define hooks
$updateHook = array('class' => 'Mutation', 'function' => 'mutUpdate', 'filename' => 'Mutation.php', 'filepath' => 'extensions/Mutation', 'params' => array('$fullRelationSignature', '$stableAtom', '$stableConcept', '$modifiedAtom', '$modifiedConcept', '$source'));
$insertHook = array('class' => 'Mutation', 'function' => 'mutInsert', 'filename' => 'Mutation.php', 'filepath' => 'extensions/Mutation', 'params' => array('$fullRelationSignature', '$stableAtom', '$stableConcept', '$modifiedAtom', '$modifiedConcept', '$source'));
$deleteHook = array('class' => 'Mutation', 'function' => 'mutDelete', 'filename' => 'Mutation.php', 'filepath' => 'extensions/Mutation', 'params' => array('$fullRelationSignature', '$stableAtom', '$stableConcept', '$modifiedAtom', '$modifiedConcept', '$source'));
Hooks::addHook('postDatabaseUpdate', $updateHook);
Hooks::addHook('postDatabaseInsert', $insertHook);
Hooks::addHook('postDatabaseDelete', $deleteHook);
class Mutation
{
public static function mutUpdate($fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
{
$operation = 'Changed';
Mutation::saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source);
}
public static function mutInsert($fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
{
$operation = 'Added';
Mutation::saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source);
}
public static function mutDelete($fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
{
$operation = 'Removed';
Mutation::saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source);
}
private static function saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
{
if (array_key_exists($fullRelationSignature, Config::get('mutationConcepts', 'MutationExtension'))) {
Notifications::addLog("Save mutation on '{$fullRelationSignature}' (editUpdate)", 'Mutation');
$mutConcept = Config::get('mutationConcepts', 'MutationExtension')[$fullRelationSignature];
示例2: array
<?php
require_once __DIR__ . '/lib/class.phpmailer.php';
// Define hooks
$hook = array('class' => 'EmailNotifications', 'function' => 'pushNotificationCache', 'filename' => 'Email.php', 'filepath' => 'extensions/Messaging', 'params' => array());
Hooks::addHook('postDatabaseCommitTransaction', $hook);
$hook = array('class' => 'EmailNotifications', 'function' => 'clearNotificationCache', 'filename' => 'Email.php', 'filepath' => 'extensions/Messaging', 'params' => array());
Hooks::addHook('postDatabaseRollbackTransaction', $hook);
class EmailNotifications
{
private static $notifications = array();
public static function execEnginePushNotificationOnCommit($userKeys, $message, $title = null, $url = null, $urltitle = null)
{
Notifications::addLog('Email[execEnginePushNotificationOnCommit' . ']; $userKeys=[' . $userKeys . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']', 'MESSAGING');
if ($userKeys == '_NULL') {
$userKeys = array(null);
} else {
$userKeys = explode('_AND', $userKeys);
}
self::pushNotificationOnCommit($userKeys, $message, $title, $url, $urltitle);
}
public static function pushNotificationOnCommit($userKeys, $message, $title = null, $url = null, $urltitle = null)
{
Notifications::addLog('Email[pushNotificationOnCommit' . ']; $userKeys=[' . $userKeys . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']', 'MESSAGING');
foreach ($userKeys as $userKey) {
if (!is_null($userKey)) {
self::$notifications[] = array('userKey' => $userKey, 'message' => $message, 'title' => $title, 'url' => $url, 'urltitle' => $urltitle);
}
}
// Send same notification to users in 'alwaysNotifyUsers' config
foreach ((array) Config::get('alwaysNotifyUsers', 'msg_email') as $notifyUser) {
示例3: array
<?php
// Define hooks
$hook1 = array('class' => 'ExecEngine', 'function' => 'run', 'filename' => 'ExecEngine.php', 'filepath' => 'extensions/ExecEngine', 'params' => array());
Hooks::addHook('preDatabaseCloseTransaction', $hook1);
$hook2 = array('class' => 'ExecEngine', 'function' => 'run', 'filename' => 'ExecEngine.php', 'filepath' => 'extensions/ExecEngine', 'params' => array(true));
Hooks::addHook('postDatabaseReinstallDB', $hook2);
// UI
$GLOBALS['navBar']['refreshMenu'][] = array('url' => 'extensions/ExecEngine/ui/views/MenuItem.html');
AngularApp::addJS('extensions/ExecEngine/ui/js/ExecEngine.js');
// Config (can be overwritten in localSettings.php)
Config::set('execEngineRoleName', 'execEngine', 'ExecEngine');
Config::set('autoRerun', 'execEngine', true);
Config::set('maxRunCount', 'execEngine', 10);
class ExecEngine
{
private static $roleName;
public static $doRun = true;
public static $autoRerun;
public static $runCount;
public static function run($allRules = false)
{
$database = Database::singleton();
Notifications::addLog('------------------------- EXEC ENGINE STARTED -------------------------', 'ExecEngine');
// Load the execEngine functions (security hazard :P)
$files = getDirectoryList(__DIR__ . '/functions');
foreach ($files as $file) {
if (substr($file, -3) !== 'php') {
continue;
}
require_once __DIR__ . '/functions/' . $file;