Hi, some good soul, please help. I am struggling with very basic thing.
I want to validate Domain entity before saving it.
I create object, set some stuff to it and then i need to access that stuff in validation method, the object is not saved yet. Simple attributes, hasOne and belongsTo relations are available, but hasMany and hasManyToMany are not. What can i do?
Validation on entities is useless without it, as i would need to check it "some other way around".
Thanks everyone.
$document = new Document();
$document->setType(new Type());
$document->setPages(array(new Page(), new Page()));
$document->save();
class Document ... {
    public function initialize() {
        $this->belongsTo('idType', 'Type', 'id', array('alias' => 'type'));
        $this->hasMany('id', 'Page', 'idDocument', array('alias' => 'pages'));
    }
    public function beforeSave() {
        $this->doValidate();
    }
    protected function doValidate() {
        // entity weren't saved yet
        // check if type is set
        $this->type; // yeah, there is a Type object here, i can check it
        // BUT: how can i check if there are some pages set?
        $this->pages; // empty Phalcon\Mvc\Model\Resultset\Simple
        // only ugly way i found is this        
        // not working (is empty) when validation model, that is fetched from DB and revalidated again
        // then i would need $this->getRelated("pages"), so i would need to script it heavilly
        $this->_related["pages"];
    }
}