Skip to content

Commit

Permalink
minor #338 Fix some Symfony Deprecations (dannyvw)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.9-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | yes
| Related tickets | partially #335
| License         | MIT

Commits
-------

a8381bd Fix controller single colon
fbc635f Fix DataTransformer
98b1760 Fix ResourceLoader getResolver
8dcf541 Fix isFileUpload
3b0a326 Change var in RecursiveTransformer
23aa618 Update docs
59aae45 Fix CI
  • Loading branch information
Zales0123 authored Feb 28, 2022
2 parents 0580fbb + 59aae45 commit 7acdfb9
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 143 deletions.
24 changes: 12 additions & 12 deletions docs/create_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ app_book_create:
path: /books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
```
Done! Now when you go to ``/books/new``, the ResourceController will use the factory (``app.factory.book``) to create a new book instance.
Then it will try to create an ``app_book`` form, and set the newly created book as its data.
Expand Down Expand Up @@ -38,7 +38,7 @@ app_book_create:
path: /books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
template: Book/create.html.twig
```
Expand All @@ -55,7 +55,7 @@ app_book_create:
path: /books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
form: App\Form\BookType
```
Expand All @@ -73,7 +73,7 @@ app_book_create:
path: /books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
form:
type: App\Form\BookType
Expand All @@ -92,7 +92,7 @@ app_book_create:
path: /books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
factory: createNewWithAuthor
```
Expand All @@ -105,7 +105,7 @@ app_book_create:
path: /books/{author}/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
factory:
method: createNewWithAuthor
Expand All @@ -124,7 +124,7 @@ app_book_create:
path: /{authorId}/books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
factory:
method: ["expr:service('app.factory.custom_book_factory')", "createNewByAuthorId"]
Expand All @@ -145,7 +145,7 @@ app_book_create:
path: /books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
redirect: app_book_index
```
Expand All @@ -158,7 +158,7 @@ app_book_create:
path: /genre/{genreId}/books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
redirect:
route: app_genre_show
Expand All @@ -173,7 +173,7 @@ app_book_create:
path: /books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
redirect:
route: app_book_show
Expand All @@ -194,7 +194,7 @@ app_book_customer_create:
path: /customer/books/new
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
event: customer_create
```
Expand All @@ -210,7 +210,7 @@ app_genre_book_add:
path: /{genreName}/books/add
methods: [GET, POST]
defaults:
_controller: app.controller.book:createAction
_controller: app.controller.book::createAction
_sylius:
template: Book/addToGenre.html.twig
form: App\Form\BookType
Expand Down
10 changes: 5 additions & 5 deletions docs/delete_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ app_book_delete:
path: /books/{id}
methods: [DELETE]
defaults:
_controller: app.controller.book:deleteAction
_controller: app.controller.book::deleteAction
```
## Calling an Action with DELETE method
Expand Down Expand Up @@ -39,7 +39,7 @@ app_book_delete:
path: /genre/{genreId}/books/{id}
methods: [DELETE]
defaults:
_controller: app.controller.book:deleteAction
_controller: app.controller.book::deleteAction
_sylius:
criteria:
id: $id
Expand All @@ -58,7 +58,7 @@ app_book_delete:
path: /genre/{genreId}/books/{id}
methods: [DELETE]
defaults:
_controller: app.controller.book:deleteAction
_controller: app.controller.book::deleteAction
_sylius:
redirect:
route: app_genre_show
Expand All @@ -78,7 +78,7 @@ app_book_customer_delete:
path: /customer/book-delete/{id}
methods: [DELETE]
defaults:
_controller: app.controller.book:deleteAction
_controller: app.controller.book::deleteAction
_sylius:
event: customer_delete
```
Expand All @@ -96,7 +96,7 @@ app_genre_book_remove:
path: /{genreName}/books/{id}/remove
methods: [DELETE]
defaults:
_controller: app.controller.book:deleteAction
_controller: app.controller.book::deleteAction
_sylius:
event: book_delete
repository:
Expand Down
14 changes: 7 additions & 7 deletions docs/index_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ app_book_index:
path: /books
methods: [GET]
defaults:
_controller: app.controller.book:indexAction
_controller: app.controller.book::indexAction
```
When you go to ``/books``, the ResourceController will use the repository (``app.repository.book``) to create a paginator.
The default template will be rendered - ``App:Book:index.html.twig`` with the paginator as the ``books`` variable.
Expand All @@ -29,7 +29,7 @@ app_book_index_inactive:
path: /books/disabled
methods: [GET]
defaults:
_controller: app.controller.book:indexAction
_controller: app.controller.book::indexAction
_sylius:
filterable: true
criteria:
Expand All @@ -49,7 +49,7 @@ app_book_index_top:
path: /books/top
methods: [GET]
defaults:
_controller: app.controller.book:indexAction
_controller: app.controller.book::indexAction
_sylius:
sortable: true
sorting:
Expand Down Expand Up @@ -78,7 +78,7 @@ app_book_index_top:
path: /books/top
methods: [GET]
defaults:
_controller: app.controller.book:indexAction
_controller: app.controller.book::indexAction
_sylius:
paginate: 5
sortable: true
Expand All @@ -99,7 +99,7 @@ app_book_index_top3:
path: /books/top
methods: [GET]
defaults:
_controller: app.controller.book:indexAction
_controller: app.controller.book::indexAction
_sylius:
paginate: false
limit: 3
Expand All @@ -119,7 +119,7 @@ app_book_index:
path: /{author}/books
methods: [GET]
defaults:
_controller: app.controller.book:indexAction
_controller: app.controller.book::indexAction
_sylius:
serialization_groups: { 0: Default, items: [ Custom ] }
```
Expand All @@ -136,7 +136,7 @@ app_book_index:
path: /{author}/books
methods: [GET]
defaults:
_controller: app.controller.book:indexAction
_controller: app.controller.book::indexAction
_sylius:
template: Author/books.html.twig
repository:
Expand Down
12 changes: 6 additions & 6 deletions docs/show_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ app_book_show:
path: /books/{id}
methods: [GET]
defaults:
_controller: app.controller.book:showAction
_controller: app.controller.book::showAction
```
</details>
Expand Down Expand Up @@ -56,7 +56,7 @@ app_admin_book_show:
path: /admin/books/{id}
methods: [GET]
defaults:
_controller: app.controller.book:showAction
_controller: app.controller.book::showAction
_sylius:
template: Admin/Book/show.html.twig
```
Expand Down Expand Up @@ -97,7 +97,7 @@ app_book_show:
path: /books/{title}
methods: [GET]
defaults:
_controller: app.controller.book:showAction
_controller: app.controller.book::showAction
_sylius:
criteria:
title: $title
Expand Down Expand Up @@ -144,7 +144,7 @@ app_book_show:
path: /books/{author}
methods: [GET]
defaults:
_controller: app.controller.book:showAction
_controller: app.controller.book::showAction
_sylius:
repository:
method: findOneNewestByAuthor
Expand Down Expand Up @@ -189,7 +189,7 @@ app_book_show:
path: /books/{author}
methods: [GET]
defaults:
_controller: app.controller.book:showAction
_controller: app.controller.book::showAction
_sylius:
repository:
method: ["expr:service('app.repository.custom_book_repository')", "findOneNewestByAuthor"]
Expand Down Expand Up @@ -232,7 +232,7 @@ app_book_show:
path: /books/{author}
methods: [GET]
defaults:
_controller: app.controller.book:showAction
_controller: app.controller.book::showAction
_sylius:
template: Book/show.html.twig
repository:
Expand Down
20 changes: 10 additions & 10 deletions docs/update_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ app_book_update:
path: /books/{id}/edit
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
```
Done! Now when you go to ``/books/5/edit``, ResourceController will use the repository (``app.repository.book``) to find the book with id == **5**.
If found it will create the ``app_book`` form, and set the existing book as data.
Expand Down Expand Up @@ -38,7 +38,7 @@ app_book_update:
path: /books/{id}/edit
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
template: Admin/Book/update.html.twig
```
Expand All @@ -54,7 +54,7 @@ app_book_update:
path: /books/{id}/edit
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
form: App\Form\BookType
```
Expand All @@ -71,7 +71,7 @@ app_book_update:
path: /books/{id}/edit
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
form:
type: app_book_custom
Expand All @@ -90,7 +90,7 @@ app_book_update:
path: /books/{title}/edit
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
criteria: { title: $title }
```
Expand All @@ -106,7 +106,7 @@ app_book_update:
path: /books/{id}/edit
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
redirect: app_book_index
```
Expand All @@ -119,7 +119,7 @@ app_book_update:
path: /genre/{genreId}/books/{id}/edit
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
redirect:
route: app_genre_show
Expand All @@ -139,7 +139,7 @@ app_book_customer_update:
path: /customer/book-update/{id}
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
event: customer_update
```
Expand All @@ -159,7 +159,7 @@ app_book_update:
path: /books/{title}/edit
methods: [GET, PUT]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
criteria: { title: $title }
return_content: true
Expand All @@ -178,7 +178,7 @@ app_book_update:
path: /genre/{genreId}/books/{title}/edit
methods: [GET, PUT, PATCH]
defaults:
_controller: app.controller.book:updateAction
_controller: app.controller.book::updateAction
_sylius:
template: Book/editInGenre.html.twig
form: app_book_custom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ public function __construct(string $delimiter)
$this->delimiter = $delimiter;
}

public function transform($values): string
public function transform($value): string
{
if (!($values instanceof Collection)) {
if (!($value instanceof Collection)) {
throw new TransformationFailedException(
sprintf(
'Expected "%s", but got "%s"',
Collection::class,
is_object($values) ? get_class($values) : gettype($values)
is_object($value) ? get_class($value) : gettype($value)
)
);
}

if ($values->isEmpty()) {
if ($value->isEmpty()) {
return '';
}

return implode($this->delimiter, $values->toArray());
return implode($this->delimiter, $value->toArray());
}

public function reverseTransform($value): Collection
Expand Down
Loading

0 comments on commit 7acdfb9

Please sign in to comment.