當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Hook::init方法代碼示例

本文整理匯總了PHP中Hook::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP Hook::init方法的具體用法?PHP Hook::init怎麽用?PHP Hook::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Hook的用法示例。


在下文中一共展示了Hook::init方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * 運行框架
  */
 public static function run()
 {
     try {
         self::init();
         Hook::init(BASE_PATH);
         Hook::listen('appBegin');
         Hook::listen('routeParseUrl', array(Config::get('REWRITE_RULE'), Config::get('REWRITE_ON')));
         //default route
         if (!defined('APP_NAME') || !defined('CONTROLLER_NAME') || !defined('ACTION_NAME')) {
             Route::parseUrl(Config::get('REWRITE_RULE'), Config::get('REWRITE_ON'));
         }
         //execute action
         $controller = '\\app\\' . APP_NAME . '\\controller\\' . CONTROLLER_NAME . 'Controller';
         $action = ACTION_NAME;
         if (!class_exists($controller)) {
             throw new \Exception("Controller '{$controller}' not found", 404);
         }
         $obj = new $controller();
         if (!method_exists($obj, $action)) {
             throw new \Exception("Action '{$controller}::{$action}()' not found", 404);
         }
         Hook::listen('actionBefore', array($obj, $action));
         $obj->{$action}();
         Hook::listen('actionAfter', array($obj, $action));
     } catch (\Exception $e) {
         Hook::listen('appError', array($e));
     }
     Hook::listen('appEnd');
 }
開發者ID:lerre,項目名稱:canphp,代碼行數:32,代碼來源:App.php

示例2: getenv

/* config */
$dbUrl = getenv('DB_URL');
if ($dbUrl) {
    $config->parse($dbUrl);
} else {
    $config->set('dbType', 'sqlite');
    $config->set('dbHost', ':memory:');
}
/* database */
Db::construct($config);
Db::init();
/* installer */
$installer = new Installer($config);
$installer->init();
$installer->rawDrop();
$installer->rawCreate();
$installer->insertData(['adminName' => 'Test', 'adminUser' => 'test', 'adminPassword' => 'test', 'adminEmail' => 'test@test.com']);
/* test user */
Db::forTablePrefix('users')->whereIdIs(1)->findOne()->set(['password' => 'test', 'description' => 'test', 'language' => 'en'])->save();
/* test module */
if (is_dir('modules/TestDummy')) {
    $testDummy = new Modules\TestDummy\TestDummy();
    $testDummy->install();
}
/* language */
$language = Language::getInstance();
$language->init();
/* hook */
Hook::construct($registry);
Hook::init();
開發者ID:redaxmedia,項目名稱:redaxscript,代碼行數:30,代碼來源:bootstrap.php

示例3:

<?php

namespace Redaxscript;

/* include as needed */
include_once 'includes/Autoloader.php';
include_once 'stubs/hook_function.php';
include_once 'stubs/hook_method.php';
include_once 'TestCase.php';
/* init */
Autoloader::init();
Request::init();
/* set config */
Config::set('type', 'mysql');
Config::set('host', 'redaxscript.com');
Config::set('name', 'd01ae38a');
Config::set('user', 'd01ae38a');
Config::set('password', 'travis');
/* registry and config */
$registry = Registry::getInstance();
$config = Config::getInstance();
/* database and hook */
Db::init($config);
Hook::init($registry);
/* language */
$language = Language::getInstance();
$language::init('en');
開發者ID:ITw3,項目名稱:redaxscript,代碼行數:27,代碼來源:Bootstrap.php

示例4: function

Hook::init('init[].node_content', function () {
    if (!cache('node__content_field')) {
        Yii::import("application.modules.node.models.NodeContent");
        Yii::import("application.modules.node.models.NodeField");
        $rows = NodeContent::model()->findAll(array('order' => 'sort desc,id desc'));
        if ($rows) {
            foreach ($rows as $v) {
                $data[$v->id] = $v->name;
                $data2[$v->id] = array($v->name, $v->discription);
                $id = $v->id;
                foreach ($v->fields as $f) {
                    $field[$id]['id'] = $f->id;
                    $field[$id]['name'] = $f->name;
                    $field[$id]['type'] = $f->type;
                    $field[$id]['widget'] = $f->widget;
                    $field_table[$v->name][$f->name] = $f;
                    $d[$v->name]['id'] = 'id';
                    $d[$v->name]['vid'] = 'vid';
                    $d[$v->name]['display'] = 'display';
                    $d[$v->name]['uid'] = 'uid';
                    $d[$v->name]['uuid'] = 'uuid';
                    $d[$v->name]['language_id'] = 'language_id';
                    $d[$v->name]['created'] = 'created';
                    $d[$v->name]['updated'] = 'updated';
                    $d[$v->name][$f->name] = $f->name;
                }
            }
            cache('node__content', $data);
            cache('node__contentfull', $data2);
            cache('node__field', $field);
            cache('node__content_field', $d);
            cache('node__field_table', $field_table);
        }
    }
});
開發者ID:hiproz,項目名稱:mincms,代碼行數:35,代碼來源:function.php

示例5: hook

 /**
  * 對字段加載HOOK,改變relation 的值
  */
 function hook()
 {
     Hook::init('model.NodeField_afterSave', function ($model) {
         CDB()->update('node_field', array('relation' => "attachments." . $model->name), 'id=:id', array(':id' => $model->id));
     });
 }
開發者ID:hiproz,項目名稱:mincms,代碼行數:9,代碼來源:file.php


注:本文中的Hook::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。