Skip to content

Commit b2de365

Browse files
committed
Set default order for cms resource collections
1 parent af52794 commit b2de365

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/Entity/Core/Layout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @author Daniel West <[email protected]>
3232
*/
3333
#[Silverback\Timestamped]
34-
#[ApiResource(mercure: true)]
34+
#[ApiResource(mercure: true, order: ['createdAt' => 'DESC'])]
3535
#[ApiFilter(OrderFilter::class, properties: ['createdAt', 'reference'], arguments: ['orderParameterName' => 'order'])]
3636
#[ApiFilter(OrSearchFilter::class, properties: ['reference' => 'ipartial', 'uiComponent' => 'ipartial'])]
3737
#[UniqueEntity(fields: ['reference'], message: 'There is already a Layout with that reference.')]

src/Entity/Core/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* @author Daniel West <[email protected]>
2828
*/
29-
#[ApiResource(mercure: true)]
29+
#[ApiResource(mercure: true, order: ['createdAt' => 'DESC'])]
3030
#[ApiFilter(OrderFilter::class, properties: ['createdAt', 'reference'], arguments: ['orderParameterName' => 'order'])]
3131
#[ApiFilter(OrSearchFilter::class, properties: ['title' => 'ipartial', 'reference' => 'ipartial', 'uiComponent' => 'ipartial', 'layout.reference' => 'ipartial'])]
3232
#[ApiFilter(SearchFilter::class, properties: ['isTemplate' => 'exact'])]

src/Entity/Core/Route.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@
6161
#[ApiFilter(OrderFilter::class, properties: ['createdAt', 'path'], arguments: ['orderParameterName' => 'order'])]
6262
#[ApiFilter(OrSearchFilter::class, properties: ['path' => 'ipartial'])]
6363
#[Post]
64-
#[GetCollection]
64+
#[GetCollection(order: ['createdAt' => 'DESC'])]
6565
#[Delete(requirements: REQUIREMENTS, security: SECURITY)]
6666
#[Put(requirements: REQUIREMENTS, security: SECURITY)]
6767
#[Patch(requirements: REQUIREMENTS, security: SECURITY)]
6868
#[Get(requirements: ['id' => "(?!.+\/redirects$).+"], security: SECURITY)]
6969
// Custom endpoints
7070
#[Post(uriTemplate: '/routes/generate{._format}', validationContext: ['groups' => ['Route:generate:write']])]
71-
#[Get(uriTemplate: '/routes/{id}/redirects{._format}', defaults: ['_api_item_operation_name' => 'route_redirects'], requirements: REQUIREMENTS, normalizationContext: ['groups' => ['Route:redirect:read']], security: SECURITY)]
71+
#[Get(uriTemplate: '/routes/{id}/redirects{._format}', defaults: ['_api_item_operation_name' => 'route_redirects'], requirements: REQUIREMENTS, order: ['createdAt' => 'DESC'], normalizationContext: ['groups' => ['Route:redirect:read']], security: SECURITY)]
7272
#[Get(uriTemplate: '/routes_manifest/{id}{._format}', defaults: ['_api_item_operation_name' => 'route_resources'], requirements: REQUIREMENTS, normalizationContext: ['groups' => ['Route:manifest:read']], security: SECURITY)]
7373
#[Silverback\Timestamped]
7474
class Route

tests/Functional/TestBundle/Entity/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#[Put(security: USER_SECURITY)]
3333
#[Patch(security: USER_SECURITY)]
3434
#[Delete(security: USER_SECURITY)]
35-
#[GetCollection(security: "is_granted('ROLE_SUPER_ADMIN')")]
35+
#[GetCollection(order: ['createdAt' => 'DESC'], security: "is_granted('ROLE_SUPER_ADMIN')")]
3636
#[ORM\Entity]
3737
#[ORM\Table(name: '`user`')]
3838
class User extends AbstractUser

0 commit comments

Comments
 (0)