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

Unknown "spaceless" filter. #65

Closed
balvirsingh opened this issue May 22, 2019 · 17 comments
Closed

Unknown "spaceless" filter. #65

balvirsingh opened this issue May 22, 2019 · 17 comments
Labels
bug Something isn't working

Comments

@balvirsingh
Copy link

balvirsingh commented May 22, 2019

I installed this bundle on Symfony 4.2, the mentioned below issue is occurring.

Unknown "spaceless" filter.

if I remove it from twig file, then works fine.

Please provide the solution or tell me how to override the twig.

@DamienHarper
Copy link
Owner

@balvirsingh thanks for your feedback, the spaceless tag is deprecated since Twig 1.38 in favor of the spaceless filter. What version of Twig is installed in your application?

@balvirsingh
Copy link
Author

balvirsingh commented May 23, 2019

symfony/twig-bundle - v4.2.2 Symfony TwigBundle
twig/twig - v2.6.2 Twig, the flexible, fast, and secure template language for PHP

So, it's 2.6.2.

Have you checked your bundle is working on symfony 4.2 ?

@balvirsingh
Copy link
Author

balvirsingh commented May 23, 2019

Or can I override the template?

One more issue:-
When I call mentioned below method in my controller's function, it gives an error

$reader = $this->container->get('dh_doctrine_audit.reader');


Error -

Service "dh_doctrine_audit.reader" not found: even though it exists in the app's container, the container inside "App\Controller\OrganizerController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "session" and "twig" services. Try using dependency injection instead.

@balvirsingh
Copy link
Author

balvirsingh commented May 24, 2019 via email

@DamienHarper
Copy link
Owner

@balvirsingh That's quite weird. I need some more time to identify/reproduce the issue. Meanwhile, you can override the template and remove the spaceless filter call.

Regarding the reader service, you should be able to inject it in a constructor/method, for example:

public function getHistory(AuditReader $reader, string $entity, string $id, int $page = 1, int $pageSize = 500): Response
{
    // ...
}

Where do you try to access the reader: from a controller? from a command?

@balvirsingh
Copy link
Author

Yes, I am trying to access in the controller.

@DamienHarper
Copy link
Owner

@balvirsingh can you post what your controller inherits from?

@balvirsingh
Copy link
Author

`<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use App\Services\CoreService;
use App\Entity\Organizer;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;

class OrganizerController extends AbstractController
{

/**
 * To find list of organizers
 *
 * @return \Symfony\Component\HttpFoundation\Response
 */
public function list()
{   

    $reader = $this->get('dh_doctrine_audit.reader');
    
    $data = $reader
         ->filterBy(AuditReader::UPDATE)   // add this to only get `update` entries.
         ->getAudit('App\Entity\Organizer', 10)
     ;

    return $this->render('organizer/list.html.twig', [
        'no_sidebar' => true,
        'data' => $data
    ]);
}

}`

@balvirsingh
Copy link
Author

balvirsingh commented May 24, 2019 via email

@DamienHarper
Copy link
Owner

@balvirsingh your controller extends AbstractController which let you access a "limited" container that's why you cannot access the reader from there. The best solution for you here is to inject the reader service to your OrganizerController::list() method.

public function list(AuditReader $reader)
{
    // ...
}

@balvirsingh
Copy link
Author

Hi @DamienHarper,

Great!, it works now on my system. Please work on the spaceless filter. I suggest you to please remove this filter from twig as its deprecated now.

Thank you so much.

@balvirsingh
Copy link
Author

Hi @DamienHarper,

Unknown "spaceless" filter.
Have you work
image

Have you worked on the above issue? Still, I am facing the same issue. I don't want to override the templates. Please remove that filter for me or do any other alternative to make it work.

Thanks.

@DamienHarper
Copy link
Owner

@balvirsingh I have a job that keeps me very busy lately so I cannot work on this project all the time. Also, I am notified when an issue is opened/commented/closed as well as when a PR is opened/commented/declined/etc. so no need to comment + send an email + send a LinkedIn message, it won't make things happen faster.

Please, test against master branch: spaceless filter is not used anymore but the spaceless tag is. I'll release a new version in the next days.

@balvirsingh
Copy link
Author

Hi @DamienHarper,

I sincerely apologize for bothering. I will be careful in future.

Thanks.

@DamienHarper
Copy link
Owner

@balvirsingh let's forget it and move forward ;)
does the master branch solve your issue?

@balvirsingh
Copy link
Author

Hi @DamienHarper,

Yes, it does work now, Thanks

@DamienHarper
Copy link
Owner

@balvirsingh thanks for the feedback.
I close this issue as the fix will be part of next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants