예제 #1
0
 /**
  *
  * @return mixed The reference of the stored file
  */
 public function __getRawValue()
 {
     if (!is_null($this->filePath)) {
         $this->reference = \morph\Storage::instance()->saveFile($this->filePath, $this->reference);
     }
     return $this->reference;
 }
예제 #2
0
 private function connect()
 {
     //connects to the DB.. prepares stuff etc.
     if (StorageObject::$mongo == null) {
         global $Configuration;
         StorageObject::$mongo = new Mongo();
         Storage::init(StorageObject::$mongo->selectDB($Configuration['db']['db']));
     }
 }
예제 #3
0
 public function testSearchAnAliasedPropertyWithItsAlias()
 {
 	$aliased = new Aliased();
     $aliased->Name = 'Chris';
     $aliased->save();
     
     $query = \morph\Query::instance()
     ->property('n')->equals('Chris');
     
     $found = \morph\Storage::instance()->findOneByQuery(new Aliased(), $query);
     $this->assertEquals($aliased->id(), $found->id());
 }
예제 #4
0
 public function tearDown()
 {
     parent::tearDown();
     \morph\Storage::deInit();
 }
예제 #5
0
 /**
  * (non-PHPdoc)
  * @see tao/classes/Morph/property/Morph_Property_Generic#__getRawValue()
  */
 public function __getRawValue()
 {
     if(!is_null($this->value)) {
         if($this->value->state() != \morph\Enum::STATE_CLEAN) {
             //save value
             \morph\Storage::instance()->save($this->value);
         }
         $this->reference = \morph\Utils::objectReference($this->value);
     }
     return $this->reference;
 }
예제 #6
0
 public function tearDown()
 {
     parent::tearDown();
     \morph\Storage::deInit();
     unlink('test.png');
 }
예제 #7
0
    /**
     * Loads the stored references
     * @return void
     */
    private function loadFromReferences()
    {
        $ids = array();
        $collection = null;
        if (count($this->references) > 0) {
            foreach ($this->references as $reference){
                $ids[] = $reference['$id'];
            }

            $query = new \morph\Query();
            $query->property('_id')->in($ids);

            $object = new $this->type;

            $collection = \morph\Storage::instance()
                    ->findByQuery($object, $query)
                    ->toCollection(); //@todo this could get nasty with large collections!
            
        }
        
        $this->value =  new \morph\property\StatefulCollection($this, $collection);
        $this->loaded = true;
    }