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

Limitation when using the TwigRenderer from elsewhere than a Twig template #1

Closed
stof opened this issue Sep 2, 2011 · 1 comment · Fixed by #15
Closed

Limitation when using the TwigRenderer from elsewhere than a Twig template #1

stof opened this issue Sep 2, 2011 · 1 comment · Fixed by #15

Comments

@stof
Copy link
Collaborator

stof commented Sep 2, 2011

Due to the way Twig works, the initRuntime method is only called the first time we load a template. So when using the renderer from elsewhere than a Twig template, we need to initialize it manually (as documented)

Passing the environment to the TwigRenderer when creating it would be the solution but it is impossible currently as it would create a circular dependency. We would need to remove the need to have it as a Twig extension to do this.

https://github.com/fabpot/Twig/issues/429 would allow getting rid of this need if it is implemented. But it would mean than (the yet-to-be-released) Twig 1.2 (assuming it is added in 1.2) will become a requirement, which is an issue for Symfony2 until it becomes the release (not an issue for Silex as it already requires using the master branch)

@stof
Copy link
Collaborator Author

stof commented Sep 25, 2011

Fixed by ef1f547

@stof stof closed this as completed Sep 25, 2011
bamarni pushed a commit to bamarni/KnpMenu that referenced this issue Aug 8, 2012
…h expects argument KnpLabs#1 to be an array of default configurations and moved former argument KnpLabs#1 (charset) to argument KnpLabs#2
raziel057 added a commit to raziel057/KnpMenu that referenced this issue May 24, 2022
Currently when creating a RecursiveItemIterator passing a new ArrayIterator, the Iterator is indexed by int.

```php
$treeIterator = new \RecursiveIteratorIterator(
            new RecursiveItemIterator(
                new \ArrayIterator(array($menu))
            ), \RecursiveIteratorIterator::SELF_FIRST
        );
```

So we got the following error:

Parameter KnpLabs#1 $iterator of class Knp\Menu\Iterator\RecursiveItemIterator constructor expects
Traversable<string, Knp\Menu\ItemInterface>, ArrayIterator<int, Knp\Menu\ItemInterface> given.

I can notice that the typehint in CurrentItemFilterIterator is ok:
https://github.com/KnpLabs/KnpMenu/blob/master/src/Knp/Menu/Iterator/CurrentItemFilterIterator.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant