Skip to content

Commit

Permalink
use attributes for API Platform when using PHP 8+
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Apr 3, 2021
1 parent 0065779 commit b7b8402
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Resources/skeleton/doctrine/Entity.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
use Doctrine\ORM\Mapping as ORM;

/**
<?php if ($api_resource): ?> * @ApiResource()
<?php if ($api_resource && !$use_attributes): ?> * @ApiResource()
<?php endif ?>
* @ORM\Entity(repositoryClass=<?= $repository_class_name ?>::class)
<?php if ($should_escape_table_name): ?> * @ORM\Table(name="`<?= $table_name ?>`")
<?php endif ?>
*/
<?php if ($api_resource && $use_attributes): ?>
#[ApiResource]
<?php endif ?>
class <?= $class_name."\n" ?>
{
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Maker/MakeEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getTestDetails()

$content = file_get_contents($directory.'/src/Entity/User.php');
$this->assertStringContainsString('use ApiPlatform\Core\Annotation\ApiResource;', $content);
$this->assertStringContainsString('@ApiResource', $content);
$this->assertStringContainsString(\PHP_VERSION_ID >= 80000 ? '#[ApiResource]' : '@ApiResource', $content);
}),
];

Expand Down
Empty file removed tests/tmp/.gitignore
Empty file.

0 comments on commit b7b8402

Please sign in to comment.