Symfony 4 - платформа API - JWT - Пользовательские операции и контроллеры - PullRequest
0 голосов
/ 03 июля 2018

Я работаю над проектом с использованием Symfony 4.1 - платформа API -jwt
Я создал пользовательскую операцию в Entity

// App\Entity
/**
 * @ApiResource(
 *  itemOperations={
 *    "get",
 *    "put",
 *    "delete",
 *    "request"={
 *      "method"="POST",
 *      "path"="/event/request",
 *      "controller"=ReservationController::class
 *    }
 *  }
 * )
 * @ORM\Entity(repositoryClass="App\Repository\EventRepository")
 */

Я создал свой метод в подходящем контроллере

public function __invoke(Event $data): ?Event
{
    $eventType = $this->getDoctrine()->getRepository(EventType::class)->findRequestType();
    $user = $this->getDoctrine()->getRepository(User::class)->find(1);
    $data->setEventType($eventType);
    $data->setUser($user);
    return $data;
}

До интеграции JWT Это работало безупречно, но теперь, когда я пытаюсь получить доступ к ресурсам, я получаю это

2018-07-03T11:19:44+00:00 [info] Matched route "api_events_request_item".
2018-07-03T11:19:44+00:00 [debug] Checking for guard authentication credentials.
2018-07-03T11:19:44+00:00 [debug] Calling getCredentials() on guard configurator.
2018-07-03T11:19:44+00:00 [debug] Passing guard token information to the GuardAuthenticationProvider
2018-07-03T11:19:44+00:00 [debug] SELECT t0.id AS id_1, t0.email AS email_2, t0.password AS password_3, t0.is_active AS is_active_4, t0.role_id AS role_id_5 FROM user t0 WHERE t0.email = ? LIMIT 1
2018-07-03T11:19:44+00:00 [info] User Deprecated: Calling Symfony\Component\Security\Core\User\UserChecker::checkPreAuth with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality.
2018-07-03T11:19:44+00:00 [info] User Deprecated: Calling Symfony\Component\Security\Core\User\UserChecker::checkPostAuth with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality.
2018-07-03T11:19:44+00:00 [info] Guard authentication successful!
2018-07-03T11:19:44+00:00 [debug] Guard authenticator set no success response: request continues.
2018-07-03T11:19:44+00:00 [debug] Remember me skipped: it is not configured for the firewall.
2018-07-03T11:19:44+00:00 [error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Not Found" at /Users/simonackermann/Sites/courses/symfony/champeryNb/vendor/api-platform/core/src/EventListener/ReadListener.php line 103
[Tue Jul  3 13:19:44 2018] 127.0.0.1:56389 [404]: /api/event/request

Вот что я получаю с помощью команды debug: router

default                          ANY      ANY      ANY    /
test                             ANY      ANY      ANY    /test
images                           ANY      ANY      ANY    /images/{name}
api_entrypoint                   ANY      ANY      ANY    /api/{index}.{_format}
api_doc                          ANY      ANY      ANY    /api/docs.{_format}
api_jsonld_context               ANY      ANY      ANY    /api/contexts/{shortName}.{_format}
api_events_get_collection        GET      ANY      ANY    /api/events.{_format}
api_events_post_collection       POST     ANY      ANY    /api/events.{_format}
api_events_get_item              GET      ANY      ANY    /api/events/{id}.{_format}
api_events_put_item              PUT      ANY      ANY    /api/events/{id}.{_format}
api_events_delete_item           DELETE   ANY      ANY    /api/events/{id}.{_format}
api_events_request_item          POST     ANY      ANY    /api/event/request
api_event_types_get_collection   GET      ANY      ANY    /api/event_types.{_format}
api_event_types_get_item         GET      ANY      ANY    /api/event_types/{id}.{_format}
api_places_get_collection        GET      ANY      ANY    /api/places.{_format}
api_places_post_collection       POST     ANY      ANY    /api/places.{_format}
api_places_get_item              GET      ANY      ANY    /api/places/{id}.{_format}
api_places_delete_item           DELETE   ANY      ANY    /api/places/{id}.{_format}
api_places_put_item              PUT      ANY      ANY    /api/places/{id}.{_format}
api_users_get_collection         GET      ANY      ANY    /api/users.{_format}
api_users_post_collection        POST     ANY      ANY    /api/users.{_format}
api_users_get_item               GET      ANY      ANY    /api/users/{id}.{_format}
api_users_delete_item            DELETE   ANY      ANY    /api/users/{id}.{_format}
api_users_put_item               PUT      ANY      ANY    /api/users/{id}.{_format}
api_users_name_item              GET      ANY      ANY    /api/user/{email}
_twig_error_test                 ANY      ANY      ANY    /_error/{code}.{_format}
api_login_check                  ANY      ANY      ANY    /api/login_check

Есть идеи?
Заранее благодарен

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...