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


PHP event\base類代碼示例

本文整理匯總了PHP中core\event\base的典型用法代碼示例。如果您正苦於以下問題:PHP base類的具體用法?PHP base怎麽用?PHP base使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: observer

 /**
  * Observe the events, and dispatch them if necessary.
  *
  * @param \core\event\base $event The event.
  * @return void
  */
 public static function observer(\core\event\base $event)
 {
     if ($event->component === 'block_xp') {
         // Skip own events.
     } else {
         if (!$event->userid || isguestuser($event->userid) || is_siteadmin($event->userid)) {
             // Skip non-logged in users and guests.
         } else {
             if ($event->contextlevel !== CONTEXT_COURSE && $event->contextlevel !== CONTEXT_MODULE) {
                 // Ignore events outside a course.
             } else {
                 if ($event->edulevel !== \core\event\base::LEVEL_PARTICIPATING) {
                     // Ignore events that are not participating.
                 } else {
                     if (!has_capability('block/xp:earnxp', $event->get_context(), $event->userid)) {
                         // Skip the events if the user does not have the capability to earn XP, or if it is the admin.
                     } else {
                         // Keep the event, and proceed.
                         $manager = block_xp_manager::get($event->courseid);
                         $manager->capture_event($event);
                     }
                 }
             }
         }
     }
 }
開發者ID:scarletjester,項目名稱:moodle-block_xp,代碼行數:32,代碼來源:helper.php

示例2: dispatch

 /**
  * Trigger new event.
  *
  * @internal to be used only from \core\event\base::trigger() method.
  * @param \core\event\base $event
  *
  * @throws \coding_Exception if used directly.
  */
 public static function dispatch(\core\event\base $event)
 {
     if (during_initial_install()) {
         return;
     }
     if (!$event->is_triggered() or $event->is_dispatched()) {
         throw new \coding_exception('Illegal event dispatching attempted.');
     }
     self::$buffer[] = $event;
     if (self::$dispatching) {
         return;
     }
     self::$dispatching = true;
     self::process_buffers();
     self::$dispatching = false;
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:24,代碼來源:manager.php

示例3: get_events_select

 public function get_events_select($selectwhere, array $params, $sort, $limitfrom, $limitnum)
 {
     global $DB;
     $sort = self::tweak_sort_by_id($sort);
     $events = array();
     $records = $DB->get_records_select('logstore_standard_log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum);
     foreach ($records as $data) {
         $extra = array('origin' => $data->origin, 'ip' => $data->ip, 'realuserid' => $data->realuserid);
         $data = (array) $data;
         $id = $data['id'];
         $data['other'] = unserialize($data['other']);
         if ($data['other'] === false) {
             $data['other'] = array();
         }
         unset($data['origin']);
         unset($data['ip']);
         unset($data['realuserid']);
         unset($data['id']);
         $event = \core\event\base::restore($data, $extra);
         // Add event to list if it's valid.
         if ($event) {
             $events[$id] = $event;
         }
     }
     return $events;
 }
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:26,代碼來源:store.php

示例4: observer

 /**
  * Observe the events, and dispatch them if necessary.
  *
  * @param \core\event\base $event The event.
  * @return void
  */
 public static function observer(\core\event\base $event)
 {
     global $CFG;
     static $allowedcontexts = null;
     if ($allowedcontexts === null) {
         $allowedcontexts = array(CONTEXT_COURSE, CONTEXT_MODULE);
         if (isset($CFG->block_xp_context) && $CFG->block_xp_context == CONTEXT_SYSTEM) {
             $allowedcontexts[] = CONTEXT_SYSTEM;
         }
     }
     if ($event->component === 'block_xp') {
         // Skip own events.
     } else {
         if (!$event->userid || isguestuser($event->userid) || is_siteadmin($event->userid)) {
             // Skip non-logged in users and guests.
         } else {
             if ($event->anonymous) {
                 // Skip all the events marked as anonymous.
             } else {
                 if (!in_array($event->contextlevel, $allowedcontexts)) {
                     // Ignore events that are not in the right context.
                 } else {
                     if ($event->edulevel !== \core\event\base::LEVEL_PARTICIPATING) {
                         // Ignore events that are not participating.
                     } else {
                         if (!has_capability('block/xp:earnxp', $event->get_context(), $event->userid)) {
                             // Skip the events if the user does not have the capability to earn XP.
                         } else {
                             // Keep the event, and proceed.
                             $manager = block_xp_manager::get($event->courseid);
                             $manager->capture_event($event);
                         }
                     }
                 }
             }
         }
     }
 }
開發者ID:antoniorodrigues,項目名稱:redes-digitais,代碼行數:44,代碼來源:helper.php

示例5: test_restore_event

 public function test_restore_event()
 {
     $event1 = \core_tests\event\unittest_executed::create(array('context' => context_system::instance(), 'other' => array('sample' => 1, 'xx' => 10)));
     $data1 = $event1->get_data();
     $data1['eventname'] = '\\mod_xx\\event\\xx_yy';
     $data1['component'] = 'mod_xx';
     $data1['action'] = 'yy';
     $data1['target'] = 'xx';
     $extra1 = array('origin' => 'cli');
     $event2 = \core\event\base::restore($data1, $extra1);
     $data2 = $event2->get_data();
     $extra2 = $event2->get_logextra();
     $this->assertInstanceOf('core\\event\\unknown_logged', $event2);
     $this->assertTrue($event2->is_triggered());
     $this->assertTrue($event2->is_restored());
     $this->assertNull($event2->get_url());
     $this->assertEquals($data1, $data2);
     $this->assertEquals($extra1, $extra2);
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:19,代碼來源:event_unknown_logged_test.php

示例6: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception
  */
 protected function validate_data()
 {
     parent::validate_data();
     if ($this->contextlevel != CONTEXT_MODULE) {
         throw new \coding_exception('Context level must be CONTEXT_MODULE.');
     }
 }
開發者ID:ninelanterns,項目名稱:moodle-mod_scheduler,代碼行數:12,代碼來源:scheduler_base.php

示例7: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     if (!isset($this->other['title'])) {
         throw new \coding_exception('The \'title\' value must be set in the object.');
     }
 }
開發者ID:unikent,項目名稱:moodle-mod_qa,代碼行數:13,代碼來源:question_posted.php

示例8: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     if (!isset($this->other['subscriptionid'])) {
         throw new \coding_exception('The \'subscriptionid\' value must be set in other.');
     }
 }
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:13,代碼來源:subscription_criteria_met.php

示例9: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     if (!isset($this->relateduserid)) {
         throw new \coding_exception('The \'relateduserid\' must be set.');
     }
 }
開發者ID:advancingdesign,項目名稱:moodle-local_enrolmentreminder,代碼行數:13,代碼來源:message_sent.php

示例10: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     if (!isset($this->other['itemid'])) {
         throw new \coding_exception('The itemid needs to be set in $other');
     }
 }
開發者ID:parksandwildlife,項目名稱:learning,代碼行數:13,代碼來源:rating_created.php

示例11: validate_data

 /**
  * Custom validations.
  *
  * @throws \coding_exception when validation fails.
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     // Make sure this class is never used without proper object details.
     if (!$this->contextlevel === CONTEXT_MODULE) {
         throw new \coding_exception('Context level must be CONTEXT_MODULE.');
     }
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:14,代碼來源:content_page_viewed.php

示例12: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     if (!isset($this->relateduserid)) {
         debugging('The \'relateduserid\' value must be specified in the event.', DEBUG_DEVELOPER);
         $this->relateduserid = $this->objectid;
     }
 }
開發者ID:sebastianberm,項目名稱:moodle-block_coupon,代碼行數:14,代碼來源:coupon_used.php

示例13: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     if (empty($this->other['mode'])) {
         throw new \coding_exception('The \'mode\' value must be set in other.');
     }
     if (empty($this->relateduserid)) {
         throw new \coding_exception('The \'relateduserid\' must be set.');
     }
 }
開發者ID:posttechguy,項目名稱:moodle-tbst2-report_log,代碼行數:16,代碼來源:user_report_viewed.php

示例14: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     if (!isset($this->other['desc'])) {
         throw new \coding_exception('The \'desc\' value must be set in other.');
     }
     if ($this->contextlevel != CONTEXT_MODULE) {
         throw new \coding_exception('Context level must be CONTEXT_MODULE.');
     }
 }
開發者ID:ccle,項目名稱:moodle-mod_turnitintool,代碼行數:16,代碼來源:delete_submission.php

示例15: validate_data

 /**
  * Custom validation.
  *
  * @throws \coding_exception when validation does not pass.
  * @return void
  */
 protected function validate_data()
 {
     parent::validate_data();
     if (!isset($this->other['dataid'])) {
         throw new \coding_exception('The dataid must be set in $other.');
     }
     if (!isset($this->other['viewid'])) {
         throw new \coding_exception('The viewid must be set in $other.');
     }
 }
開發者ID:parksandwildlife,項目名稱:learning,代碼行數:16,代碼來源:view_base.php


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