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


PHP Events::add_listener方法代码示例

本文整理汇总了PHP中Events::add_listener方法的典型用法代码示例。如果您正苦于以下问题:PHP Events::add_listener方法的具体用法?PHP Events::add_listener怎么用?PHP Events::add_listener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Events的用法示例。


在下文中一共展示了Events::add_listener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     $self = $this;
     Events::add_listener('ws.response', function ($resp) use($self) {
         $self->dump($resp);
     });
 }
开发者ID:techart,项目名称:tao,代码行数:7,代码来源:FirePHP.php

示例2: init_module_cache

 protected static function init_module_cache()
 {
     if (Core::option('modules_cache')) {
         Core::load('Events');
         $modules = array();
         if (is_file(self::option('modules_cache_path')) && ($inc = (include_once self::option('modules_cache_path'))) && is_array($inc)) {
             self::$cached_modules = $inc;
         } else {
             self::$cached_modules = Core::find_all_modules();
             self::$flush_modules_cahce = true;
         }
         Events::add_listener('ws.response', array('Core', 'flush_modules_cache'));
     }
 }
开发者ID:techart,项目名称:tao,代码行数:14,代码来源:Core.php

示例3: add_command

 /**
  * Добавляет комманду в очередь
  *
  * @param string $chapter
  * @param string $command
  */
 static function add_command()
 {
     $args = func_get_args();
     $chapter = trim($args[0]);
     $method = trim($args[1]);
     array_splice($args, 0, 2);
     if (!isset(self::$commands[$chapter])) {
         self::$commands[$chapter] = array();
     }
     self::$commands[$chapter][] = array('method' => $method, 'args' => $args);
     Events::add_listener(self::event_name_for_command($chapter, $method), $args[0]);
 }
开发者ID:techart,项目名称:tao,代码行数:18,代码来源:CMS.php

示例4: process_component_config

 protected function process_component_config($config_name = 'component')
 {
     $config = $this->config($config_name);
     // TODO: split to methods
     if (isset($config->admin_menu)) {
         $menu = (object) $config->admin_menu;
         CMS_Admin::menu($menu->caption, $menu->path, $menu->items, $menu->icon);
     }
     if (isset($config->templates)) {
         $helpers = $config->templates['helpers'];
         Templates_HTML::use_helpers($helpers);
     }
     if (isset($config->field_types)) {
         $types = $config->field_types;
         foreach ($types as $name => $class) {
             CMS::field_type($name, $class);
         }
     }
     if (isset($config->commands)) {
         $commands = $config->commands;
         foreach ($commands as $chapter => $data) {
             $args = array_merge(array($chapter, $data['name'], $data['callback']), isset($data['args']) ? $data['args'] : array());
             call_user_func_array(array('CMS', 'add_command'), $args);
         }
     }
     if (isset($config->insertions)) {
         $insertions = $config->insertions;
         foreach ($insertions as $ins) {
             $args = array_merge(array($ins['class']), $ins['names']);
             call_user_func_array(array('CMS', 'register_insertions'), $args);
         }
     }
     if (isset($config->events)) {
         $events = $config->events;
         foreach ($events as $name => $callback) {
             Events::add_listener($name, $callback);
         }
     }
     if (isset($config->orm)) {
         $orm = $config->orm;
         foreach ($orm as $name => $class) {
             CMS::orm()->submapper($name, $class);
         }
     }
 }
开发者ID:techart,项目名称:tao,代码行数:45,代码来源:Component.php

示例5: form_fields

 protected function form_fields($action)
 {
     $fields = array();
     if ($action == 'list') {
     } elseif ($action == 'add') {
         $fields = array();
         if ($this->is_admin()) {
             $fields['_name'] = array('type' => 'input', 'style' => 'width: 200px;', 'tab' => 'config', 'caption' => CMS::lang('%LANG{en}Name%LANG{ru}Мнемокод'));
             if (isset($_GET['chapter'])) {
                 $pchapter = trim($_GET['chapter']);
                 if ($pchapter != '') {
                     $pchapter .= '.';
                 }
                 $fields['_name']['obligatory_prefix'] = $pchapter;
                 $fields['_type'] = array('type' => 'select', 'items' => CMS::vars()->types_list(), 'caption' => CMS::lang('%LANG{en}Type%LANG{ru}Тип'), 'tab' => 'config');
             }
         }
     } else {
         $var = $this->edit_item;
         if (!$var->is_dir()) {
             $fields = array('vname' => array('type' => 'subheader', 'tab' => 'default', 'caption' => $var->id() . ': ' . $var->title()));
             $fields += $var->fields($var);
         }
     }
     if ($this->is_admin()) {
         $fields['_title'] = array('type' => 'input', 'style' => 'width: 100%;', 'tab' => 'config', 'caption' => CMS::lang('%LANG{en}Title%LANG{ru}Название'));
         $fields['_access'] = array('type' => 'input', 'style' => 'width: 200px;', 'tab' => 'config', 'caption' => CMS::lang('%LANG{en}Access%LANG{ru}Доступ'));
         $fields['_delsubheader'] = array('type' => 'subheader', 'style' => 'width: 200px;', 'tab' => 'config', 'caption' => CMS::lang(' '));
         static $ev = false;
         if (!$ev) {
             Events::add_listener('cms.fields.admin.mainform._delsubheader.after', function ($parms) {
                 $var = $parms['item'];
                 $url = WS::env()->urls->adminvars->delete_url($var->name());
                 if ($url == '#') {
                     return;
                 }
                 $title = 'Удалить';
                 $confirm = 'Вы уверены?';
                 print "<a href='{$url}' onClick='return confirm(\"{$confirm}\")' class='icon-button'><em style='background-image: url(/tao/images/del.png);'>{$title}</em></a>";
             });
             $ev = true;
         }
     }
     return $fields;
 }
开发者ID:techart,项目名称:tao,代码行数:45,代码来源:Controller.php


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