Exemplo n.º 1
0
 public function searchMeta($id, IMetaData $metaData)
 {
     try {
         // setting up className...
         $className = explode('_', $id);
         $className = $className[1];
         // retrieving all setted MetaDatas from $metaData object...
         $metaDatas = $metaData->getAll();
         // if just one meta is setted, we search for a single meta in the database...
         if (count($metaDatas) == 1) {
             $result = $this->searchSingleMeta($className, key($metaDatas), current($metaDatas));
         } else {
             $result = $this->searchMultipleMetas($className, $metaDatas);
         }
         // the search returns empty values, we return null and quit the function...
         if ($result === false) {
             return null;
         }
         // else we prepare the array $return, and we fill it with object's ids.
         $return = array();
         foreach ($result as $value) {
             $return[] = $value[self::METADATA_FIELD_ID];
         }
     } catch (Exception $e) {
         throw new EyeDBException('An error occured while trying to retrieve metadata from database.', 0, $e);
     }
     return $return;
 }
 /**
  * TODO
  * 
  * @param string $id The identifier used to be able to retrieve data to be written afterwards.
  * @param IMetaData The metadata to be written.
  * @param array $params Additional params implementation-dependant.
  */
 public function storeMeta($id, IMetaData $metaData, $params = null)
 {
     $xml = new SimpleXMLElement('<meta/>');
     $metaDatas = $metaData->getAll();
     foreach ($metaDatas as $key => $value) {
         if (is_array($value)) {
             $node = $xml->addChild('entry');
             $node->addAttribute('key', $key);
             $node->addAttribute('type', 'array');
             $this->writeArray($node, $value);
         } else {
             if (is_bool($value)) {
                 $node = $xml->addChild('entry', $value ? 'true' : 'false');
                 $node->addAttribute('key', $key);
             } else {
                 $node = $xml->addChild('entry', $value);
                 $node->addAttribute('key', $key);
             }
         }
     }
     try {
         $xmlWriter = new XmlStreamWriter(new FileOutputStream($this->filePath), array(XmlStreamWriter::PARAM_FORMATOUTPUT => $this->formatOutput));
         $xmlWriter->write($xml);
     } catch (Exception $e) {
         //close stream
         try {
             if (is_object($xmlWriter)) {
                 $xmlWriter->close();
             }
         } catch (Exception $e) {
         }
         throw new EyeIOException('Unable to write meta file at ' . $this->filePath . '.', 0, $e);
     }
     //close stream
     try {
         if (is_object($xmlWriter)) {
             $xmlWriter->close();
         }
     } catch (Exception $e) {
     }
     //Update cache
     self::$Cache[$this->filePath] = $metaData->getAll();
 }
Exemplo n.º 3
0
 /**
  * Constructs a new IMetadata by copying the values stored in the given parameter if any,
  * or an empty one otherwise.
  * 
  * @param IMetaData $metaData
  */
 public function __construct(IMetaData $metaData = null)
 {
     if ($metaData !== null) {
         $this->setAll($metaData->getAll());
     }
 }