Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3917

Use custom method controller for a custom route

$
0
0

I created a custom controller for PUT item operation. I used the _invoke method to make the default action but I tried to used a custom method to a second PUT action on the same item.


I tried this configurations without success.

*         "activate"={
*             "method"="PUT",
*             "path"="/safety_rooms/{id}/activate",
*             "requirements"={"id"="\d+"},
*             "controller"=SafetyRoomPutItem::activeRoom,
*          },

but I get [Semantical Error] Couldn't find constant App\Controller\SafetyRoomPutItem::activeRoom, class App\Entity\SafetyRoom.


I tried this configurations without success.

*         "activate"={
*             "method"="PUT",
*             "path"="/safety_rooms/{id}/activate",
*             "requirements"={"id"="\d+"},
*             "controller"=SafetyRoomPutItem::class.activeRoom,
*          },

but I get [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_CURLY_BRACES, got '.' at position 1274 in class App\Entity\SafetyRoom.


I tried this configurations without success.

*         "activate"={
*             "method"="PUT",
*             "path"="/safety_rooms/{id}/activate",
*             "requirements"={"id"="\d+"},
*             "controller"=SafetyRoomPutItem::class(activeRoom),
*          },

I tried this configurations without success.

*         "activate"={
*             "method"="PUT",
*             "path"="/safety_rooms/{id}/activate",
*             "requirements"={"id"="\d+"},
*             "controller"=SafetyRoomPutItem::class:activeRoom,
*          },

I tried this configurations without success.

*         "activate"={
*             "method"="PUT",
*             "path"="/safety_rooms/{id}/activate",
*             "requirements"={"id"="\d+"},
*             "controller"=SafetyRoomPutItem:activeRoom,
*          },

I tried this configurations without success.

*         "activate"={
*             "method"="PUT",
*             "path"="/safety_rooms/{id}/activate",
*             "requirements"={"id"="\d+"},
*             "controller"=[SafetyRoomPutItem::class, "activeRoom"],
*          },

but I get [Syntax Error] Expected PlainValue, got '[' at position 1250 in class App\Entity\SafetyRoom.



Viewing all articles
Browse latest Browse all 3917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>