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


PHP base::restore方法代码示例

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


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

示例1: 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

示例2: 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

示例3: get_log_event

 /**
  * Returns an event from the log data.
  *
  * @param stdClass $data Log data
  * @return \core\event\base
  */
 public function get_log_event($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']);
     if (!($event = \core\event\base::restore($data, $extra))) {
         return null;
     }
     return $event;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:24,代码来源:store.php

示例4: test_restore_event

 public function test_restore_event()
 {
     $event1 = \core_tests\event\unittest_executed::create(array('courseid' => 1, 'context' => \context_system::instance(), 'other' => array('sample' => 1, 'xx' => 10)));
     $data1 = $event1->get_data();
     $event2 = \core\event\base::restore($data1, array('origin' => 'clid'));
     $data2 = $event2->get_data();
     $this->assertTrue($event2->is_triggered());
     $this->assertTrue($event2->is_restored());
     $this->assertEquals($data1, $data2);
     $this->assertInstanceOf('core_tests\\event\\unittest_executed', $event2);
     $this->assertEquals($event1->get_context(), $event2->get_context());
     // Now test problematic data.
     $data3 = $data1;
     $data3['eventname'] = '\\a\\b\\c';
     $event3 = \core\event\base::restore($data3, array());
     $this->assertFalse($event3, 'Class name must match');
     $data4 = $data1;
     unset($data4['userid']);
     $event4 = \core\event\base::restore($data4, array());
     $this->assertInstanceOf('core_tests\\event\\unittest_executed', $event4);
     $this->assertDebuggingCalled();
     $data5 = $data1;
     $data5['xx'] = 'xx';
     $event5 = \core\event\base::restore($data5, array());
     $this->assertInstanceOf('core_tests\\event\\unittest_executed', $event5);
     $this->assertDebuggingCalled();
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:27,代码来源:event_test.php

示例5: test_course_viewed

 /**
  * There is no api involved so the best we can do is test legacy data by triggering event manually.
  */
 public function test_course_viewed()
 {
     $user = $this->getDataGenerator()->create_user();
     $course = $this->getDataGenerator()->create_course();
     $context = context_course::instance($course->id);
     // First try with no optional parameters.
     $eventparams = array();
     $eventparams['context'] = $context;
     $event = \core\event\course_viewed::create($eventparams);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertInstanceOf('\\core\\event\\course_viewed', $event);
     $this->assertEquals(context_course::instance($course->id), $event->get_context());
     $expected = array($course->id, 'course', 'view', 'view.php?id=' . $course->id, $course->id);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
     // Now try with optional parameters.
     $sectionid = 34;
     $eventparams = array();
     $eventparams['context'] = $context;
     $eventparams['other'] = array('coursesectionid' => $sectionid);
     $event = \core\event\course_viewed::create($eventparams);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $loggeddata = $event->get_data();
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertInstanceOf('\\core\\event\\course_viewed', $event);
     $this->assertEquals(context_course::instance($course->id), $event->get_context());
     $expected = array($course->id, 'course', 'view section', 'view.php?id=' . $course->id . '&section=' . $sectionid, $sectionid);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
     delete_course($course->id, false);
     $restored = \core\event\base::restore($loggeddata, array('origin' => 'web', 'ip' => '127.0.0.1'));
     $this->assertInstanceOf('\\core\\event\\course_viewed', $restored);
     $this->assertNull($restored->get_url());
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:44,代码来源:events_test.php

示例6: get_events_select

 /**
  * Get an array of events based on the passed on params.
  *
  * @param string $selectwhere select conditions.
  * @param array $params params.
  * @param string $sort sortorder.
  * @param int $limitfrom limit constraints.
  * @param int $limitnum limit constraints.
  *
  * @return array|\core\event\base[] array of events.
  */
 public function get_events_select($selectwhere, array $params, $sort, $limitfrom, $limitnum)
 {
     if (!$this->init()) {
         return array();
     }
     if (!($dbtable = $this->get_config('dbtable'))) {
         return array();
     }
     $sort = self::tweak_sort_by_id($sort);
     $events = array();
     $records = $this->extdb->get_records_select($dbtable, $selectwhere, $params, $sort, '*', $limitfrom, $limitnum);
     foreach ($records as $data) {
         $extra = array('origin' => $data->origin, 'realuserid' => $data->realuserid, 'ip' => $data->ip);
         $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,代码行数:42,代码来源:store.php


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