-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved transformation of relationships
- Loading branch information
1 parent
55d1b8f
commit 60ffaeb
Showing
11 changed files
with
138 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
namespace WoohooLabs\Yin\JsonApi\Schema; | ||
|
||
use WoohooLabs\Yin\JsonApi\Request\Criteria; | ||
use WoohooLabs\Yin\JsonApi\Transformer\ResourceTransformerInterface; | ||
|
||
class OneToManyArrayRelationship extends AbstractRelationship | ||
{ | ||
/** | ||
* @param array $data | ||
* @param \WoohooLabs\Yin\JsonApi\Transformer\ResourceTransformerInterface $resourceTransformer | ||
*/ | ||
public function __construct(array $data, ResourceTransformerInterface $resourceTransformer) | ||
{ | ||
parent::__construct($data, $resourceTransformer); | ||
} | ||
|
||
/** | ||
* @param \WoohooLabs\Yin\JsonApi\Request\Criteria $criteria | ||
* @param \WoohooLabs\Yin\JsonApi\Schema\Included $includes | ||
* @param string $relationshipPath | ||
* @return array | ||
*/ | ||
protected function transformData(Criteria $criteria, Included $includes, $relationshipPath) | ||
{ | ||
$result = []; | ||
|
||
foreach ($this->data as $item) { | ||
$result[] = $this->transformResource($item, $criteria, $includes, $relationshipPath); | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
<?php | ||
namespace WoohooLabs\Yin\JsonApi\Schema; | ||
|
||
class OneToOneAbstractRelationship extends AbstractRelationship | ||
use WoohooLabs\Yin\JsonApi\Request\Criteria; | ||
use WoohooLabs\Yin\JsonApi\Transformer\ResourceTransformerInterface; | ||
|
||
class OneToOneRelationship extends AbstractRelationship | ||
{ | ||
/** | ||
* @var \WoohooLabs\Yin\JsonApi\Schema\ResourceIdentifier | ||
* @param mixed $data | ||
* @param \WoohooLabs\Yin\JsonApi\Transformer\ResourceTransformerInterface $resourceTransformer | ||
*/ | ||
private $data; | ||
public function __construct($data, ResourceTransformerInterface $resourceTransformer) | ||
{ | ||
parent::__construct($data, $resourceTransformer); | ||
} | ||
|
||
/** | ||
* @param array $resource | ||
* @param \WoohooLabs\Yin\JsonApi\Request\Criteria $criteria | ||
* @param \WoohooLabs\Yin\JsonApi\Schema\Included $includes | ||
* @param string $relationshipPath | ||
* @return array | ||
*/ | ||
public function addResource(array $resource) | ||
protected function transformData(Criteria $criteria, Included $includes, $relationshipPath) | ||
{ | ||
$this->data = $resource; | ||
return $this->transformResource($this->data, $criteria, $includes, $relationshipPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters