<?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/System/Model/Plugin.php
*/
abstract class Plugg_System_Model_Base_Plugin extends Sabai_Model_Entity
{
    public function __construct(Sabai_Model $model)
    {
        parent::__construct('Plugin', $model);
        $this->_vars = array('plugin_id' => 0, 'plugin_created' => 0, 'plugin_updated' => 0, 'plugin_name' => null, 'plugin_nicename' => null, 'plugin_version' => null, 'plugin_library' => null, 'plugin_params' => null, 'plugin_priority' => 0, 'plugin_active' => 1, 'plugin_locked' => 1);
    }

    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');
    }

    public function getLabel()
    {
        return $this->getVar('name');
    }


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

    protected function _setVar($name, $value)
    {
        switch ($name) {
        case 'id':
            $this->_vars['plugin_id'] = $value;
            break;
        case 'name':
            $this->_vars['plugin_name'] = trim($value);
            break;
        case 'nicename':
            $this->_vars['plugin_nicename'] = trim($value);
            break;
        case 'version':
            $this->_vars['plugin_version'] = trim($value);
            break;
        case 'library':
            $this->_vars['plugin_library'] = trim($value);
            break;
        case 'params':
            $this->_vars['plugin_params'] = trim($value);
            break;
        case 'priority':
            $this->_vars['plugin_priority'] = $value;
            break;
        case 'active':
            $this->_vars['plugin_active'] = $value;
            break;
        case 'locked':
            $this->_vars['plugin_locked'] = $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 'name':
            return $this->getVar('name');
        case 'nicename':
            return $this->getVar('nicename');
        case 'version':
            return $this->getVar('version');
        case 'library':
            return $this->getVar('library');
        case 'params':
            return $this->getVar('params');
        case 'priority':
            return $this->getVar('priority');
        case 'active':
            return $this->getVar('active');
        case 'locked':
            return $this->getVar('locked');
        }
    }

    public function __set($name, $value)
    {
        switch ($name) {
        case 'name':
            $this->setVar('name', $value);
            break;
        case 'nicename':
            $this->setVar('nicename', $value);
            break;
        case 'version':
            $this->setVar('version', $value);
            break;
        case 'library':
            $this->setVar('library', $value);
            break;
        case 'params':
            $this->setVar('params', $value);
            break;
        case 'priority':
            $this->setVar('priority', $value);
            break;
        case 'active':
            $this->setVar('active', $value);
            break;
        case 'locked':
            $this->setVar('locked', $value);
            break;
        }
    }

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

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

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

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

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

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

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