Skip to content

Commit 1edc22f

Browse files
committed
doctrine odm to attributes
1 parent 5fbfd94 commit 1edc22f

File tree

129 files changed

+517
-1259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+517
-1259
lines changed

tests/Fixtures/TestBundle/Document/AbsoluteUrlDummy.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,14 @@
1919
use ApiPlatform\Metadata\Link;
2020
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
2121

22-
/**
23-
* @ODM\Document
24-
*/
2522
#[ApiResource(urlGenerationStrategy: UrlGeneratorInterface::ABS_URL)]
2623
#[ApiResource(uriTemplate: '/absolute_url_relation_dummies/{id}/absolute_url_dummies.{_format}', uriVariables: ['id' => new Link(fromClass: \ApiPlatform\Tests\Fixtures\TestBundle\Document\AbsoluteUrlRelationDummy::class, identifiers: ['id'], toProperty: 'absoluteUrlRelationDummy')], status: 200, urlGenerationStrategy: UrlGeneratorInterface::ABS_URL, operations: [new GetCollection()])]
24+
#[ODM\Document]
2725
class AbsoluteUrlDummy
2826
{
29-
/**
30-
* @ODM\Id(strategy="INCREMENT", type="int")
31-
*/
27+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
3228
private $id;
33-
/**
34-
* @ODM\ReferenceOne(targetDocument=AbsoluteUrlRelationDummy::class, inversedBy="absoluteUrlDummies", storeAs="id")
35-
*/
29+
#[ODM\ReferenceOne(targetDocument: AbsoluteUrlRelationDummy::class, inversedBy: 'absoluteUrlDummies', storeAs: 'id')]
3630
public $absoluteUrlRelationDummy;
3731

3832
public function getId()

tests/Fixtures/TestBundle/Document/AbsoluteUrlRelationDummy.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@
1818
use Doctrine\Common\Collections\ArrayCollection;
1919
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
2020

21-
/**
22-
* @ODM\Document
23-
*/
2421
#[ApiResource(urlGenerationStrategy: UrlGeneratorInterface::ABS_URL)]
22+
#[ODM\Document]
2523
class AbsoluteUrlRelationDummy
2624
{
27-
/**
28-
* @ODM\Id(strategy="INCREMENT", type="int")
29-
*/
25+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
3026
private $id;
31-
/**
32-
* @ODM\ReferenceMany(targetDocument=AbsoluteUrlDummy::class, mappedBy="absoluteUrlRelationDummy")
33-
*/
27+
#[ODM\ReferenceMany(targetDocument: AbsoluteUrlDummy::class, mappedBy: 'absoluteUrlRelationDummy')]
3428
public $absoluteUrlDummies;
3529

3630
public function __construct()

tests/Fixtures/TestBundle/Document/AbstractDummy.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,25 @@
2727
* Abstract Dummy.
2828
*
2929
* @author Jérémy Derussé <[email protected]>
30-
* @ODM\Document
31-
* @ODM\InheritanceType ("SINGLE_COLLECTION")
32-
* @ODM\DiscriminatorField (value="discr")
33-
* @ODM\DiscriminatorMap ({"concrete"=ConcreteDummy::class})
3430
*/
3531
#[ApiResource(operations: [new Get(), new Put(), new Delete(), new GetCollection(), new Post()], filters: ['my_dummy.mongodb.search', 'my_dummy.mongodb.order', 'my_dummy.mongodb.date'])]
32+
#[ODM\Document]
33+
#[ODM\InheritanceType('SINGLE_COLLECTION')]
34+
#[ODM\DiscriminatorField(value: 'discr')]
35+
#[ODM\DiscriminatorMap(['concrete' => ConcreteDummy::class])]
3636
abstract class AbstractDummy
3737
{
3838
/**
3939
* @var int The id
40-
*
41-
* @ODM\Id(strategy="INCREMENT", type="int")
4240
*/
41+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
4342
private ?int $id = null;
4443
/**
4544
* @var string The dummy name
46-
*
47-
* @ODM\Field
4845
*/
4946
#[ApiProperty(types: ['http://schema.org/name'])]
5047
#[Assert\NotBlank]
48+
#[ODM\Field]
5149
private $name;
5250

5351
public function getId()

tests/Fixtures/TestBundle/Document/Address.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,15 @@
1717
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
1818
use Symfony\Component\Serializer\Annotation\Groups;
1919

20-
/**
21-
* @ODM\Document
22-
*/
2320
#[ApiResource(normalizationContext: ['groups' => ['order_read']])]
21+
#[ODM\Document]
2422
class Address
2523
{
26-
/**
27-
* @ODM\Id(strategy="INCREMENT", type="int")
28-
*/
2924
#[Groups(['order_read'])]
25+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
3026
private ?int $id = null;
31-
/**
32-
* @ODM\Field(type="string")
33-
*/
3427
#[Groups(['order_read'])]
28+
#[ODM\Field(type: 'string')]
3529
public $name;
3630

3731
public function getId()

tests/Fixtures/TestBundle/Document/Answer.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,24 @@
2727

2828
/**
2929
* Answer.
30-
*
31-
* @ODM\Document
3230
*/
3331
#[ApiResource(operations: [new Get(), new Put(), new Patch(), new Delete(), new GetCollection(normalizationContext: ['groups' => ['foobar']])])]
3432
#[ApiResource(uriTemplate: '/answers/{id}/related_questions/{relatedQuestions}/answer.{_format}', uriVariables: ['id' => new Link(fromClass: self::class, identifiers: ['id'], toProperty: 'answer'), 'relatedQuestions' => new Link(fromClass: \ApiPlatform\Tests\Fixtures\TestBundle\Document\Question::class, identifiers: ['id'], fromProperty: 'answer')], status: 200, operations: [new Get()])]
3533
#[ApiResource(uriTemplate: '/questions/{id}/answer.{_format}', uriVariables: ['id' => new Link(fromClass: \ApiPlatform\Tests\Fixtures\TestBundle\Document\Question::class, identifiers: ['id'], fromProperty: 'answer')], status: 200, operations: [new Get()])]
34+
#[ODM\Document]
3635
class Answer
3736
{
38-
/**
39-
* @ODM\Id(strategy="INCREMENT", type="int")
40-
*/
4137
#[Serializer\Groups(['foobar'])]
38+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
4239
private $id;
43-
/**
44-
* @ODM\Field(nullable=false)
45-
*/
4640
#[Serializer\Groups(['foobar'])]
41+
#[ODM\Field(nullable: false)]
4742
private $content;
48-
/**
49-
* @ODM\ReferenceOne(targetDocument=Question::class, mappedBy="answer")
50-
*/
5143
#[Serializer\Groups(['foobar'])]
44+
#[ODM\ReferenceOne(targetDocument: Question::class, mappedBy: 'answer')]
5245
private $question;
53-
/**
54-
* @ODM\ReferenceMany(targetDocument=Question::class, mappedBy="answer")
55-
*/
5646
#[Serializer\Groups(['foobar'])]
47+
#[ODM\ReferenceMany(targetDocument: Question::class, mappedBy: 'answer')]
5748
private $relatedQuestions;
5849

5950
public function __construct()

tests/Fixtures/TestBundle/Document/ArrayFilterValidator.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,22 @@
2323
*
2424
* @author Julien Deniau <[email protected]>
2525
* @author Alan Poulain <[email protected]>
26-
* @ODM\Document
2726
*/
2827
#[ApiResource(filters: [ArrayRequiredFilter::class])]
28+
#[ODM\Document]
2929
class ArrayFilterValidator
3030
{
3131
/**
3232
* @var int The id
33-
*
34-
* @ODM\Id(strategy="INCREMENT", type="int")
3533
*/
34+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
3635
private ?int $id = null;
3736

3837
/**
3938
* @var string A name
40-
*
41-
* @ODM\Field
4239
*/
4340
#[ApiProperty(types: ['http://schema.org/name'])]
41+
#[ODM\Field]
4442
private $name;
4543

4644
public function getId()

tests/Fixtures/TestBundle/Document/Book.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,16 @@
2121
* Book.
2222
*
2323
* @author Antoine Bluchet <[email protected]>
24-
* @ODM\Document
2524
*/
2625
#[ApiResource(operations: [new Get(), new Get(uriTemplate: '/books/by_isbn/{isbn}.{_format}', requirements: ['isbn' => '.+'], uriVariables: 'isbn')])]
26+
#[ODM\Document]
2727
class Book
2828
{
29-
/**
30-
* @ODM\Id(strategy="INCREMENT", type="int")
31-
*/
29+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
3230
private $id;
33-
/**
34-
* @ODM\Field(type="string", nullable=true)
35-
*/
31+
#[ODM\Field(type: 'string', nullable: true)]
3632
public $name;
37-
/**
38-
* @ODM\Field(type="string")
39-
*/
33+
#[ODM\Field(type: 'string')]
4034
public $isbn;
4135

4236
public function getId()

tests/Fixtures/TestBundle/Document/CircularReference.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,18 @@
2222
* Circular Reference.
2323
*
2424
* @author Kévin Dunglas <[email protected]>
25-
* @ODM\Document
2625
*/
2726
#[ApiResource(normalizationContext: ['groups' => ['circular']])]
27+
#[ODM\Document]
2828
class CircularReference
2929
{
30-
/**
31-
* @ODM\Id(strategy="INCREMENT", type="int")
32-
*/
30+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
3331
public $id;
34-
/**
35-
* @ODM\ReferenceOne(targetDocument=CircularReference::class, inversedBy="children")
36-
*/
3732
#[Groups(['circular'])]
33+
#[ODM\ReferenceOne(targetDocument: self::class, inversedBy: 'children')]
3834
public $parent;
39-
/**
40-
* @ODM\ReferenceMany(targetDocument=CircularReference::class, mappedBy="parent")
41-
*/
4235
#[Groups(['circular'])]
36+
#[ODM\ReferenceMany(targetDocument: self::class, mappedBy: 'parent')]
4337
public $children;
4438

4539
public function __construct()

tests/Fixtures/TestBundle/Document/Comment.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,17 @@
1717

1818
/**
1919
* @author Vincent Chalamon <[email protected]>
20-
*
21-
* @ODM\Document
2220
*/
21+
#[ODM\Document]
2322
class Comment
2423
{
25-
/**
26-
* @ODM\Id(strategy="INCREMENT", type="int")
27-
*/
24+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
2825
private $id;
29-
30-
/**
31-
* @ODM\Field(type="string")
32-
*/
26+
#[ODM\Field(type: 'string')]
3327
public $comment;
34-
35-
/**
36-
* @ODM\Field(type="date")
37-
*/
28+
#[ODM\Field(type: 'date')]
3829
public $date;
39-
40-
/**
41-
* @ODM\ReferenceOne(targetDocument=User::class, storeAs="id")
42-
*/
30+
#[ODM\ReferenceOne(targetDocument: User::class, storeAs: 'id')]
4331
public $author;
4432

4533
public function getId()

tests/Fixtures/TestBundle/Document/Company.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,25 @@
1919
use ApiPlatform\Metadata\Post;
2020
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
2121

22-
/**
23-
* @ODM\Document
24-
*/
2522
#[ApiResource]
2623
#[Get]
2724
#[Post]
2825
#[ApiResource(uriTemplate: '/employees/{employeeId}/rooms/{roomId}/company/{companyId}', uriVariables: ['employeeId' => ['from_class' => Employee::class, 'from_property' => 'company']])]
2926
#[Get]
3027
#[ApiResource(uriTemplate: '/employees/{employeeId}/company', uriVariables: ['employeeId' => ['from_class' => Employee::class, 'from_property' => 'company']])]
28+
#[ODM\Document]
3129
class Company
3230
{
3331
/**
3432
* @var int|null The id
35-
*
36-
* @ODM\Id(strategy="INCREMENT", type="int")
3733
*/
34+
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
3835
private ?int $id = null;
3936

4037
/**
4138
* @var string The dummy name
42-
*
43-
* @ODM\Field
4439
*/
40+
#[ODM\Field]
4541
public $name;
4642

4743
/** @var Employee[] */

0 commit comments

Comments
 (0)