PHP Fat Free Closing Kit

Does anyone know how to assign and then use closure in a model / view using F3 :: set? Or suggest a solution for the following scenario?

I am using version 1.4.4

Here is what I am trying to do:

//In Model - Loaded from controller w/ F3::call
F3::set('getPrice', function($tax, $profile){
//return price
});

//In View - Inside an F3:repeat of @products
{@getPrice(@product.tax, @product.profile)}

But closing is not supported. If I load the model using require / include, define a function w / o F3 :: set and enable user-defined functions in the view, I can make it work. But I was hoping to maintain the separation level provided with F3 :: call / F3 :: set.

Thank!

+3
source share
2 answers

, 1.4.4 , 2.0 . 2.0! :

Controller -

F3::set('func',
    function($a,$b) {
        return $a.', '.$b;
    }
);

-

{{@func('hello','world')}}

:

$foo=new stdClass;
$foo->phrase='99 bottles of beer';
F3::set('myvar',$foo);

{{@myvar->phrase}}

http://fatfree.sourceforge.net/page/views-templates

+1

, , , : F3 , . F3 , , , , . PHP - F3 . :

<?= $this->getPrice($this->product->tax, $this->product->profile) ?>

__get __call .

+1
source

Source: https://habr.com/ru/post/1793339/


All Articles