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


PHP Event::instance方法代码示例

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


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

示例1: forge

 /**
  * Creates an instance of the Response class
  *
  * @param   string  $body    The response body
  * @param   int     $status  The HTTP response status for this response
  * @param   array   $headers Array of HTTP headers for this reponse
  *
  * @return  Response
  */
 public static function forge($body = null, $status = 200, array $headers = array())
 {
     $response = new static($body, $status, $headers);
     // fire any response created events
     \Event::instance()->has_events('response_created') and \Event::instance()->trigger('response_created', '', 'none');
     return $response;
 }
开发者ID:takawasitobi,项目名称:pembit,代码行数:16,代码来源:response.php

示例2: __construct

 public function __construct()
 {
     $this->wi3 = $this->app = APPPATH;
     //site and pagefiller location can only be known after site has been loaded by Engine or View
     //we therefore register an hook on the wi3.siteandpageloaded event
     Event::instance("wi3.init.sitearea.site.loaded")->callback(array("Wi3_pathof", "fill_site_paths"));
     Event::instance("wi3.init.page.loaded")->callback(array("Wi3_pathof", "fill_page_paths"));
 }
开发者ID:azuya,项目名称:Wi3,代码行数:8,代码来源:pathof.php

示例3: set_auto_render

 public static function set_auto_render()
 {
     //add a hook to the system.display Event. This event is called just before flushing content to the browser
     //only add the hook if we didn't set the hook already sometime earlier
     if (self::$will_already_be_auto_rendered == false) {
         //add before the page is cached, so that css files are cached as well
         Event::instance('wi3.afterexecution.addcontent.css')->callback(array('Wi3_Css', 'render_in_head'));
         self::$will_already_be_auto_rendered = true;
     }
 }
开发者ID:azuya,项目名称:Wi3,代码行数:10,代码来源:css.php

示例4: handle

 /**
  * When this type of exception isn't caught this method is called by
  * Error::exception_handler() to deal with the problem.
  */
 public function handle()
 {
     // get the exception response
     $response = $this->response();
     // fire any app shutdown events
     \Event::instance()->trigger('shutdown', '', 'none', true);
     // fire any framework shutdown events
     \Event::instance()->trigger('fuel-shutdown', '', 'none', true);
     // send the response out
     $response->send(true);
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:15,代码来源:httpexception.php

示例5: __construct

 function __construct()
 {
     //register this Plugin
     parent::__construct();
     //-------------------------------------------------------------
     // this function ensures that some Wi3 information is always sent to the client for use in javascript files (ie kohana.js)
     //
     //set up the event to pass information to the clientside
     //add this event before the javascript event, so that javascript always have this information available when they load
     Event::instance('wi3.afterexecution.addcontent.javascript.variables')->callback(array("Plugin_clientjavascriptvars", "addclientjavascriptvars"));
     //-------------------------------------------------------------
 }
开发者ID:azuya,项目名称:Wi3,代码行数:12,代码来源:clientjavascriptvars.php

示例6: execute

 public function execute($job, $data)
 {
     // Trigger price update/change event and modify data
     $data = \Event::instance('supplier')->trigger('update', $data, 'array');
     $data = call_user_func_array('\\Arr::merge_assoc', $data);
     // This is all about update
     $data = $data[0];
     // Do not update some fields
     $set = \Arr::filter_keys($data, array('external_id', 'supplier_id'), true);
     $data['updated_at'] = time();
     return Model_Price::query()->set($set)->where('external_id', $data['external_id'])->where('supplier_id', $data['supplier_id'])->update();
 }
开发者ID:indigophp,项目名称:erp-stock-extra,代码行数:12,代码来源:update.php

示例7: action_editpagetemplatesettings

 public function action_editpagetemplatesettings($pageid)
 {
     $page = Wi3::inst()->model->factory("Site_Page")->set("id", $pageid)->load();
     Wi3::inst()->sitearea->page = $page;
     // Now notify other entities that use this->page that the page has been loaded
     Event::instance("wi3.init.sitearea.page.loaded")->execute();
     // Save the template for this page
     $templatename = $_POST["pagefiller_templatename"];
     $page->templatename = $templatename;
     $page->update();
     echo json_encode(array("alert" => "template is geupdate"));
 }
开发者ID:azuya,项目名称:Wi3,代码行数:12,代码来源:ajax.php

示例8: register_callbacks

 /**
  * Method for registering callback methods for a particular action and a particular
  * @param String $action underscore separated string 'exam_add'
  * @param String $handlerClass - Name of the class in which the static callback methods are grouped per module
  * @return Notice $this
  */
 public function register_callbacks($mod, $handlerClass)
 {
     foreach ($this->_config[$mod] as $conf) {
         $action = $mod . '_' . $conf;
         $event = Event::instance($action);
         foreach (self::$MEDIA as $m) {
             $callback = $m . '_' . $conf;
             if ($this->check_preference($action, $m) && method_exists($handlerClass, $callback)) {
                 $event->callback(array($handlerClass, $callback));
             }
         }
     }
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:19,代码来源:notice.php

示例9: setpage

 public function setpage($pageorpagename)
 {
     if (is_object($pageorpagename)) {
         $this->page = $pageorpagename;
     } else {
         if (is_string($pageorpagename)) {
             $this->page = $this->getpage($pageorpagename);
         } else {
             $this->page = $this->getpage(NULL);
         }
     }
     // Now notify other entities that use this->page that the page has been loaded
     Event::instance("wi3.init.sitearea.page.loaded")->execute();
     return $this->page;
 }
开发者ID:azuya,项目名称:Wi3,代码行数:15,代码来源:sitearea.php

示例10: execute

 /**
  * Queue job
  *
  * @param	mixed		$id			Supplier id
  * @param	string		$method		Method to run
  * @param	integer		$delay
  * @param	integer		$ttr		Time limit
  * @return	null
  */
 public function execute($id, $method, $delay = 0, $ttr = 300)
 {
     // Cast id
     is_numeric($id) and $id = (int) $id;
     // Job data
     $data = array('id' => $id, 'cached' => (bool) \Cli::option('cached', \Cli::option('c', false)), 'force' => (bool) \Cli::option('force', \Cli::option('f', false)), 'method' => $method);
     // Execute job immediately
     $execute = (bool) \Cli::option('execute', \Cli::option('e', false));
     // Use Queue if available (greater performance)
     if (\Package::loaded('queue')) {
         // Create queue data
         if ($execute) {
             // Initialize logger
             $logger = clone \Log::instance();
             // Get original handler
             $handler = $logger->popHandler();
             $handler->pushProcessor(new \Monolog\Processor\PsrLogMessageProcessor());
             $logger->pushHandler($handler);
             // Console handler
             $handler = new \Monolog\Handler\ConsoleHandler(\Monolog\Logger::NOTICE);
             $formatter = new \Monolog\Formatter\LineFormatter("%message% - %context%" . PHP_EOL, "Y-m-d H:i:s");
             $handler->setFormatter($formatter);
             $logger->pushHandler($handler);
             // Add other handlers to logger through Event trigger
             \Event::instance('queue')->trigger('logger', $logger);
             $queue = array('supplier', array('driver' => 'direct', 'logger' => $logger));
         } else {
             $queue = 'supplier';
         }
         $options = array('delay' => $delay, 'ttr' => $ttr);
         // Push job and data to queue
         \Queue::push($queue, 'Indigo\\Erp\\Stock\\Job_Supplier', $data, $options);
     } else {
         try {
             $job = new Job_Supplier();
             return $job->execute(null, $data);
         } catch (\Exception $e) {
             // TODO: process exceptions
         }
     }
 }
开发者ID:indigophp,项目名称:erp-stock-extra,代码行数:50,代码来源:supplier.php

示例11: defined

<?php

defined('SYSPATH') or die('No direct access allowed.');
/**
 * @package    YurikoCMS
 * @author     Lorenzo Pisani - Zeelot
 * @copyright  (c) 2008-2009 Lorenzo Pisani
 * @license    http://yurikocms.com/license
 */
// Add all the enabled plugins to the modules
$enabled = Sprig::factory('plugin', array('status' => 'enabled'))->load(NULL, FALSE);
$modules = Kohana::modules();
// Start with the default template at the top
$array = array('default_theme' => DOCROOT . 'yurikocms/themes/default');
foreach ($enabled as $plugin) {
    $array[$plugin->name] = DOCROOT . 'yurikocms/plugins/' . $plugin->name;
}
Event::instance('yuriko_core.init.loading_plugins')->bind('modules', $modules)->execute();
Kohana::modules($array + $modules);
// Clean up
unset($modules, $enabled);
/**
 * Setup the YurikoCMS page route, this is a catch all route that any
 * custom routes need to preceed.
 */
Route::set('page', '(<uri>)', array('uri' => '.*'))->defaults(array('controller' => 'page', 'action' => 'index', 'directory' => 'yuriko'));
开发者ID:Zeelot,项目名称:yuriko_cms,代码行数:26,代码来源:init.php

示例12: action_edit

 public function action_edit()
 {
     $id = $this->request->param('id');
     if (!$id) {
         Request::current()->redirect('exam');
     }
     $submitted = FALSE;
     if ($this->request->method() === 'POST' && $this->request->post()) {
         if (Arr::get($this->request->post(), 'save') !== null) {
             $submitted = true;
             $exam = ORM::factory('exam');
             $validator = $exam->validator($this->request->post());
             $validator->bind(':to', $this->request->post('to'));
             $validator->bind(':total_marks', $this->request->post('total_marks'));
             if ($validator->check()) {
                 $from = strtotime($this->request->post('date')) + $this->request->post('from') * 60;
                 $to = strtotime($this->request->post('date')) + $this->request->post('to') * 60;
                 $exam = ORM::factory('exam', $id);
                 $exam->values($this->request->post());
                 $exam->save();
                 $event_exam = Event_Abstract::factory('exam', $exam->event_id);
                 $event_exam->set_values($this->request->post());
                 $event_exam->set_value('eventstart', $from);
                 $event_exam->set_value('eventend', $to);
                 $event_exam->update($exam->event_id);
                 // dispatch events for sending the notices and feeds (TODO to be refactored later)
                 if ($event_exam->is_rescheduled()) {
                     Event::instance('exam_reschedule')->set('exam', $exam)->execute();
                 }
                 if ($event_exam->is_relocated()) {
                     Event::instance('exam_relocate')->set('exam', $exam)->execute();
                 }
                 $feed = new Feed_Exam();
                 $feed->set_action('edit');
                 $feed->set_course_id($this->request->post('course_id'));
                 $feed->set_respective_id($exam->id);
                 $feed->set_actor_id(Auth::instance()->get_user()->id);
                 $feed->streams(array('course_id' => (int) $this->request->post('course_id')));
                 $feed->save();
                 Session::instance()->set('success', 'Exam edited successfully.');
                 Request::current()->redirect('exam');
                 exit;
             } else {
                 $this->_errors = $validator->errors('exam');
             }
         }
     }
     $exam = ORM::factory('exam', $id);
     $event = ORM::factory('event', $exam->event_id);
     $saved_data = array('name' => $exam->name, 'examgroup_id' => $exam->examgroup_id, 'course_id' => $exam->course_id, 'total_marks' => $exam->total_marks, 'passing_marks' => $exam->passing_marks, 'reminder' => $exam->reminder, 'reminder_days' => $exam->reminder_days, 'date' => date('Y-m-d', $event->eventstart), 'from' => date('H:i', $event->eventstart), 'to' => date('H:i', $event->eventend), 'room_id' => $event->room_id);
     $silder['start'] = ($event->eventstart - strtotime($saved_data['date'])) / 60;
     $silder['end'] = ($event->eventend - strtotime($saved_data['date'])) / 60;
     $form = $this->form('exam/edit/id/' . $id, $submitted, $saved_data);
     $event_id = $exam->event_id;
     $links = array('rooms' => Html::anchor('/room/', 'Add Rooms', array('target' => '_blank')));
     $view = View::factory('exam/form')->bind('form', $form)->bind('event_id', $event_id)->bind('links', $links)->bind('slider', $silder);
     Breadcrumbs::add(array('Exams', Url::site('exam')));
     Breadcrumbs::add(array('Edit', Url::site('exam/edit/id/' . $id)));
     $this->content = $view;
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:60,代码来源:exam.php

示例13: init

 public function init()
 {
     // Load session handler
     $this->session = Session::instance();
     // Set cache handler
     $this->cache = Wi3TikoCache::instance();
     // Define APPRELATIVEPATH, which is the path to the application relative to the web root
     // We can retrieve this by using the SCRIPT_NAME from the front-controller ({pathfromroot}/app/index.php), and extracting the path-from-root
     define("APPRELATIVEPATH", substr($_SERVER["SCRIPT_NAME"], 0, strpos($_SERVER["SCRIPT_NAME"], "/app/index.php")) . "/app/latest/");
     // Define document root
     // TODO: Add support for ISS (see http://www.helicron.net/php/)
     define("DOCUMENTROOT", $_SERVER["DOCUMENT_ROOT"] . "/");
     // Determine language
     $lang = Cookie::get('lang');
     if ($lang !== NULL) {
         if (!in_array($lang, array('nl-nl', 'en-us'))) {
             // Check the allowed languages, and force the default
             $lang = 'nl-nl';
         }
     } else {
         // Language not set in cookie. Get default language from i18n file.
         $i18nfiles = Kohana::find_file("config", "i18n");
         if (!empty($i18nfiles)) {
             $i18nsettings = Kohana::load($i18nfiles[0]);
             $lang = $i18nsettings["lang"];
         } else {
             $lang = 'nl-nl';
             // Fall back to default
         }
         // Save loaded language in cookie
         Cookie::set('lang', $lang);
     }
     // Set the target language
     i18n::lang($lang);
     // Set the source language to some non-existing language to prevent Kohana skipping translation lookup if source and target language are identical
     i18n::$source = "bb-bb";
     // See http://unicode.org/cldr/utility/languageid.jsp?a=bb&l=en for valid tags
     // Load wi3-kohana-specific functions
     $this->kohana = new Wi3_Kohana();
     // XSS Clean all user input!
     // TODO: only do this if the user is not an admin...
     $this->originalpost = $_POST;
     // Save original $_POST
     foreach ($_POST as $key => $val) {
         $_POST[$key] = Security::xss_clean($val);
     }
     $this->originalget = $_GET;
     // Save original $_GET
     foreach ($_GET as $key => $val) {
         $_GET[$key] = Security::xss_clean($val);
     }
     // Load some Wi3 classes
     // Load a global database configuration
     $this->database = new Wi3_Database();
     // Helper functions to create databases etc
     $this->globaldatabase = Wi3_Database::instance("global");
     Event::instance("wi3.init.globaldatabase.loaded")->execute();
     // Get routing, url and path information
     // These classes in turn add a callback to the wi3.init.site.loaded Event, after which they will update with path and urls to the site
     $this->routing = Wi3_Routing::instance();
     Event::instance("wi3.init.routing.loaded")->execute();
     $this->pathof = Wi3_Pathof::instance();
     Event::instance("wi3.init.pathof.loaded")->execute();
     $this->urlof = Wi3_Urlof::instance();
     Event::instance("wi3.init.urlof.loaded")->execute();
     // Load CSS and Javascript 'injectors'
     $this->css = Wi3_Css::instance();
     $this->javascript = Wi3_Javascript::instance();
     // Instantiate the Model class, that is an interface to the 'factory' method for any underlying model-systems
     $this->model = Wi3_Model::inst();
     Event::instance("wi3.init.model.loaded")->execute();
     // Instantiate the form-builder
     $this->formbuilder = Wi3_Formbuilder::inst();
     Event::instance("wi3.init.formbuilder.loaded")->execute();
     // Now find out what is the scope of this request
     // It most often is a site-scope (i.e. the admin or view of a site), but might also be a global scope (i.e. superadmin)
     // This depends on the controller.
     // Pagefiller-specific controllers are always for the the sitearea
     $this->scope = (substr(Request::instance()->controller, 0, 9) == "adminarea" or substr(Request::instance()->controller, 0, 10) == "pagefiller" or Request::instance()->controller == "sitearea") ? "site" : "global";
     if ($this->scope == "site") {
         $this->sitearea = Wi3_Sitearea::inst();
         // Find out what site we are working with
         // Both the admin controller and the site controller need to know this in order to work properly
         // Find the site by apache 'sitename' variable
         if (isset($_SERVER['REDIRECT_SITENAME'])) {
             $sitename = $_SERVER['REDIRECT_SITENAME'];
             // With correct loading, $_SERVER['REDIRECT_SITENAME'] should always be present, as it is set in the vhosts .htaccess that redirect here
             // Global site is the site in the global space, i.e. the Site model in the 'list of sites' that is always accesible
             // ( In the per-site database, there can only exist one Site model )
             $this->sitearea->globalsite = $this->model->factory("site")->set('name', $sitename)->load();
             Event::instance("wi3.init.sitearea.globalsite.loaded")->execute();
             $this->sitearea->site = $this->sitearea->globalsite;
             // This site instance will be replaced by the local user site. The ->name will be added to that local site, since it does not store that in the local db
         }
         // If the sitename not present, the page request came here via some illegal method.
         // If the site was not loaded correctly or is not active, we cannot show the site either
         if (!isset($_SERVER['REDIRECT_SITENAME']) or empty($sitename) or !$this->sitearea->globalsite->loaded() or $this->sitearea->globalsite->active == FALSE) {
             // Site does not exist. Quit.
             throw new Kohana_Exception("site does not exist");
         }
//.........这里部分代码省略.........
开发者ID:azuya,项目名称:Wi3,代码行数:101,代码来源:wi3.php

示例14: register_shutdown_function

}
require VENDORPATH . 'autoload.php';
/**
 * Register all the error/shutdown handlers
 */
register_shutdown_function(function () {
    // reset the autoloader
    \Autoloader::_reset();
    // make sure we're having an output filter so we can display errors
    // occuring before the main config file is loaded
    \Config::get('security.output_filter', null) or \Config::set('security.output_filter', 'Security::htmlentities');
    try {
        // fire any app shutdown events
        \Event::instance()->trigger('shutdown', '', 'none', true);
        // fire any framework shutdown events
        \Event::instance()->trigger('fuel-shutdown', '', 'none', true);
    } catch (\Exception $e) {
        if (\Fuel::$is_cli) {
            \Cli::error("Error: " . $e->getMessage() . " in " . $e->getFile() . " on " . $e->getLine());
            \Cli::beep();
            exit(1);
        }
    }
    return \Error::shutdown_handler();
});
set_exception_handler(function (\Exception $e) {
    // reset the autoloader
    \Autoloader::_reset();
    // deal with PHP bugs #42098/#54054
    if (!class_exists('Error')) {
        include COREPATH . 'classes/error.php';
开发者ID:marietta-adachi,项目名称:website,代码行数:31,代码来源:bootstrap.php

示例15: Kohana_Log_File

 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 */
Kohana::init(array('base_url' => '/', 'index_file' => FALSE));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Kohana_Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array(MODPATH . 'zeelot-event', MODPATH . 'zeelot-orm', MODPATH . 'yuriko_dev', MODPATH . 'yuriko_admin', MODPATH . 'assets', MODPATH . 'yuriko_core'));
/**
 * Execute the main request using PATH_INFO. If no URI source is specified,
 * the URI will be automatically detected.
 */
$request = Request::instance();
Event::run('yuriko.bootstrap.request.pre_execute', $request);
$request = $request->execute();
Event::instance('yuriko.bootstrap.request.pre_send_headers', $request);
$request = $request->send_headers();
Event::instance('yuriko.bootstrap.request.pre_render', $request);
echo $request->response;
// Clean up
unset($request);
开发者ID:Zeelot,项目名称:yuriko_cms,代码行数:31,代码来源:bootstrap.php


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