Skip to content

Revert "alwaysIdentifier annotation option implementation" #1696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2018
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
19 changes: 0 additions & 19 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

declare(strict_types=1);

use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\AlwaysIdentifierDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Answer;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeItem;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeLabel;
Expand Down Expand Up @@ -862,24 +861,6 @@ public function thereAreDummyDateObjectsWithDummyDate(int $nb)
$this->manager->flush();
}

/**
* @Given there are AlwaysIdentifierDummies
*/
public function thereAreAlwaysIdentifierDummies()
{
$mainDummy = new AlwaysIdentifierDummy();
$relatedDummy = new AlwaysIdentifierDummy();

$this->manager->persist($relatedDummy);

$mainDummy->setParent($relatedDummy);
$mainDummy->setChildren([$relatedDummy]);
$mainDummy->setRelated([$relatedDummy]);

$this->manager->persist($mainDummy);
$this->manager->flush();
}

/**
* @Given there are :nb dummyimmutabledate objects with dummyDate
*/
Expand Down
52 changes: 0 additions & 52 deletions features/hal/always_identifier.feature

This file was deleted.

28 changes: 0 additions & 28 deletions features/json/always_identifier.feature

This file was deleted.

32 changes: 0 additions & 32 deletions features/jsonld/always_identifier.feature

This file was deleted.

5 changes: 0 additions & 5 deletions src/Annotation/ApiProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,4 @@ final class ApiProperty
* @var array
*/
public $attributes = [];

/**
* @var bool
*/
public $alwaysIdentifier;
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ private function createMetadata(ApiProperty $annotation, PropertyMetadata $paren
$annotation->identifier,
$annotation->iri,
null,
$annotation->attributes,
null,
$annotation->alwaysIdentifier
$annotation->attributes
);
}

$propertyMetadata = $parentPropertyMetadata;
foreach ([['get', 'description'], ['is', 'readable'], ['is', 'writable'], ['is', 'readableLink'], ['is', 'writableLink'], ['is', 'required'], ['get', 'iri'], ['is', 'identifier'], ['get', 'attributes'], ['is', 'alwaysIdentifier']] as $property) {
foreach ([['get', 'description'], ['is', 'readable'], ['is', 'writable'], ['is', 'readableLink'], ['is', 'writableLink'], ['is', 'required'], ['get', 'iri'], ['is', 'identifier'], ['get', 'attributes']] as $property) {
if (null !== $value = $annotation->{$property[1]}) {
$propertyMetadata = $this->createWith($propertyMetadata, $property, $value);
}
Expand Down
25 changes: 1 addition & 24 deletions src/Metadata/Property/PropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ final class PropertyMetadata
private $childInherited;
private $attributes;
private $subresource;
private $alwaysIdentifier;

public function __construct(Type $type = null, string $description = null, bool $readable = null, bool $writable = null, bool $readableLink = null, bool $writableLink = null, bool $required = null, bool $identifier = null, string $iri = null, $childInherited = null, array $attributes = null, SubresourceMetadata $subresource = null, bool $alwaysIdentifier = null)
public function __construct(Type $type = null, string $description = null, bool $readable = null, bool $writable = null, bool $readableLink = null, bool $writableLink = null, bool $required = null, bool $identifier = null, string $iri = null, $childInherited = null, array $attributes = null, SubresourceMetadata $subresource = null)
{
$this->type = $type;
$this->description = $description;
Expand All @@ -50,7 +49,6 @@ public function __construct(Type $type = null, string $description = null, bool
$this->childInherited = $childInherited;
$this->attributes = $attributes;
$this->subresource = $subresource;
$this->alwaysIdentifier = $alwaysIdentifier;
}

/**
Expand Down Expand Up @@ -383,25 +381,4 @@ public function withSubresource(SubresourceMetadata $subresource = null): self

return $metadata;
}

/**
* Returns a new instance with the given alwaysIdentifier flag.
*/
public function withAlwaysIdentifier(bool $alwaysIdentifier): self
{
$metadata = clone $this;
$metadata->alwaysIdentifier = $alwaysIdentifier;

return $metadata;
}

/**
* Is the property should be serialized as identifier ?
*
* @return bool|null
*/
public function isAlwaysIdentifier()
{
return $this->alwaysIdentifier;
}
}
8 changes: 0 additions & 8 deletions src/Serializer/AbstractItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ abstract class AbstractItemNormalizer extends AbstractObjectNormalizer
{
use ContextTrait;

const ALWAYS_IDENTIFIER = 'always_identifier';

protected $propertyNameCollectionFactory;
protected $propertyMetadataFactory;
protected $iriConverter;
Expand Down Expand Up @@ -99,10 +97,6 @@ public function normalize($object, $format = null, array $context = [])
$context['resources'][$resource] = $resource;
}

if ($context[self::ALWAYS_IDENTIFIER] ?? false) {
return $context['iri'] ?? $this->iriConverter->getIriFromItem($object);
}

return parent::normalize($object, $format, $context);
}

Expand Down Expand Up @@ -403,8 +397,6 @@ protected function getAttributeValue($object, $attribute, $format = null, array
{
$propertyMetadata = $this->propertyMetadataFactory->create($context['resource_class'], $attribute, $this->getFactoryOptions($context));

$context[self::ALWAYS_IDENTIFIER] = $propertyMetadata->isAlwaysIdentifier();

try {
$attributeValue = $this->propertyAccessor->getValue($object, $attribute);
} catch (NoSuchPropertyException $e) {
Expand Down
139 changes: 0 additions & 139 deletions tests/Fixtures/TestBundle/Entity/AlwaysIdentifierDummy.php

This file was deleted.

Loading