Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[S4 ]View Response Listener - twig error #1844

Closed
andrzepakula opened this issue Jan 17, 2018 · 4 comments
Closed

[S4 ]View Response Listener - twig error #1844

andrzepakula opened this issue Jan 17, 2018 · 4 comments

Comments

@andrzepakula
Copy link

andrzepakula commented Jan 17, 2018

Hi. I am using S4. When I try to use the @view annotation, receives an error : There are no registered paths for namespace "FOSRest". What am I doing wrong ?

`

/**
 *@Rest\Get(
 *     "/busy-times",
 *     name="app.api.busytime.get_busy_times"
 * )
 * @Rest\View()
 */
public function getBusyTimes(): array
{
    /** @var User $user */
    $user = $this->getUser();
    $doctrine = $this->getDoctrine();

    $busyTimes = $doctrine->getRepository(BusyTime::class)->findAll();

    if (false == $user->isSuperAdmin()) {
        $decoratedBusyTimes = [];
        /** @var BusyTime $busyTime */
        foreach ($busyTimes as $busyTime) {
            $decoratedBusyTimes[] = new BusyTimeDecorator($busyTime, $this->translator);
        }
        $busyTimes = $decoratedBusyTimes;
    }

    return $busyTimes;
}

`

`
fos_rest:
param_fetcher_listener: true
serializer:
serialize_null: false
view:
view_response_listener: 'force'
body_converter:
enabled: true
validate: true
validation_errors_argument: validationErrors

`

@andrzepakula andrzepakula changed the title View Response Listener - twig error [S4 ]View Response Listener - twig error Jan 18, 2018
@janvernieuwe
Copy link

How did you solve this, i'm getting the same error in my unit tests.

@vbourdeix
Copy link

I had the same, solved it when I added the following configuration under fos_rest :

    format_listener:
        rules:
            prefer_extension: false
            fallback_format: json

@robinvdvleuten
Copy link

I had the same issue on SF 4+ and fixed it by configuring the namespaced path in Twig;

twig:
    paths:
        "%kernel.project_dir%/templates": FOSRest

@Seb33300
Copy link

If you are encountering the same error: do not open URL from a web brower.
Use postman or any other REST client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants