When I visit this page: https://mysite.xyz/mymodule/sale I getting an error:
Fatal error: Uncaught Error: Call to undefined function get_special_key()
An action for https://mysite.xyz/mymodule/sale
public function executeSale() {
$this->redirect('https://auth.sandbox.ebay.com/oauth2/authorize?client_id='.get_special_key('EBAY_CLIENT_ID').'&redirect_uri='.get_special_key('EBAY_REDIRECT_URI').'&response_type=code&scope='.self::EBAY_SCOPES);
// Get the sale pictures
$q = Doctrine_Query::create()
->select('sp.id, sp.pic_order')
->from('SalePicture sp')
->where('sp.sale_id = ?', 606223)
->orderBy('pic_order')
;
$arSalePictures = $q->execute([], Doctrine::HYDRATE_ARRAY);
echo 'SALE PICTURES: ';
print_r($arSalePictures);
}
but, when I visit https://mysite.xyz/mymodule/sale while an acction is like this:
public function executeSale() {
/*
* Some
* Code
* ...
*/
$this->redirect('https://auth.sandbox.ebay.com/oauth2/authorize?client_id='.get_special_key('EBAY_CLIENT_ID').'&redirect_uri='.get_special_key('EBAY_REDIRECT_URI').'&response_type=code&scope='.self::EBAY_SCOPES);
}
everything works as expected.
The get_special_key() function is autoloaded by symfony.
Any suggestions would be helpful, thank you!
Adding this answer here because of the generic use of "function name" in the error message. This seems like the best place for the answer, given that the question text would essentially be the same. Switching from Java to PHP I wasn't aware that when calling a function within a class the use of the reference to the current object (this) is mandatory, i.e. you will get an undefined function error if you do not call the function as follows:
I actually guessed at the use of $this - I couldn't find a reference to this in the PHP manual. Added something to Reference — What does this symbol mean in PHP?. W3 Schools has something - https://www.w3schools.com/php/php_oop_classes_objects.asp.