<?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/SimpleSearch/Model/Text.php
*/
abstract class Plugg_SimpleSearch_Model_Base_Text extends Sabai_Model_Entity
{
    public function __construct(Sabai_Model $model)
    {
        parent::__construct('Text', $model);
        $this->_vars = array('text_id' => 0, 'text_created' => 0, 'text_updated' => 0, 'text_content_id' => 0, 'text_ctime' => 0, 'text_mtime' => 0, 'text_title' => null, 'text_body' => null, 'text_author_id' => 0, 'text_searchable_id' => 0, 'text_content_group' => null, 'text_plugin' => null);
    }

    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['text_' . $name];
    }

    protected function _setVar($name, $value)
    {
        switch ($name) {
        case 'id':
            $this->_vars['text_id'] = $value;
            break;
        case 'content_id':
            $this->_vars['text_content_id'] = $value;
            break;
        case 'ctime':
            $this->_vars['text_ctime'] = $value;
            break;
        case 'mtime':
            $this->_vars['text_mtime'] = $value;
            break;
        case 'title':
            $this->_vars['text_title'] = trim($value);
            break;
        case 'body':
            $this->_vars['text_body'] = trim($value);
            break;
        case 'author_id':
            $this->_vars['text_author_id'] = $value;
            break;
        case 'searchable_id':
            $this->_vars['text_searchable_id'] = $value;
            break;
        case 'content_group':
            $this->_vars['text_content_group'] = trim($value);
            break;
        case 'plugin':
            $this->_vars['text_plugin'] = trim($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 'content_id':
            return $this->getVar('content_id');
        case 'ctime':
            return $this->getVar('ctime');
        case 'mtime':
            return $this->getVar('mtime');
        case 'title':
            return $this->getVar('title');
        case 'body':
            return $this->getVar('body');
        case 'author_id':
            return $this->getVar('author_id');
        case 'searchable_id':
            return $this->getVar('searchable_id');
        case 'content_group':
            return $this->getVar('content_group');
        case 'plugin':
            return $this->getVar('plugin');
        }
    }

    public function __set($name, $value)
    {
        switch ($name) {
        case 'content_id':
            $this->setVar('content_id', $value);
            break;
        case 'ctime':
            $this->setVar('ctime', $value);
            break;
        case 'mtime':
            $this->setVar('mtime', $value);
            break;
        case 'title':
            $this->setVar('title', $value);
            break;
        case 'body':
            $this->setVar('body', $value);
            break;
        case 'author_id':
            $this->setVar('author_id', $value);
            break;
        case 'searchable_id':
            $this->setVar('searchable_id', $value);
            break;
        case 'content_group':
            $this->setVar('content_group', $value);
            break;
        case 'plugin':
            $this->setVar('plugin', $value);
            break;
        }
    }

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

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

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

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

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

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

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