<?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/Search/Model/Searchable.php
*/
abstract class Plugg_Search_Model_Base_Searchable extends Sabai_Model_Entity
{
    public function __construct(Sabai_Model $model)
    {
        parent::__construct('Searchable', $model);
        $this->_vars = array('searchable_id' => 0, 'searchable_created' => 0, 'searchable_updated' => 0, 'searchable_name' => null, 'searchable_title' => null, 'searchable_plugin' => null, 'searchable_order' => 0, 'searchable_default' => 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');
    }

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


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

    protected function _setVar($name, $value)
    {
        switch ($name) {
        case 'id':
            $this->_vars['searchable_id'] = $value;
            break;
        case 'name':
            $this->_vars['searchable_name'] = trim($value);
            break;
        case 'title':
            $this->_vars['searchable_title'] = trim($value);
            break;
        case 'plugin':
            $this->_vars['searchable_plugin'] = trim($value);
            break;
        case 'order':
            $this->_vars['searchable_order'] = $value;
            break;
        case 'default':
            $this->_vars['searchable_default'] = $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 'title':
            return $this->getVar('title');
        case 'plugin':
            return $this->getVar('plugin');
        case 'order':
            return $this->getVar('order');
        case 'default':
            return $this->getVar('default');
        }
    }

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

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

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

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

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

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

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

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