<?php
/* This file has been auto-generated. Do not edit this file directly. */
namespace SabaiApps\Directories\Component\Calendar\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 Occurrence extends AbstractEntity {

	public function __construct( Model $model ) {
		parent::__construct( 'Occurrence', $model );
		$this->_vars = array(
			'occurrence_entity_type'        => null,
			'occurrence_bundle_name'        => null,
			'occurrence_entity_id'          => 0,
			'occurrence_slot_field_name'    => null,
			'occurrence_slot_id'            => null,
			'occurrence_hash'               => null,
			'occurrence_title'              => null,
			'occurrence_start_date'         => 0,
			'occurrence_end_date'           => 0,
			'occurrence_all_day'            => 0,
			'occurrence_status'             => 1,
			'occurrence_slot_data_snapshot' => null,
			'occurrence_data'               => null,
			'occurrence_id'                 => 0,
			'occurrence_created'            => 0,
			'occurrence_updated'            => 0,
		);
	}

	public function __clone() {
		$this->_vars = array(
			'occurrence_id'      => 0,
			'occurrence_created' => 0,
			'occurrence_updated' => 0,
		) + $this->_vars;
	}

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

	public function __get( $name ) {
		if ( $name === 'entity_type' ) {
			return $this->_vars['occurrence_entity_type'];
		} elseif ( $name === 'bundle_name' ) {
			return $this->_vars['occurrence_bundle_name'];
		} elseif ( $name === 'entity_id' ) {
			return $this->_vars['occurrence_entity_id'];
		} elseif ( $name === 'slot_field_name' ) {
			return $this->_vars['occurrence_slot_field_name'];
		} elseif ( $name === 'slot_id' ) {
			return $this->_vars['occurrence_slot_id'];
		} elseif ( $name === 'hash' ) {
			return $this->_vars['occurrence_hash'];
		} elseif ( $name === 'title' ) {
			return $this->_vars['occurrence_title'];
		} elseif ( $name === 'start_date' ) {
			return $this->_vars['occurrence_start_date'];
		} elseif ( $name === 'end_date' ) {
			return $this->_vars['occurrence_end_date'];
		} elseif ( $name === 'all_day' ) {
			return $this->_vars['occurrence_all_day'];
		} elseif ( $name === 'status' ) {
			return $this->_vars['occurrence_status'];
		} elseif ( $name === 'slot_data_snapshot' ) {
			return $this->_vars['occurrence_slot_data_snapshot'];
		} elseif ( $name === 'data' ) {
			return $this->_vars['occurrence_data'];
		} elseif ( $name === 'id' ) {
			return $this->_vars['occurrence_id'];
		} elseif ( $name === 'created' ) {
			return $this->_vars['occurrence_created'];
		} elseif ( $name === 'updated' ) {
			return $this->_vars['occurrence_updated'];
		} else {
			return $this->fetchObject( $name );
		}
	}

	public function __set( $name, $value ) {
		if ( $name === 'entity_type' ) {
			$this->_setVar( 'occurrence_entity_type', $value );
		} elseif ( $name === 'bundle_name' ) {
			$this->_setVar( 'occurrence_bundle_name', $value );
		} elseif ( $name === 'entity_id' ) {
			$this->_setVar( 'occurrence_entity_id', $value );
		} elseif ( $name === 'slot_field_name' ) {
			$this->_setVar( 'occurrence_slot_field_name', $value );
		} elseif ( $name === 'slot_id' ) {
			$this->_setVar( 'occurrence_slot_id', $value );
		} elseif ( $name === 'hash' ) {
			$this->_setVar( 'occurrence_hash', $value );
		} elseif ( $name === 'title' ) {
			$this->_setVar( 'occurrence_title', $value );
		} elseif ( $name === 'start_date' ) {
			$this->_setVar( 'occurrence_start_date', $value );
		} elseif ( $name === 'end_date' ) {
			$this->_setVar( 'occurrence_end_date', $value );
		} elseif ( $name === 'all_day' ) {
			$this->_setVar( 'occurrence_all_day', $value );
		} elseif ( $name === 'status' ) {
			$this->_setVar( 'occurrence_status', $value );
		} elseif ( $name === 'slot_data_snapshot' ) {
			$this->_setVar( 'occurrence_slot_data_snapshot', $value );
		} elseif ( $name === 'data' ) {
			$this->_setVar( 'occurrence_data', $value );
		} elseif ( $name === 'id' ) {
			$this->_setVar( 'occurrence_id', $value );
		} else {
			$this->assignObject( $name, $value );
		}
	}

	protected function _initVar( $name, $value ) {
		if ( $name === 'occurrence_entity_id' ) {
			$this->_vars['occurrence_entity_id'] = (int) $value;
		} elseif ( $name === 'occurrence_start_date' ) {
			$this->_vars['occurrence_start_date'] = (int) $value;
		} elseif ( $name === 'occurrence_end_date' ) {
			$this->_vars['occurrence_end_date'] = (int) $value;
		} elseif ( $name === 'occurrence_all_day' ) {
			$this->_vars['occurrence_all_day'] = (int) $value;
		} elseif ( $name === 'occurrence_status' ) {
			$this->_vars['occurrence_status'] = (int) $value;
		} elseif ( $name === 'occurrence_slot_data_snapshot' ) {
			$this->_vars['occurrence_slot_data_snapshot'] = @json_decode( $value, true );
		} elseif ( $name === 'occurrence_data' ) {
			$this->_vars['occurrence_data'] = @json_decode( $value, true );
		} elseif ( $name === 'occurrence_id' ) {
			$this->_vars['occurrence_id'] = (int) $value;
		} elseif ( $name === 'occurrence_created' ) {
			$this->_vars['occurrence_created'] = (int) $value;
		} elseif ( $name === 'occurrence_updated' ) {
			$this->_vars['occurrence_updated'] = (int) $value;
		} else {
			$this->_vars[ $name ] = $value;
		}
	}
}

abstract class OccurrenceRepository extends AbstractEntityRepository {

	public function __construct( Model $model ) {
		parent::__construct( 'Occurrence', $model );
	}

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

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

class OccurrencesByRowset extends \SabaiApps\Framework\Model\EntityCollection\RowsetEntityCollection {

	public function __construct( AbstractRowset $rs, Occurrence $emptyEntity, Model $model ) {
		parent::__construct( 'Occurrences', $rs, $emptyEntity, $model );
	}
}

class Occurrences extends \SabaiApps\Framework\Model\EntityCollection\ArrayEntityCollection {

	public function __construct( Model $model, array $entities = array() ) {
		parent::__construct( $model, 'Occurrences', $entities );
	}
}
