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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ jobs:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Allow unstable project dependencies
run: composer config minimum-stability dev
- name: Update project dependencies
run: composer update --no-interaction --no-progress --ansi
- name: Require Symfony components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ final class UpgradeApiResourceCommand extends Command
private $identifiersExtractor;
private $localCache = [];

public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, SubresourceOperationFactoryInterface $subresourceOperationFactory, SubresourceTransformer $subresourceTransformer, AnnotationReader $reader, IdentifiersExtractorInterface $identifiersExtractor)
public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, SubresourceOperationFactoryInterface $subresourceOperationFactory, SubresourceTransformer $subresourceTransformer, IdentifiersExtractorInterface $identifiersExtractor, AnnotationReader $reader = null)
{
$this->resourceNameCollectionFactory = $resourceNameCollectionFactory;
$this->resourceMetadataFactory = $resourceMetadataFactory;
$this->subresourceOperationFactory = $subresourceOperationFactory;
$this->subresourceTransformer = $subresourceTransformer;
$this->reader = $reader;
$this->identifiersExtractor = $identifiersExtractor;
$this->reader = $reader;

parent::__construct();
}
Expand Down Expand Up @@ -248,6 +248,10 @@ private function readApiResource(string $resourceClass): array
return [$attributes[0]->newInstance(), false];
}

if (null === $this->reader) {
throw new \RuntimeException(sprintf('Resource "%s" not found.', $resourceClass));
}

return [$this->reader->getClassAnnotation($reflectionClass, ApiResource::class), true];
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/Resources/config/legacy/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
<argument type="service" id="api_platform.subresource_operation_factory" />
<argument type="service" id="api_platform.upgrade.subresource_transformer" />
<argument type="service" id="annotations.reader" />
<argument type="service" id="api_platform.identifiers_extractor.legacy" />
<argument type="service" id="annotations.reader" on-invalid="ignore" />
</service>
</services>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function getCommandTester(ResourceNameCollectionFactoryInterface $resour
$application->setCatchExceptions(false);
$application->setAutoExit(false);

$application->add(new UpgradeApiResourceCommand($resourceNameCollectionFactory, $resourceMetadataFactory, $subresourceOperationFactory, new SubresourceTransformer(), new AnnotationReader(), $identifiersExtractor->reveal()));
$application->add(new UpgradeApiResourceCommand($resourceNameCollectionFactory, $resourceMetadataFactory, $subresourceOperationFactory, new SubresourceTransformer(), $identifiersExtractor->reveal(), new AnnotationReader()));

$command = $application->find('api:upgrade-resource');

Expand Down