当前位置: 首页>>代码示例>>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;未经允许,请勿转载。