private $_validators; is too strict

abstract class CModel extends CComponent implements IteratorAggregate, ArrayAccess{

private $_errors = array(); // attribute name => array of errors


private $_validators;		// validators


private $_scenario = '';	 // scenario

There is no way to change these variable in inherited classes?

at least

protected $_errors = array(); // attribute name => array of errors


protected $_validators;		// validators


protected $_scenario = '';	 // scenario

you know what I mean.

It’s there a way to set private $_validators to null again in rumtime?

Can you explain a bit more what is your need… why would you set this to null?




<?php

class Kaf_Model_Rule_Uuid extends Kaf_Model_Data{


	public 

		$uuid;

	

	public function rules(){

		return array(

			array(

				'uuid', 

				'Kaf_Validator_Member', 'callback' => 'validateUuid',

				'uuid' => $this->uuid,

				'message' => '{attribute}Invalid'

			),

		);

	}


}



Basically, I have defined some rules which will take model attributes as it’s params, But attributes is unassigned untill I use $model->attrubites = …, So after that step, I intend to set $_validators to null to force a recompiliation of the rules before validate() called, This time, ‘uuid’ => $this->uuid, will be assigned.

Since _validators is read only to me, I came up with a workaround to reset the validators:




	public function setAttributes($values, $safeOnly=true){

		parent::setAttributes($values, $safeOnly);

		

		$validatorList = $this->getValidatorList();

		$validatorList->clear();

		$validatorList->mergeWith($this->createValidators());

	}