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


PHP Event::trigger方法代码示例

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


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

示例1: logout

 static function logout()
 {
     $token = self::token();
     Event::trigger('auth.logout', $token);
     session_unset();
     Event::trigger('auth.post_logout', $token);
 }
开发者ID:pihizi,项目名称:qf,代码行数:7,代码来源:auth.php

示例2: displayTask

 /**
  * Pub view for project files, notes etc.
  *
  * @return     void
  */
 public function displayTask()
 {
     require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'publicstamp.php';
     // Incoming
     $stamp = Request::getVar('s', '');
     // Clean up stamp value (only numbers and letters)
     $regex = array('/[^a-zA-Z0-9]/');
     $stamp = preg_replace($regex, '', $stamp);
     // Load item reference
     $objSt = new Tables\Stamp($this->database);
     if (!$stamp || !$objSt->loadItem($stamp)) {
         App::redirect(Route::url('index.php?option=' . $this->_option));
         return;
     }
     // Can only serve files or notes at the moment
     if (!in_array($objSt->type, array('files', 'notes', 'publications'))) {
         App::redirect(Route::url('index.php?option=' . $this->_option));
         return;
     }
     // Serve requested item
     $content = Event::trigger('projects.serve', array($objSt->type, $objSt->projectid, $objSt->reference));
     // Output
     foreach ($content as $out) {
         if ($out) {
             return $out;
         }
     }
     // Redirect if nothing fetched
     App::redirect(Route::url('index.php?option=' . $this->_option));
     return;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:36,代码来源:get.php

示例3: getItem

 /**
  * Method to get a single record.
  *
  * @param   integer  $pk  The id of the primary key.
  *
  * @return  mixed  Object on success, false on failure.
  *
  * @since   2.5
  */
 public function getItem($pk = null)
 {
     $result = parent::getItem($pk);
     // Trigger the data preparation event.
     $results = Event::trigger('user.onContentPrepareData', array('com_users.note', $result));
     return $result;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:16,代码来源:note.php

示例4: onResources

 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param   object  $resource  Current resource
  * @param   string  $option    Name of the component
  * @param   array   $areas     Active area(s)
  * @param   string  $rtrn      Data to be returned
  * @return  array
  */
 public function onResources($model, $option, $areas, $rtrn = 'all')
 {
     if (!$model->type->params->get('plg_share')) {
         return;
     }
     $arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
     $resource = $model->resource;
     $sef = Route::url('index.php?option=com_resources&' . ($resource->alias ? 'alias=' . $resource->alias : 'id=' . $resource->id));
     $url = Request::base() . ltrim($sef, '/');
     // Incoming action
     $sharewith = Request::getVar('sharewith', '');
     if ($sharewith) {
         // Log the activity
         if (!User::isGuest()) {
             Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'resource', 'scope_id' => $resource->id, 'description' => Lang::txt('PLG_RESOURCES_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $resource->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $resource->title, 'url' => $sef)], 'recipients' => [['resource', $resource->id], ['user', $resource->created_by], ['user', User::get('id')]]]);
         }
         // Email form
         if ($sharewith == 'email') {
             // Instantiate a view
             $view = $this->view('email', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
             // Return the output
             $view->display();
             exit;
         }
         return $this->share($sharewith, $url, $resource);
     }
     // Build the HTML meant for the "about" tab's metadata overview
     if ($rtrn == 'all' || $rtrn == 'metadata') {
         // Instantiate a view
         $view = $this->view('default', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
         // Return the output
         $arr['metadata'] = $view->loadTemplate();
     }
     return $arr;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:44,代码来源:share.php

示例5: getBasedOnPeriodAndCategory

 /**
  * Get what's new based on a time period and category
  *
  * @param   string  $period   Time period to return results for
  * @param   string  $category Category to filter by
  * @param   integer $limit    Limit number of results returned
  * @return  array
  */
 public static function getBasedOnPeriodAndCategory($period = 'month', $category = '', $limit = 0)
 {
     // parse the time period for use by the whats new plugins
     $p = self::parseTimePeriod($period);
     // get the search areas
     $areas = array();
     $search_areas = \Event::trigger('whatsnew.onWhatsNewAreas');
     foreach ($search_areas as $search_area) {
         $areas = array_merge($areas, $search_area);
     }
     // get the results
     $config = array($p, $limit, 0, $areas);
     $results = \Event::trigger('onWhatsNew', $config);
     $new = array();
     $i = 0;
     foreach ($areas as $k => $area) {
         $new[$i]['alias'] = $k;
         $new[$i]['title'] = $k == 'resources' ? 'Resources' : $area;
         $new[$i]['results'] = $results[$i];
         $i++;
     }
     // check to see if we only want to return results for a certain category
     if ($category != '') {
         $index = 0;
         foreach ($areas as $k => $area) {
             if ($category == $k) {
                 return $new[$index];
             }
             $index++;
         }
     }
     return $new;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:41,代码来源:finder.php

示例6: handle

 public function handle()
 {
     require_once PATH_CORE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Memberships.php';
     $ms = new \Components\Storefront\Models\Memberships();
     /* NEW
     		$subscription = StorefrontModelMemberships::getSubscriptionObject($this->type, $this->pId, $this->uId);
     		// Get the expiration for the current subscription (if any)
     		$currentExpiration = $subscription->getExpiration();
     		*/
     // Get current registration
     $membership = $ms->getMembershipInfo($this->crtId, $this->item['info']->pId);
     $expiration = $membership['crtmExpires'];
     /* Add the user to the corresponding user access group (pull access group ID from the meta) */
     try {
         // Get user ID for the cart
         require_once dirname(dirname(dirname(__DIR__))) . DS . 'models' . DS . 'Cart.php';
         $userId = \Components\Cart\Models\Cart::getCartUser($this->crtId);
         // Get the user group ID to set the user to (from meta)
         require_once PATH_CORE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Product.php';
         $userGId = \Components\Storefront\Models\Product::getMeta($this->item['info']->pId, 'userGroupId');
         $add = \JUserHelper::addUserToGroup($userId, $userGId);
         if ($add instanceof \Exception) {
             mail(Config::get('mailfrom'), 'Error adding to the group', $add->getMessage() . ' Cart #' . $this->crtId);
         }
         $table = \JTable::getInstance('User', 'JTable', array());
         $table->load($userId);
         // Trigger the onAftereStoreUser event
         Event::trigger('onUserAfterSave', array($table->getProperties(), false, true, null));
     } catch (Exception $e) {
         // Error
         return false;
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:33,代码来源:Access_Group_Membership_Type_Handler.php

示例7: install_shutdown

 /**
  * Single shot defer handeler install
  */
 protected static function install_shutdown()
 {
     if (static::$inited_shutdown) {
         return;
     }
     // Disable time limit
     set_time_limit(0);
     // HHVM support
     if (function_exists('register_postsend_function')) {
         register_postsend_function(function () {
             Event::trigger('core.shutdown');
         });
     } else {
         if (function_exists('fastcgi_finish_request')) {
             register_shutdown_function(function () {
                 fastcgi_finish_request();
                 Event::trigger('core.shutdown');
             });
         } else {
             register_shutdown_function(function () {
                 Event::trigger('core.shutdown');
             });
         }
     }
     static::$inited_shutdown = true;
 }
开发者ID:caffeina-core,项目名称:core,代码行数:29,代码来源:Work.php

示例8: __invoke

 /**
  * Output the autocompleter
  *
  * @param   string  $what   The component to call
  * @param   string  $name   Name of the input field
  * @param   string  $value  The value of the input field
  * @param   string  $id     ID of the input field
  * @param   string  $class  CSS class(es) for the input field
  * @param   string  $size   The size of the input field
  * @param   string  $wsel   AC autopopulates a select list based on choice?
  * @param   string  $type   Allow single or multiple entries
  * @param   string  $dsabl  Readonly input
  * @return  string
  * @throws  \InvalidArgumentException  If wrong type passed
  */
 public function __invoke($what = null, $name = null, $value = null, $id = null, $class = null, $size = null, $wsel = false, $type = 'multi', $dsabl = false)
 {
     if (!in_array($what, array('tags', 'members', 'groups'))) {
         throw new \InvalidArgumentException(__METHOD__ . '(); ' . \Lang::txt('Autocompleter for "%s" not supported.', $what));
     }
     $id = $id ?: str_replace(array('[', ']'), '', $name);
     switch ($type) {
         case 'multi':
             $event = 'onGetMultiEntry';
             break;
         case 'single':
             $event = 'onGetSingleEntry';
             if ($wsel) {
                 $event = 'onGetSingleEntryWithSelect';
             }
             break;
         default:
             throw new \InvalidArgumentException(__METHOD__ . '(); ' . \Lang::txt('Autocompleter type "%s" not supported.', $type));
             break;
     }
     $results = \Event::trigger('hubzero.' . $event, array(array($what, $name, $id, $class, $value, $size, $wsel, $type, $dsabl)));
     if (count($results) > 0) {
         $results = implode("\n", $results);
     } else {
         $results = '<input type="text" name="' . $name . '" id="' . $id . '" value="' . $value . '" />';
     }
     return $results;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:43,代码来源:Autocompleter.php

示例9: onPublication

 /**
  * Return data on a publication view (this will be some form of HTML)
  *
  * @param   object   $publication
  * @param   string   $option
  * @param   array    $areas
  * @param   string   $rtrn
  * @param   string   $version
  * @param   boolean  $extended
  * @return  array
  */
 public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true)
 {
     $arr = array('html' => '', 'metadata' => '', 'name' => 'share');
     // Hide if version not published
     if (!$extended || in_array($publication->state, array(4, 5, 6))) {
         return $arr;
     }
     $sef = Route::url('index.php?option=' . $option . '&id=' . $publication->id);
     $sef = rtrim($sef, '/') . '/?v=' . $publication->version_number;
     $url = Request::base() . ltrim($sef, '/');
     $mediaUrl = Request::base() . trim($sef, '/') . '/' . $publication->version_id . '/Image:master';
     // Incoming action
     $sharewith = Request::getVar('sharewith', '');
     if ($sharewith) {
         if (!User::isGuest()) {
             // Log the activity
             Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'publication', 'scope_id' => $publication->id, 'description' => Lang::txt('PLG_PUBLICATIONS_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $publication->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $publication->title, 'url' => $sef, 'version' => $publication->version_number)], 'recipients' => [['publication', $publication->id], ['user', $publication->created_by], ['user', User::get('id')]]]);
         }
         return $this->share($sharewith, $url, $mediaUrl, $publication, $version);
     }
     // Build the HTML meant for the "about" tab's metadata overview
     if ($rtrn == 'all' || $rtrn == 'metadata') {
         // Instantiate a view
         $view = $this->view('default', 'options')->set('option', $option)->set('publication', $publication)->set('version', $version)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
         // Return the output
         $arr['metadata'] = $view->loadTemplate();
     }
     return $arr;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:40,代码来源:share.php

示例10: traceError

 public static function traceError($errno, $errstr, $errfile = null, $errline = null)
 {
     // This error code is not included in error_reporting
     if (!(error_reporting() & $errno)) {
         //todo throw exception
         return;
     }
     switch ($errno) {
         case E_USER_ERROR:
             $type = 'Fatal';
             break;
         case E_USER_WARNING:
         case E_WARNING:
             $type = 'Warning';
             break;
         case E_USER_NOTICE:
         case E_NOTICE:
         case E_STRICT:
             $type = 'Notice';
             break;
         default:
             $type = 'Error';
             break;
     }
     $e = new \ErrorException($type . ': ' . $errstr, 0, $errno, $errfile, $errline);
     $chk_specific = array_filter((array) Event::trigger('core.error.' . strtolower($type), $e));
     $chk_general = array_filter((array) Event::trigger('core.error', $e));
     if (!($chk_specific || $chk_general)) {
         static::traceException($e);
     }
     return true;
 }
开发者ID:evil-enterprises,项目名称:phpcore,代码行数:32,代码来源:Error.php

示例11: processQueue

 /**
  * Process the index queue
  *
  * @museDescription  Processes the index queue
  *
  * @return  void
  **/
 public function processQueue()
 {
     require_once PATH_CORE . DS . 'components' . DS . 'com_search' . DS . 'models' . DS . 'indexqueue.php';
     require_once PATH_CORE . DS . 'components' . DS . 'com_search' . DS . 'models' . DS . 'blacklist.php';
     // Get the type needed to be indexed;
     $items = \Components\Search\Models\QueueDB::all()->where('status', '=', 0)->limit(100)->rows();
     // Refresh indexed material if no work to do
     if ($items->count() <= 0) {
         $items = \Components\Search\Models\QueueDB::all()->where('status', '=', 1)->where('action', '=', 'index')->order('modified', 'ASC')->limit(100)->rows();
     }
     // Get the blacklist
     $sql = "SELECT doc_id FROM #__search_blacklist;";
     $db = App::get('db');
     $db->setQuery($sql);
     $blacklist = $db->query()->loadColumn();
     foreach ($items as $item) {
         $format = Event::trigger('search.onIndex', array($item->type, $item->type_id, true));
         if (isset($format[0])) {
             $this->processRows($format[0], $item->action, $blacklist);
             $timestamp = \Hubzero\Utility\Date::of()->toSql();
             $item->set('modified', $timestamp);
             $item->set('status', 1);
         } else {
             $item->set('status', '2');
         }
         $item->save();
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:35,代码来源:search.php

示例12: testTrigger

 /** 
  * @dataProvider providerTrigger
  */
 public function testTrigger($data)
 {
     Event::trigger('test', $data);
     if ($data !== 'ok') {
         $this->fail('изменения не внесены');
     }
 }
开发者ID:smoren,项目名称:mushroom-framework,代码行数:10,代码来源:EventTest.php

示例13: exec

 public static function exec($query, $params = [])
 {
     $query = Filter::with('core.sql.query', $query);
     $statement = static::prepare($query);
     Event::trigger('core.sql.query', $query, $params, !!$statement);
     static::$last_exec_success = $statement && $statement->execute($params);
     return $statement;
 }
开发者ID:evil-enterprises,项目名称:phpcore,代码行数:8,代码来源:SQL.php

示例14: error

 public static function error($message, $status = 501)
 {
     Event::trigger('api.error', [$message, $status]);
     Response::status($status);
     Response::json(['error' => ['type' => 'fatal', 'status' => $status, 'message' => $message]]);
     Response::send();
     exit;
 }
开发者ID:caffeina-core,项目名称:api,代码行数:8,代码来源:API.php

示例15: delete

 function delete() {
     if (User::$current->logout()) {
         Event::trigger(Event::TYPE_USER_LOGOUT, User::$current->account);
         session_start();
         $this->flash('success', "erfolgreich ausgeloggt!");
     }
     $this->redirect_to(array('session', 'add'));
 }
开发者ID:reddragon010,项目名称:RG-ServerPanel,代码行数:8,代码来源:SessionController.php


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