<?php
/* This file has been auto-generated. Do not edit this file directly. */
namespace SabaiApps\Directories\Component\View\Model\Base;

use SabaiApps\Framework\Model\Model;
use SabaiApps\Framework\Criteria\AbstractCriteria;
use SabaiApps\Framework\DB\AbstractRowset;
use SabaiApps\Framework\Model\AbstractEntity;
use SabaiApps\Framework\Model\AbstractEntityRepository;

abstract class Filter extends AbstractEntity
{
    public function __construct(Model $model)
    {
        parent::__construct('Filter', $model);
        $this->_vars = ['filter_name' => null, 'filter_type' => null, 'filter_data' => null, 'filter_bundle_name' => null, 'filter_field_id' => 0, 'filter_id' => 0, 'filter_created' => 0, 'filter_updated' => 0];
    }

    public function __clone()
    {
        $this->_vars = ['filter_id' => 0, 'filter_created' => 0, 'filter_updated' => 0] + $this->_vars;
    }

    public function __toString()
    {
        return $this->__get('name');
    }

    public function __get($name)
    {
        if ($name === 'name')
            return $this->_vars['filter_name'];
        elseif ($name === 'type')
            return $this->_vars['filter_type'];
        elseif ($name === 'data')
            return $this->_vars['filter_data'];
        elseif ($name === 'bundle_name')
            return $this->_vars['filter_bundle_name'];
        elseif ($name === 'field_id')
            return $this->_vars['filter_field_id'];
        elseif ($name === 'id')
            return $this->_vars['filter_id'];
        elseif ($name === 'created')
            return $this->_vars['filter_created'];
        elseif ($name === 'updated')
            return $this->_vars['filter_updated'];
        else
            return $this->fetchObject($name);
    }

    public function __set($name, $value)
    {
        if ($name === 'name')
            $this->_setVar('filter_name', $value);
        elseif ($name === 'type')
            $this->_setVar('filter_type', $value);
        elseif ($name === 'data')
            $this->_setVar('filter_data', $value);
        elseif ($name === 'bundle_name')
            $this->_setVar('filter_bundle_name', $value);
        elseif ($name === 'field_id')
            $this->_setVar('filter_field_id', $value);
        elseif ($name === 'id')
            $this->_setVar('filter_id', $value);
        else
            $this->assignObject($name, $value);
    }

    protected function _initVar($name, $value)
    {
        if ($name === 'filter_data')
            $this->_vars['filter_data'] = @unserialize($value);
        elseif ($name === 'filter_field_id')
            $this->_vars['filter_field_id'] = (int)$value;
        elseif ($name === 'filter_id')
            $this->_vars['filter_id'] = (int)$value;
        elseif ($name === 'filter_created')
            $this->_vars['filter_created'] = (int)$value;
        elseif ($name === 'filter_updated')
            $this->_vars['filter_updated'] = (int)$value;
        else
            $this->_vars[$name] = $value;
    }
}

abstract class FilterRepository extends AbstractEntityRepository
{
    public function __construct(Model $model)
    {
        parent::__construct('Filter', $model);
    }

    protected function _getCollectionByRowset(AbstractRowset $rs)
    {
        return new FiltersByRowset($rs, $this->_model->create('Filter'), $this->_model);
    }

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

class FiltersByRowset extends \SabaiApps\Framework\Model\EntityCollection\RowsetEntityCollection
{
    public function __construct(AbstractRowset $rs, Filter $emptyEntity, Model $model)
    {
        parent::__construct('Filters', $rs, $emptyEntity, $model);
    }
}

class Filters extends \SabaiApps\Framework\Model\EntityCollection\ArrayEntityCollection
{
    public function __construct(Model $model, array $entities = [])
    {
        parent::__construct($model, 'Filters', $entities);
    }
}