In CakePHP 2.x I could insert $this->log() just about anywhere and it worked.
Was just trying to do the same in CakePHP 3 from inside the file src/Model/Entity/Bookmark.php I received an error message
"Call to undefined method App\Model\Entity\Bookmark::log()"
To fix this you need to add 2 use statements one at the top of the file and one inside the class declaration
<?php namespace App\Model\Entity; use Cake\ORM\Entity; use Cake\Collection\Collection; // add use statement for LogTrait use Cake\Log\LogTrait; class Bookmark extends Entity { // add the use LogTrait use LogTrait; protected function _getTagString() { // now you can use $this->log() $this->log(["old" => "macdonald"]); } }
0 Comments