コード例 #1
0
 public function __construct($raw, $value, $type)
 {
     parent::__construct($raw, $value, $type);
     if (array_key_exists('description', $raw)) {
         $this->description = $raw['description'];
     }
     if (array_key_exists('filesize', $raw)) {
         $this->size = $raw['filesize'];
     }
     if (array_key_exists('filemime', $raw)) {
         $this->mime = $raw['filemime'];
     }
     if (array_key_exists('status', $raw)) {
         $this->status = $raw['status'];
     }
     if (array_key_exists('timestamp', $raw)) {
         $this->timestamp = $raw['timestamp'];
     }
     if (array_key_exists('uid', $raw)) {
         $this->uid = $raw['uid'];
     }
     if (array_key_exists('fid', $raw)) {
         $this->fid = $raw['fid'];
     }
     if (array_key_exists('filename', $raw)) {
         $this->name = $raw['filename'];
         $this->extension = pathinfo($this->name, PATHINFO_EXTENSION);
     }
     if (array_key_exists('uri', $raw)) {
         $this->uri = $raw['uri'];
         $this->url = file_create_url($raw['uri']);
     }
 }
コード例 #2
0
 public function __construct($raw, $value, $type, $format)
 {
     parent::__construct($raw, $value, $type);
     switch ($format) {
         case 'datestamp':
             $this->dateType = 'unix';
             $this->timestamp = $value;
             break;
         case 'datetime':
             $this->dateType = 'datetime';
             $this->timestamp = strtotime($value);
             break;
         case 'date':
             $this->dateType = 'iso';
             $this->timestamp = strtotime($value);
             break;
     }
     if (array_key_exists('timezone', $raw)) {
         $this->timezone = $raw['timezone'];
     }
     if (array_key_exists('timezone_db', $raw)) {
         $this->dbTimezone = $raw['timezone_db'];
     }
     if (array_key_exists('value2', $raw)) {
         $enddateRaw = array('timezone' => $this->timezone, 'timezone_db' => $this->dbTimezone, 'value' => $raw['value2'], 'date_type' => $this->dateType);
         $this->endDate = new DateFieldValue($enddateRaw, $raw['value2'], $type, $format);
     }
 }
コード例 #3
0
 public function __construct($type, $raw, $target_type)
 {
     parent::__construct($raw, $raw['target_id'], $type);
     $this->id = $raw['target_id'];
     $this->target_type = $target_type;
     $raw_array = entity_load($target_type, array($raw['target_id']));
     if (count($raw_array) > 0) {
         // The array from entity_load is keyed by entity id.
         foreach ($raw_array as $item) {
             $this->raw_entity = $item;
             break;
         }
     } else {
         throw new \Exception("The {$target_type} '{$this->id}' does not exist.");
     }
 }
コード例 #4
0
 public function __construct($type, $raw)
 {
     parent::__construct($raw, $raw['value'], $type);
     $this->id = $raw['value'];
     $raw_array = entity_load('field_collection_item', array($raw['value']));
     if (count($raw_array) > 0) {
         // The array from entity_load is keyed by entity id.
         foreach ($raw_array as $item) {
             $this->raw_collection = $item;
             break;
         }
     } else {
         throw new \Exception("The field collection '{$this->id}' does not exist.");
     }
     if (array_key_exists('revision_id', $raw)) {
         $this->revision_id = $raw['revision_id'];
     }
 }
コード例 #5
0
 public function __construct($raw, $value, $type)
 {
     parent::__construct($raw, $value, $type);
     if (array_key_exists('safe_value', $raw)) {
         $this->safe_value = $raw['safe_value'];
     }
     if (array_key_exists('value', $raw)) {
         $this->unsafe_value = $raw['value'];
     }
     if (array_key_exists('format', $raw)) {
         $this->format = $raw['format'];
     }
     if (array_key_exists('safe_summary', $raw)) {
         $this->safe_summary = $raw['safe_summary'];
     }
     if (array_key_exists('summary', $raw)) {
         $this->unsafe_summary = $raw['summary'];
     }
 }