HappyWorld
Well-known member
Hello.
When i tried to add code event listener i got this error :
What do you think is wrong?
When i tried to add code event listener i got this error :
Code:
Callback MyMobileDetection\Visitor\Visitor::getStructure is invalid (error_invalid_class).
- I have created add on using command line.
- I create php file in
Code:
\src\addons\MyMobileDetection\Visitor.php
- Listen to event : visitor_setup
- Event hint : empty
- Execute callback :
Code:
MyMobileDetection\Visitor\Visitor
Code:getStructure
- Enable callback execution : unchecked
PHP:
<?php
namespace MyMobileDetection;
class Visitor extends XFCP_User
{
public function isMobile()
{
return true;
}
public static function getStructure(Structure $structure)
{
$structure = parent::getStructure($structure);
$structure->getters['is_mobile'] = ['getter' => 'isMobile', 'cache' => true];
return $structure;
}
}
?>