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

Accessing Helpers #29

Closed
HavokInspiration opened this issue Jul 20, 2016 · 2 comments
Closed

Accessing Helpers #29

HavokInspiration opened this issue Jul 20, 2016 · 2 comments

Comments

@HavokInspiration
Copy link
Member

HavokInspiration commented Jul 20, 2016

While trying the plugin, I found out I could not use the Helpers name directly as specified in the doc :

{{ Html.css('default.app.css')|raw }}

I had to call them as follows :

{{ _view.Html.css('default.app.css')|raw }}

After digging a bit, I found out that I had to change the TwigView::generateHelperList() method to the following implementation for it to work :

diff --git a/src/View/TwigView.php b/src/View/TwigView.php
index af8bc77..06ed785 100644
--- a/src/View/TwigView.php
+++ b/src/View/TwigView.php
@@ -164,7 +164,7 @@ protected function getLoader()
     protected function generateHelperList()
     {
         $registry = $this->helpers();
-        $helpers = $registry->normalizeArray($this->helpers);
+        $helpers = $registry->normalizeArray($registry->loaded());
         foreach ($helpers as $properties) {
             list(, $class) = pluginSplit($properties['class']);
             $this->helperList[$class] = $this->{$class};

I'm working with CakePHP 3.3-beta2 on a PHP 5.5.30 install.
I'm loading my Helpers in the initialize() method of my AppView class.

Is it ok if I submit a pull request with this change or do you think that could cause issues ?

@WyriHaximus
Copy link
Collaborator

Yes please submit a pull request, that will also test it against different CakePHP versions and PHP versions 👍

@HavokInspiration
Copy link
Member Author

I opened PR #31

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

2 participants