/** * * @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; }
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()); }
/** * (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; }
/** * 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; }