Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
namespace ApiPlatform\Core\Annotation;

/**
* Resource annotation.
* ApiResource annotation.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @Annotation
* @Target({"CLASS"})
*/
final class Resource
final class ApiResource
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace ApiPlatform\Core\Metadata\Resource\Factory;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Exception\ResourceClassNotFoundException;
use ApiPlatform\Core\Metadata\Resource\Operation;
use ApiPlatform\Core\Metadata\Resource\PaginationMetadata;
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
use Doctrine\Common\Annotations\Reader;

/**
* Creates a resource metadata from {@see Resource} annotations.
* Creates a resource metadata from {@see ApiResource} annotations.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*/
Expand Down Expand Up @@ -54,7 +54,7 @@ public function create(string $resourceClass) : ResourceMetadata
return $this->handleNotFound($parentResourceMetadata, $resourceClass);
}

$resourceAnnotation = $this->reader->getClassAnnotation($reflectionClass, Resource::class);
$resourceAnnotation = $this->reader->getClassAnnotation($reflectionClass, ApiResource::class);
if (null === $resourceAnnotation) {
return $this->handleNotFound($parentResourceMetadata, $resourceClass);
}
Expand All @@ -81,7 +81,7 @@ private function handleNotFound(ResourceMetadata $parentPropertyMetadata = null,
throw new ResourceClassNotFoundException(sprintf('Resource "%s" not found.', $resourceClass));
}

private function createMetadata(Resource $annotation, ResourceMetadata $parentResourceMetadata = null) : ResourceMetadata
private function createMetadata(ApiResource $annotation, ResourceMetadata $parentResourceMetadata = null) : ResourceMetadata
{
if (!$parentResourceMetadata) {
return new ResourceMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Metadata\Resource\Factory;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;
use Doctrine\Common\Annotations\Reader;

Expand Down Expand Up @@ -79,7 +79,7 @@ public function create() : ResourceNameCollection
foreach ($declared as $className) {
$reflectionClass = new \ReflectionClass($className);
$sourceFile = $reflectionClass->getFileName();
if (isset($includedFiles[$sourceFile]) && $this->reader->getClassAnnotation($reflectionClass, Resource::class)) {
if (isset($includedFiles[$sourceFile]) && $this->reader->getClassAnnotation($reflectionClass, ApiResource::class)) {
$classes[$className] = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace ApiPlatform\Core\Metadata\Resource\Factory;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Exception\ResourceClassNotFoundException;
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace ApiPlatform\Core\Metadata\Resource\Factory;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace ApiPlatform\Core\Metadata\Resource\Factory;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Exception\ResourceClassNotFoundException;
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
use Symfony\Component\Yaml\Parser as YamlParser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace ApiPlatform\Core\Metadata\Resource\Factory;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;
use Symfony\Component\Yaml\Parser as YamlParser;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

namespace ApiPlatform\Core\Tests\Annotation;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;

/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
class ResourceTest extends \PHPUnit_Framework_TestCase
class ApiResourceTest extends \PHPUnit_Framework_TestCase
{
public function testAssignation()
{
$resource = new Resource();
$resource = new ApiResource();
$resource->shortName = 'shortName';
$resource->description = 'description';
$resource->iri = 'http://example.com/res';
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/AbstractDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\Iri;
use ApiPlatform\Core\Annotation\Property;
use ApiPlatform\Core\Annotation\Resource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

Expand All @@ -22,7 +22,7 @@
*
* @author Jérémy Derussé <jeremy@derusse.com>
*
* @Resource(attributes={"filters": {"my_dummy.search", "my_dummy.order", "my_dummy.date"}})
* @ApiResource(attributes={"filters": {"my_dummy.search", "my_dummy.order", "my_dummy.date"}})
* @ORM\Entity
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string", length=16)
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/CircularReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
Expand All @@ -21,7 +21,7 @@
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @Resource(attributes={"normalization_context"={"groups": {"circular"}}})
* @ApiResource(attributes={"normalization_context"={"groups": {"circular"}}})
* @ORM\Entity
*/
class CircularReference
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/CompositeItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
* @Resource
* @ApiResource
* @ORM\Entity
*/
class CompositeItem
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/CompositeLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
* @ORM\Entity
* @Resource
* @ApiResource
*/
class CompositeLabel
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/CompositeRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
* @ORM\Entity
* @Resource
* @ApiResource
*/
class CompositeRelation
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/ConcreteDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

Expand All @@ -20,7 +20,7 @@
*
* @author Jérémy Derusse <jeremy@derusse.com>
*
* @Resource
* @ApiResource
* @ORM\Entity
*/
class ConcreteDummy extends AbstractDummy
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/CustomIdentifierDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;

/**
* Custom identifier dummy.
*
* @Resource
* @ApiResource
* @ORM\Entity
*/
class CustomIdentifierDummy
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/CustomNormalizedDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\Property;
use ApiPlatform\Core\Annotation\Resource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
Expand All @@ -22,7 +22,7 @@
*
* @author Mikaël Labrut <labrut@gmail.com>
*
* @Resource(attributes={
* @ApiResource(attributes={
* "normalization_context"={"groups"={"output"}},
* "denormalization_context"={"groups"={"input"}}
* })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;

/**
* Custom writable identifier dummy.
*
* @Resource
* @ApiResource
* @ORM\Entity
*/
class CustomWritableIdentifierDummy
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\Property;
use ApiPlatform\Core\Annotation\Resource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
Expand All @@ -22,7 +22,7 @@
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @Resource(attributes={"filters"={"my_dummy.search", "my_dummy.order", "my_dummy.date", "my_dummy.range", "my_dummy.boolean", "my_dummy.numeric"}})
* @ApiResource(attributes={"filters"={"my_dummy.search", "my_dummy.order", "my_dummy.date", "my_dummy.range", "my_dummy.boolean", "my_dummy.numeric"}})
* @ORM\Entity
*/
class Dummy
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/NoCollectionDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;

/**
* No collection dummy.
*
* @Resource(collectionOperations={})
* @ApiResource(collectionOperations={})
* @ORM\Entity
*/
class NoCollectionDummy
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/RelatedDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
Expand All @@ -21,7 +21,7 @@
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @Resource(iri="https://schema.org/Product")
* @ApiResource(iri="https://schema.org/Product")
* @ORM\Entity
*/
class RelatedDummy extends ParentDummy
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/RelationEmbedder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

Expand All @@ -20,7 +20,7 @@
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @Resource(attributes={
* @ApiResource(attributes={
* "normalization_context"={"groups"={"barcelona"}},
* "denormalization_context"={"groups"={"chicago"}},
* "hydra_context"={"@type"="hydra:Operation", "hydra:title"="A custom operation", "returns"="xmls:string"}
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/ThirdLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

Expand All @@ -20,7 +20,7 @@
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @Resource
* @ApiResource
* @ORM\Entity
*/
class ThirdLevel
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;

/**
* @ORM\Entity
* @Resource(attributes={
* @ApiResource(attributes={
* "normalization_context"={"groups"={"user", "user-read"}},
* "denormalization_context"={"groups"={"user", "user-write"}}
* })
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/UuidIdentifierDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity;

use ApiPlatform\Core\Annotation\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;

/**
* Custom identifier dummy.
*
* @Resource
* @ApiResource
* @ORM\Entity
*/
class UuidIdentifierDummy
Expand Down