<?php
/*
This file has been generated by the Sabai scaffold script. Do not edit this file directly.
If you need to customize the class, use the following file:
plugins/XOOPSCube/Model/Block.php
*/
abstract class Plugg_XOOPSCube_Model_Base_Block extends Sabai_Model_Entity
{
    public function __construct(Sabai_Model $model)
    {
        parent::__construct('Block', $model);
        $this->_vars = array('block_id' => 0, 'block_created' => 0, 'block_updated' => 0, 'block_plugin' => null, 'block_widget' => null, 'block_block_id' => 0);
    }

    public function getId()
    {
        return $this->getVar('id');
    }

    public function setId($value)
    {
        $this->setVar('id', $value);
    }

    public function getTimeCreated()
    {
        return $this->getVar('created');
    }

    public function getTimeUpdated()
    {
        return $this->getVar('updated');
    }

    protected function _getVar($name)
    {
        return $this->_vars['block_' . $name];
    }

    protected function _setVar($name, $value)
    {
        switch ($name) {
        case 'id':
            $this->_vars['block_id'] = $value;
            break;
        case 'plugin':
            $this->_vars['block_plugin'] = trim($value);
            break;
        case 'widget':
            $this->_vars['block_widget'] = trim($value);
            break;
        case 'block_id':
            $this->_vars['block_block_id'] = $value;
            break;
        default:
            trigger_error(sprintf('Error trying to set value for variable %s. This variable is either read-only or does not exist for this entity', $name), E_USER_WARNING);
            return false;
        }
        return true;
    }

    protected function _get($name, $sort, $order)
    {
        switch ($name) {
        case 'plugin':
            return $this->getVar('plugin');
        case 'widget':
            return $this->getVar('widget');
        case 'block_id':
            return $this->getVar('block_id');
        }
    }

    public function __set($name, $value)
    {
        switch ($name) {
        case 'plugin':
            $this->setVar('plugin', $value);
            break;
        case 'widget':
            $this->setVar('widget', $value);
            break;
        case 'block_id':
            $this->setVar('block_id', $value);
            break;
        }
    }

    public function initVar($name, $value)
    {
        switch ($name) {
        default:
            $this->_vars[$name] = $value;
            break;
        }
    }
}

abstract class Plugg_XOOPSCube_Model_Base_BlockRepository extends Sabai_Model_EntityRepository
{
    public function __construct(Sabai_Model $model)
    {
        parent::__construct('Block', $model);
    }

    protected function _getCollectionByRowset(Sabai_DB_Rowset $rs)
    {
        return new Plugg_XOOPSCube_Model_Base_BlocksByRowset($rs, $this->_model->create('Block'), $this->_model);
    }

    public function createCollection(array $entities = array())
    {
        return new Plugg_XOOPSCube_Model_Base_Blocks($this->_model, $entities);
    }
}

class Plugg_XOOPSCube_Model_Base_BlocksByRowset extends Sabai_Model_EntityCollection_Rowset
{
    public function __construct(Sabai_DB_Rowset $rs, Sabai_Model_Entity $emptyEntity, Sabai_Model $model)
    {
        parent::__construct('Blocks', $rs, $emptyEntity, $model);
    }

    protected function _loadRow(Sabai_Model_Entity $entity, array $row)
    {
        $entity->initVars($row);
    }
}

class Plugg_XOOPSCube_Model_Base_Blocks extends Sabai_Model_EntityCollection_Array
{
    public function __construct(Sabai_Model $model, array $entities = array())
    {
        parent::__construct($model, 'Blocks', $entities);
    }
}