Пример #1
0
 /**
  * Converts an $hash to the Value defined by the field type
  *
  * @param mixed $hash
  *
  * @return Value
  */
 public function fromHash($hash)
 {
     if (!is_array($hash)) {
         return new Value([]);
     }
     $metas = [];
     foreach ($hash as $hashItem) {
         if (!is_array($hashItem)) {
             continue;
         }
         $meta = new Meta();
         $meta->setName($hashItem["meta_name"]);
         $meta->setContent($hashItem["meta_content"]);
         $metas[] = $meta;
     }
     return new Value($metas);
 }
Пример #2
0
 /**
  * Return content (xxx object), either stored one or a new empty one based on
  * if attribute has data or not
  *
  * @param eZContentObjectAttribute $contentObjectAttribute
  *
  * @return array
  */
 function objectAttributeContent($contentObjectAttribute)
 {
     if ($contentObjectAttribute->attribute('id')) {
         $db = eZDB::instance();
         $metasArray = $db->arrayQuery("SELECT * FROM " . $db->escapeString(self::TABLE) . " WHERE\n                        objectattribute_id = {$contentObjectAttribute->attribute('id')} AND\n                        objectattribute_version= {$contentObjectAttribute->attribute('version')}\n                        ");
         $metas = [];
         foreach ($metasArray as $row) {
             $meta = new Meta();
             $meta->setName($row['meta_name'])->setContent($row['meta_content']);
             $metas[] = $meta;
         }
         return new FieldValue($metas);
     }
     return new FieldValue([]);
 }