Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using AppUI in Function

Tags:

php

I am translating a website and I need to input $AppUI->_('') to make translation in system admin. But, somehow I can't use it in this function.

What am I doing wrong?

Here is my script and I hope you will help me:

public function BeginCalc()
{
    if($this->getActive())
    {
        echo $AppUI->_('Calculating');
    }
    else
    {
        $this->_BeginCalculation();
        echo "Calculation has been started";
    }
}

And, when I use like this I get error Fatal error: Call to a member function _() on a non-object in. Tried to search in Stackowerflow but answers there haven't helped me in solving the problem.

like image 359
McLaren Avatar asked Dec 14 '25 02:12

McLaren


1 Answers

$AppUI does not exists in this scope. If it's global variable, you need to import it with global keyword.

But i'd rather advise you to make $AppUI object a singleton and reference to it by AppUI::getInstance()->_('Calculating');

like image 176
pamelus Avatar answered Dec 16 '25 17:12

pamelus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!