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 @@ -19,7 +19,7 @@
* @Annotation
* @Target({"METHOD", "PROPERTY"})
*/
final class Property
final class ApiProperty
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Metadata\Property\Factory;

use ApiPlatform\Core\Annotation\Property;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Exception\PropertyNotFoundException;
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
use ApiPlatform\Core\Util\Reflection;
Expand Down Expand Up @@ -54,7 +54,7 @@ public function create(string $resourceClass, string $property, array $options =
}

if ($reflectionClass->hasProperty($property)) {
$annotation = $this->reader->getPropertyAnnotation($reflectionClass->getProperty($property), Property::class);
$annotation = $this->reader->getPropertyAnnotation($reflectionClass->getProperty($property), ApiProperty::class);

if (null !== $annotation) {
return $this->createMetadata($annotation, $parentPropertyMetadata);
Expand All @@ -74,7 +74,7 @@ public function create(string $resourceClass, string $property, array $options =
continue;
}

$annotation = $this->reader->getMethodAnnotation($reflectionMethod, Property::class);
$annotation = $this->reader->getMethodAnnotation($reflectionMethod, ApiProperty::class);
if (null !== $annotation) {
return $this->createMetadata($annotation, $parentPropertyMetadata);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ private function handleNotFound(PropertyMetadata $parentPropertyMetadata = null,
throw new PropertyNotFoundException(sprintf('Property "%s" of class "%s" not found.', $property, $resourceClass));
}

private function createMetadata(Property $annotation, PropertyMetadata $parentPropertyMetadata = null) : PropertyMetadata
private function createMetadata(ApiProperty $annotation, PropertyMetadata $parentPropertyMetadata = null) : PropertyMetadata
{
if (!$parentPropertyMetadata) {
return new PropertyMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Metadata\Property\Factory;

use ApiPlatform\Core\Annotation\Property;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Exception\ResourceClassNotFoundException;
use ApiPlatform\Core\Metadata\Property\PropertyNameCollection;
use ApiPlatform\Core\Util\Reflection;
Expand Down Expand Up @@ -62,7 +62,7 @@ public function create(string $resourceClass, array $options = []) : PropertyNam

// Properties
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
if ($this->reader->getPropertyAnnotation($reflectionProperty, Property::class)) {
if ($this->reader->getPropertyAnnotation($reflectionProperty, ApiProperty::class)) {
$propertyNames[$reflectionProperty->name] = true;
}
}
Expand All @@ -71,7 +71,7 @@ public function create(string $resourceClass, array $options = []) : PropertyNam
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
$propertyName = $this->reflection->getProperty($reflectionMethod->name);

if ($propertyName && $this->reader->getMethodAnnotation($reflectionMethod, Property::class)) {
if ($propertyName && $this->reader->getMethodAnnotation($reflectionMethod, ApiProperty::class)) {
$propertyNames[$propertyName] = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Annotation/PropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ApiPlatform\Core\Tests\Annotation;

use ApiPlatform\Core\Annotation\Property;
use ApiPlatform\Core\Annotation\ApiProperty;

/**
* @author Kévin Dunglas <dunglas@gmail.com>
Expand All @@ -20,7 +20,7 @@ class PropertyTest extends \PHPUnit_Framework_TestCase
{
public function testAssignation()
{
$property = new Property();
$property = new ApiProperty();
$property->description = 'description';
$property->readable = true;
$property->writable = true;
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\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\Iri;
use ApiPlatform\Core\Annotation\Property;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

Expand Down Expand Up @@ -44,7 +44,7 @@ abstract class AbstractDummy
*
* @ORM\Column
* @Assert\NotBlank
* @Property(iri="http://schema.org/name")
* @ApiProperty(iri="http://schema.org/name")
*/
private $name;

Expand Down
6 changes: 3 additions & 3 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\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\Property;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down Expand Up @@ -44,7 +44,7 @@ class CustomNormalizedDummy
*
* @ORM\Column
* @Assert\NotBlank
* @Property(iri="http://schema.org/name")
* @ApiProperty(iri="http://schema.org/name")
* @Groups({"input", "output"})
*/
private $name;
Expand All @@ -53,7 +53,7 @@ class CustomNormalizedDummy
* @var string The dummy name alias.
*
* @ORM\Column(nullable=true)
* @Property(iri="https://schema.org/alternateName")
* @ApiProperty(iri="https://schema.org/alternateName")
* @Groups({"input", "output"})
*/
private $alias;
Expand Down
8 changes: 4 additions & 4 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\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\Property;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down Expand Up @@ -41,15 +41,15 @@ class Dummy
*
* @ORM\Column
* @Assert\NotBlank
* @Property(iri="http://schema.org/name")
* @ApiProperty(iri="http://schema.org/name")
*/
private $name;

/**
* @var string The dummy name alias.
*
* @ORM\Column(nullable=true)
* @Property(iri="https://schema.org/alternateName")
* @ApiProperty(iri="https://schema.org/alternateName")
*/
private $alias;

Expand All @@ -62,7 +62,7 @@ class Dummy
* @var string A short description of the item.
*
* @ORM\Column(nullable=true)
* @Property(iri="https://schema.org/description")
* @ApiProperty(iri="https://schema.org/description")
*/
public $description;

Expand Down