Skip to content

Commit

Permalink
Remove hydrator
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Mar 16, 2014
1 parent e66afa4 commit 3f374e0
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 45 deletions.
44 changes: 0 additions & 44 deletions src/ZfrRest/Hydrator/ResourceHydrator.php

This file was deleted.

47 changes: 47 additions & 0 deletions tests/ZfrRestTest/Asset/Resource/Metadata/Annotation/Tweet.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,55 @@

namespace ZfrRestTest\Asset\Resource\Metadata\Annotation;

use Doctrine\ORM\Mapping as ORM;
use ZfrRest\Resource\Metadata\Annotation as REST;

/**
* @ORM\Entity
* @REST\Resource(hydrator="ClassMethods")
*/
class Tweet
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
*/
protected $id;

/**
* @ORM\Column(type="string")
*/
protected $content;

/**
* @param (int) $id
*/
public function setId($id)
{
$this->id = (int) $id;
}

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @param string $content
*/
public function setContent($content)
{
$this->content = (string) $content;
}

/**
* @return string
*/
public function getContent()
{
return $this->content;
}
}
29 changes: 29 additions & 0 deletions tests/ZfrRestTest/Asset/Resource/Metadata/Annotation/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace ZfrRestTest\Asset\Resource\Metadata\Annotation;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use ZfrRest\Resource\Metadata\Annotation as REST;

Expand All @@ -44,6 +45,17 @@ class User
*/
protected $address;

/**
* @ORM\OneToMany(targetEntity="Tweet")
* @REST\Association(extraction="ID")
*/
protected $tweets;

public function __construct()
{
$this->tweets = new ArrayCollection();
}

/**
* @param (int) $id
*/
Expand Down Expand Up @@ -91,4 +103,21 @@ public function getAddress()
{
return $this->address;
}

/**
* @param Tweet $tweet
* @return void
*/
public function addTweet(Tweet $tweet)
{
$this->tweets->add($tweet);
}

/**
* @return ArrayCollection
*/
public function getTweets()
{
return $this->tweets;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ public function testCanRenderSingleResourceWithAssociationAsEmbed()
$expectedPayload = [
'id' => 2,
'username' => 'bakura',
'address' => 43
'address' => [
'id' => 43,
'country' => 'France'
]
];

$this->assertEquals($expectedPayload, $payload);
Expand Down

0 comments on commit 3f374e0

Please sign in to comment.