/** * Returns a Managed Object whose property matches the specified object value * * This method fetches an object from the Persistent Store that contains the * specified property and whose value for that property matches the value * specified in $value * * @param MEntityDescriptionProperty $property The property whose value you * wish to match against * @param MObject $value The value to be matched * * @return MManagedObject The fetched MManagedObject */ public function objectWith(MEntityDescriptionProperty $property, MObject $value = null) { $request = new MFetchRequest($property->entity(), $this); if ($value) { $request->setPredicate(Sf("%s = '%s'", $property->name()->stringValue(), $value->toString()->stringValue())); } else { $request->setPredicate(Sf("%s = null", $property->name()->stringValue())); } $data = $this->executeFetchRequest($request); return $data->lastObject(); }