Skip to content

Commit

Permalink
Merge pull request parse-community#175 from ParsePlatform/gfosco.getR…
Browse files Browse the repository at this point in the history
…elation

Added param to getRelation for Issue 126
  • Loading branch information
gfosco committed Oct 27, 2015
2 parents f277262 + 5944e96 commit 762c396
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Parse/ParseObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -1171,15 +1171,16 @@ private function mergeAfterSave($result)
/**
* Access or create a Relation value for a key.
*
* @param string $key The key to access the relation for.
* @param string $key The key to access the relation for.
* @param string $className The target class name.
*
* @return ParseRelation The ParseRelation object if the relation already
* exists for the key or can be created for this key.
*/
public function getRelation($key)
public function getRelation($key, $className = null)
{
$relation = new ParseRelation($this, $key);
if (isset($this->estimatedData[$key])) {
$relation = new ParseRelation($this, $key, $className);
if (!$className && isset($this->estimatedData[$key])) {
$object = $this->estimatedData[$key];
if ($object instanceof ParseRelation) {
$relation->setTargetClass($object->getTargetClass());
Expand Down

0 comments on commit 762c396

Please sign in to comment.