I have a class full of static functions that I call UtilityFunctions in my Model/ directory. But that class cannot access TableRegistry::Get even though the "use" statements are in place. Below is the code and the error.
namespace App\Model\Table;
use Cake\ORM\TableRegistry;
use App\Model\Entity\Device;
class UtilityFunctions {
public static function getDevice($deviceInfo) {
$devicesTable = TableRegistry::get('Devices'); // TableRegistry not found
$query = $devicesTable->findByDeviceInfo($deviceInfo);
...
}
}
"Class \u0027UtilityFunctions\TableRegistry\u0027 not found", "/var/www/myserver/src/Model/Custom/UtilityFunctions.php",115
I know that this might be a really late reply, but it may be an issue with you not inserting use Cake\ORM\TableRegistry;
at the top of the code.
I had the same issue. I added that line of code and it worked
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With