コード例 #1
0
 /**
  * @param RelationshipInterface $relationship
  * @param $record
  */
 protected function hydrateUserRelationship(RelationshipInterface $relationship, $record)
 {
     $record->user_id = $relationship->getIdentifier()->getId();
 }
コード例 #2
0
 /**
  * Hydrate a resource has-one relationship.
  *
  * @param $resourceKey
  * @param RelationshipInterface $relationship
  * @param Model $model
  * @return bool
  *      whether a relationship was hydrated
  */
 protected function hydrateHasOne($resourceKey, RelationshipInterface $relationship, Model $model)
 {
     $relation = $this->getRelation($resourceKey, $model);
     if (!$relation instanceof BelongsTo) {
         return false;
     }
     if ($relationship->hasIdentifier()) {
         $relation->associate($this->findRelated($relationship->getIdentifier()));
     } else {
         $relation->dissociate();
     }
     return true;
 }