public function __construct(comment $comment, $related = array())
 {
     $this->comment = $comment;
     $data = new stdClass();
     $data->component = $comment->get_component();
     $data->commentarea = $comment->get_commentarea();
     $data->itemid = $comment->get_itemid();
     $data->courseid = $comment->get_courseid();
     $data->contextid = $comment->get_context()->id;
     $data->cid = $comment->get_cid();
     parent::__construct($data, $related);
 }
Esempio n. 2
0
 /**
  * Constructor - saves the persistent object, and the related objects.
  *
  * @param \core_competency\persistent $persistent The persistent object to export.
  * @param array $related - An optional list of pre-loaded objects related to this persistent.
  */
 public final function __construct(\core_competency\persistent $persistent, $related = array())
 {
     $classname = static::define_class();
     if (!$persistent instanceof $classname) {
         throw new coding_exception('Invalid type for persistent. ' . 'Expected: ' . $classname . ' got: ' . get_class($persistent));
     }
     $this->persistent = $persistent;
     if (method_exists($this->persistent, 'get_context') && !isset($this->related['context'])) {
         $this->related['context'] = $this->persistent->get_context();
     }
     $data = $persistent->to_record();
     parent::__construct($data, $related);
 }
Esempio n. 3
0
 public function __construct(stored_file $file, $related = array())
 {
     $this->file = $file;
     $data = new stdClass();
     $data->contextid = $file->get_contextid();
     $data->component = $file->get_component();
     $data->filearea = $file->get_filearea();
     $data->itemid = $file->get_itemid();
     $data->filepath = $file->get_filepath();
     $data->filename = $file->get_filename();
     $data->isdir = $file->is_directory();
     $data->timemodified = $file->get_timemodified();
     $data->timecreated = $file->get_timecreated();
     $data->filesize = $file->get_filesize();
     $data->author = $file->get_author();
     $data->license = $file->get_license();
     if ($related['context']->id != $data->contextid) {
         throw new coding_exception('Unexpected context ID received.');
     }
     parent::__construct($data, $related);
 }
 /**
  * Constructor.
  *
  * @param array $related - related objects.
  */
 public function __construct($related)
 {
     parent::__construct([], $related);
 }