当前位置: 首页>>代码示例>>PHP>>正文


PHP Hooks::addHook方法代码示例

本文整理汇总了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];
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:31,代码来源:Mutation.php

示例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) {
开发者ID:4ZP6Capstone2015,项目名称:ampersand-models,代码行数:31,代码来源:Email.php

示例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;
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:31,代码来源:ExecEngine.php


注:本文中的Hooks::addHook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。