示例#1
0
	/**
	 * Returns the filename of a model associated file
	 * 
	 * @param 	Atomik_Model	$model
	 * @return 	string
	 */
	public static function getFilenameFromModel(Atomik_Model $model)
	{
		$dir = self::getDirectoryFromBuilder($model->getBuilder());
		$filename = self::getFilenameFromBuilder($model->getBuilder(), $model->toArray());
		
		if (preg_match('/:[a-zA-Z0-9]+/', $filename)) {
			require_once 'Atomik/Model/Exception.php';
			throw new Atomik_Model_Exception('Some fields are missing for the filename to be complete in ' . get_class($model));
		}
		
		return $dir . $filename;
	}
示例#2
0
	public function afterSave(Atomik_Model_Builder $builder, Atomik_Model $model)
	{
		$key = $builder->name . ':' . $model->getPrimaryKey();
		$data = $model->toArray();
		
		if ($this->_memcache->replace($key, $data) === false) {
			$this->_memcache->set($key, $data);
		}
	}
示例#3
0
	/**
	 * Sets the model associated to this form
	 *
	 * @param Atomik_Model $model
	 */
	public function setModel(Atomik_Model $model, $updateData = true)
	{
		if ($model !== null && $model->getBuilder() !== $this->_builder) {
			require_once 'Atomik/Model/Exception.php';
			throw new Atomik_Model_Exception('Only models using builder ' . $this->_builder->name . ' can be used with the form');
		}
		
		$this->_model = $model;
		
		if ($model !== null && $updateData) {
			$this->setData($model->toArray(), false);
		}
	}