<?php

namespace App\EntityPreference;

/**
 * Class for setting/getting up preferences for users.
 */
class User extends \App\EntityPreference\BaseAbstract
{

	/**
	 * The name of the entity identifier field in the database table.
	 * @var String
	 */
	protected $field_idEntityName='idUser';


	/**
	 * This indicates if the database table stores the last update user.
	 * @var Boolean
	 */
	protected $field_lastUpdateUser=null;

	/**
	 * The cache type used - check the global configs for more details.
	 * @var String
	 */
	protected $cacheType = 'session';

	/**
	 * Used for Singleton instantiation.
	 * @param Int $idEntity
	 * @return \App\EntityPreference\BaseAbstract
	 */
	static public function getInstance($idEntity = null)
	{
		// fallback to current user id
		if (!$idEntity) {
			$idEntity = CURRENT_ID_USER;
		}

		return parent::getInstance($idEntity);

	}

	/**
	 * (non-PHPdoc)
	 * @see \App\EntityPreference\BaseAbstract::setDbTableName()
	 */
	protected function setDbTableName()
	{
		global $DBTUsersPreferences;
		$this->DBTEntityPreferences = $DBTUsersPreferences;
	}

}

