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

use namespaced twig classes #127

Merged
merged 2 commits into from Dec 30, 2019
Merged

use namespaced twig classes #127

merged 2 commits into from Dec 30, 2019

Conversation

ghost
Copy link

@ghost ghost commented Dec 18, 2019

made a mistake in the previous pr, this should be okay now.

this fixes #125, fixes #122 and makes the bundle work for twig 3.x.

see https://symfony.com/blog/preparing-your-applications-for-twig-3

P̖̳͍͚̠̪̲̼̱̮͕̘̹̭̓̾̈̏́̆̊ͭ͒ͯ̋̅ͭ͛͛́͂̇̌ͅǎ̗̦̻̼̼̙͇͉̳͔͈̰̺̦̥̾̀̂̈̓ͨͭͤ̑̾̔ͣͧͣ͑ͬͭ͛ͅs͈͈̯̲͍̱̍͆̔̄̓ͣ̏̇̒̋ͯͫ͆̽ͤ̆̅̄c͈̫͔̹͓͖̲̄͂͒ͭ͐̏̉̚ͅã̩̖̩̦̫̺̻̘̾ͨ̈͋ͥ̉ͩ̿̾͆͂ͅl͉̱̙̼̩̣̀͑ͭ͗̚ added 2 commits December 18, 2019 15:07
@mikeploeger
Copy link

mikeploeger commented Dec 30, 2019

Please merge this commit @weaverryan to make it compatible with twig 3 & sf 5. Thank you!

@mikeploeger
Copy link

mikeploeger commented Dec 30, 2019

There seems to be a problem with this commit?

I added this into my composer.json:

     "require": {
         "knplabs/knp-time-bundle": "dev-master",
         ...
 },
     "repositories": [
         {
             "type": "vcs",
             "url": "https://github.com/zaggi-iwnl/KnpTimeBundle"
         }
     ],

Installation:

 % composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)         
Restricting packages listed in "symfony/symfony" to "5.0.*"
Package operations: 2 installs, 0 updates, 0 removals
   - Installing symfony/templating (v5.0.2): Loading from cache
   - Installing knplabs/knp-time-bundle (dev-master 714b0ec): Downloading (100%) Writing lock file
 Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (b25a807eab05b2a0b28d8ec443bd71ab)
   - Configuring knplabs/knp-time-bundle (>=dev-master): From auto-generated recipe
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  
!!   // Clearing the cache for the dev environment with debug                       
!!   // true                                                                        
!!  
!!  14:30:05 CRITICAL  [php] Uncaught Error: Argument 1 passed to Knp\Bundle\TimeBundle\DateTimeFormatter::__construct() must be an instance of Symfony\Component\Translation\TranslatorInterface, instance of Symfony\Component\Translation\DataCollectorTranslator given, called in /Users/USERNAME/Sites/apps/PROJECT/var/cache/dev/ContainerSKffxCI/App_KernelDevDebugContainer.php on line 1775 ["exception" => TypeError { …}]
!!  
!!  In DateTimeFormatter.php line 17:
!!                                                                                 
!!    Argument 1 passed to Knp\Bundle\TimeBundle\DateTimeFormatter::__construct()  
!!     must be an instance of Symfony\Component\Translation\TranslatorInterface,   
!!    instance of Symfony\Component\Translation\DataCollectorTranslator given, ca  
!!    lled in /Users/USERNAME/Sites/apps/PROJECT/var/cache/dev/  
!!    ContainerSKffxCI/App_KernelDevDebugContainer.php on line 1775                
!!                                                                                 
!!  
!!  cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
!!  
!!  
Script @auto-scripts was called via post-update-cmd

I have the latest Twig3 & SF5.0.2 installed.

@mikeploeger
Copy link

mikeploeger commented Dec 30, 2019

I have found a working solution, changes on DateTimeFormatter.php:

Line 5 old:
use Symfony\Component\Translation\TranslatorInterface;

Line 5 new:
use Symfony\Component\Translation\DataCollectorTranslator;

Line 17 old:
public function __construct(TranslatorInterface $translator)

Line 17 new:
public function __construct(DataCollectorTranslator $translator)

I don't get any errors now and the translation process is working fine.

@weaverryan weaverryan merged commit ab88c33 into KnpLabs:master Dec 30, 2019
@weaverryan
Copy link
Collaborator

Thank you @zaggi-iwnl!

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

Successfully merging this pull request may close these issues.

Bug on latest version of twig bundle Allow Symfony 5
3 participants