Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Orm
Are everthing correct with those observers?
bvn
January 2016
I have observer events are not working. This is how I do it:
class Model_Someclass extends \Orm\Model
{
protected static $_table_name = 'someclasses';
protected static $_primary_key = array('id');
...
protected static $_observers = array(
'Orm\Observer_CreatedAt' => array(
'events' => array('before_insert'),
'property' => 'created_at',
'mysql_timestamp' => false,
),
'Orm\Observer_UpdatedAt' => array(
'events' => array('before_save'),
'property' => 'updated_at',
'mysql_timestamp' => false,
)
);
public function _event_before_insert()
{
\Log::debug('Created');
}
public function _event_before_save()
{
\Log::debug('Updated');
}
}
It seems event functions never run. Maybe you will see some rough mistake, but I don't see.
Please, help. Thank you.
PS: I use fuelphp 1.8.
Harro
January 2016
Accepted Answer
You define observers to run, so they run.
If you want to define observer methods in the model itself, you need to use Observer_Self instead.
bvn
January 2016
Thank you, Harro! I found it too.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
bvn
January 2016
Harro
January 2016