<?php

namespace App\Mvc;

abstract class ModelAbstract extends \Engine\Mvc\ModelAbstract
{

	/**
	 * Stores the script's full global $CFG var.
	 * @var array
	 */
	protected $globalCfg;

	/**
	 * Stores the script's local configs.
	 * @var array
	 */
	protected $cfg;

	/**
	 * The local lang array.
	 * @var array
	 */
	protected $lang;

	/**
	 * The global lang array.
	 * @var array
	 */
	protected $globalLang;


	/**
	 * The class constructor - attaches main global vars.
	 */
	public function __construct()
	{

		// the current module path (from the namespace)
		$modulePath = getClassNamespace(get_called_class());
		$modulePathLang = str_replace("\\", "/", getClassNamespace(get_called_class())); // TODO: the cfg loader should use the same path structure

		// loads langs and configs for this module
		\Engine\Loader_Cfg::getInstance()->loadModule($modulePath);

		// attaches te lang and configs vals to the object for easy access
		$this->globalLang = 	\App\Loader_Lang::getInstance()->getAll();
		$this->lang = 			\App\Loader_Lang::getInstance()->getSection($modulePathLang);
		$this->globalCfg = 		\Engine\Loader_Cfg::getInstance()->getGlobal();
		$this->cfg = 			\Engine\Loader_Cfg::getInstance()->getLocal($modulePath);

	}

}

