Tobscure\JsonApi\AbstractSerializer::getRelationship PHP Méthode

getRelationship() public méthode

public getRelationship ( $model, $name )
    public function getRelationship($model, $name)
    {
        $method = $this->getRelationshipMethodName($name);
        if (method_exists($this, $method)) {
            $relationship = $this->{$method}($model);
            if ($relationship !== null && !$relationship instanceof Relationship) {
                throw new LogicException('Relationship method must return null or an instance of Tobscure\\JsonApi\\Relationship');
            }
            return $relationship;
        }
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function getRelationship($model, $name)
 {
     if ($relationship = $this->getCustomRelationship($model, $name)) {
         return $relationship;
     }
     return parent::getRelationship($model, $name);
 }