ORM Events

I belive i´m sure I read a discussion here from someone to ask for an afterFetch event on ORM to decode their json-encoded rows, it sounds great, and i remember Phalcon Team did already the implementation... So, guys i am not beeing able to find the discussion here, im starting to doubt it was real... please do you tell me it is implemented or how can I use it.

Oh! its a method ! ```c if (phalconmethodexistsex(object, SS("afterfetch") TSRMLSCC) == SUCCESS) { phalconcallmethod_noret(object, "afterfetch"); } ```

But what if we make it an Event... now we can make a behavior wich listens the afterFetch (to decode) and beforeSave (to Encode) and make a behavior:

$this->addBehavior( new JSONCodec(array(
    'field' => 'config_json', 
    'property' => 'config' , 
    'assoc' => TRUE 

You can do that already with afterFetch() and beforeSave() in your models:


From the docs: ```php <?php

class Robots extends Phalcon\Mvc\Model {

public $id;

public $name;

public $status;

public function beforeSave()
    //Convert the array into a string
    $this->status = join(',', $this->status);

public function afterFetch()
    //Convert the string to an array
    $this->status = explode(',', $this->status);

} ```

Instead of "explode" and "join" you can use "jsonencode" and "jsondecode" as you wish.

Yeah actually do this way but i suggest the behavior methos cause yo need less code ( and better ) to do that