Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Temporarily disable observers
  • Is there a way to temporarily disable all ORM observers, without for example commenting them all?
  • HarroHarro
    Accepted Answer
    Something like this would be the cleanest solution:

    class Model_Mine
        protected $_observers_enabled = true;

        public static observer_state($state = true)
            static::$_observers_enabled = (boot) $state;

        public function observe($event)
            static::$_observers_enabled and parent::observe($event);

  • I know this old, but this helped me a lot.  We needed to create an import function and in this situation I needed to set the created_at, update_by, etc with past dates.  Thanks guys :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion