Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Closure in version 1.7.3
  • I am using FuelPhp version 1. Now I am updating to 1.7.3. I have one
    problem while using view::set_global('name', closure(){}). It works on
    version 1.7 but not works in this version.

    please help me to overcome this problem.
  • My code is:
    classes/presenter/index.php
    class Presenter_Index extends Presenter
    {

        public function view()
        {
             $this->title = 'Testing this Presenter thing';
             $this->echo_upper = function($string)
                                {
                                    echo strtoupper($string);
                                   
                                };
       }
    }

    views/index.php
    <h1><?php echo $title; ?></h1>
    <?php
        $echo_upper('this string');
    ?>

    This error shows:

    Fatal Error!



    ErrorException [ Fatal Error ]:
    Function name must be a string



    APPPATH/views/index.php @ line 3


  • HarroHarro
    Accepted Answer
    See the issue.

    We know the issue exists, we don't know yet how to solve it. Further information will be added to the issue.
  • Thanks,

    Hopping to solve this problem soon.
  • Working on it. ;-)
  • HarroHarro
    Accepted Answer
    Issue is fixed in 1.8/develop.

    If you can't switch to the 1.8/dev branch, download these files:
    view class: https://raw.githubusercontent.com/fuel/core/627441c5341e698b5dd6e8553dab3879f81794c3/classes/view.php
    presenter class: https://raw.githubusercontent.com/fuel/core/627441c5341e698b5dd6e8553dab3879f81794c3/classes/presenter.php

    and replace them in fuel/core.

    Then edit your applications config.php, and add the key:

            /**
             * Whether to filter closures as well
             */
            'filter_closures'  => false,

    to have the View and Presenter classes revert to their old behaviour.
  • Thanks.

    It works and solved my problem.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion