Skip to content

Commit f2a778a

Browse files
committed
APIP: use new attribute if exists
1 parent 8407f26 commit f2a778a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Doctrine/EntityRegenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function regenerateEntities(string $classOrNamespace): void
4444
{
4545
try {
4646
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace);
47-
} catch (MappingException | LegacyCommonMappingException | PersistenceMappingException $mappingException) {
47+
} catch (MappingException|LegacyCommonMappingException|PersistenceMappingException $mappingException) {
4848
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace, true);
4949
}
5050

src/Resources/skeleton/doctrine/Entity.tpl.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
namespace <?= $namespace ?>;
44

5-
<?php if ($api_resource): ?>use ApiPlatform\Core\Annotation\ApiResource;
5+
<?php if ($api_resource && class_exists(\ApiPlatform\Metadata\ApiResource::class)): ?>use ApiPlatform\Metadata\ApiResource;
6+
<?php elseif ($api_resource): ?>use ApiPlatform\Core\Annotation\ApiResource;
67
<?php endif ?>
78
use <?= $repository_full_class_name ?>;
89
use Doctrine\ORM\Mapping as ORM;

0 commit comments

Comments
 (0)