<commit_before><?php
/* Copyright 2014, Zunautica Initiatives Ltd.
*  Distributed under the MIT License (http://opensource.org/licenses/MIT)
*/
namespace Teadaze;
/**
 * The abstract class for all controllers and handles the instantiation of controller objects
 *
 * This acts as the go between for views, models and the Entry object.
 * While not exactly how MVC controllers should work; they load the
 * model and view, interact with the model and pass the data to the view.
 * They pass the view back out to whatever is handling it.
 *
 * It also acts as the loader for all controllers, so you
 * use this class's static method to load an instance of a
 * controller.
 *
 * Controllers are the default go to from the first URL subdir unless
 * you use a router plugin to alias another controller. They can also 
 * be locked so they don't act as a root controller from the URL but
 * are only used in a composite.
 */
	abstract class Controller extends ControlType
	implements ControllerLoadingInterface, PluginLoadingInterface
	{
		/** @var string $name The name of the instantiated Controller */
		private $name = null;

		/** @var View $view The view object loaded by the Controller */
		private $view = null;

		/** @var string $frame (TEMPORARY) Used to define the frame, before composite controllers are working */
		private $frame = null;

		/** @var boolean $root Sets whether the controller can be called as a root controller or has to be composite (TRUE automatically) */
		private $root = true;

		/** @var Contoller $reference The reference to the final class after initalising */
		private $reference;

		/** @var ControllerLoader $controllerLoader The controller loader used for chainloading */
		protected $controllerLoader = null;

		/** @var PluginLoader $pluginLoader The plugin loader used for when loading a model */
		private $pluginLoader = null;

		/**
		 * When the object is instantiated, it is set it's name
		 * @method __construct(string $name)
		 * @param string $name The name of the controller
		 * @access public
		 */
		public function __construct($name)
		{
			$this->name = $name;
			$this->reference = $this;
		}

		public final function setControllerLoader(GenericLoader $controllerLoader) {
			$this->controllerLoader = &$controllerLoader;
		}

		public final function setPluginLoader(GenericLoader $pluginLoader) {
			$this->pluginLoader = &$pluginLoader;
		}


		/**
		 * Load a particular view
		 *
		 * This is used by child objects to load a specific
		 * view that is handled by the controller. The view
		 * is instantiated and set in the private $view
		 * property
		 *
		 * @method loadView(string $view)
		 * @param string $view The name of the view to load
		 * @access protected
		 */
		protected function loadView($view)
		{
			try { 
				$this->view = View::load($this->name, $view);
			} catch (exception $e) {
				echo $e;
			}
		}

		/**
		* this is called to load a template from the view<commit_msg>Update Controller to use the injected view loader<commit_after><?php
/* Copyright 2014, Zunautica Initiatives Ltd.
*  Distributed under the MIT License (http://opensource.org/licenses/MIT)
*/
namespace Teadaze;
/**
 * The abstract class for all controllers and handles the instantiation of controller objects
 *
 * This acts as the go between for views, models and the Entry object.
 * While not exactly how MVC controllers should work; they load the
 * model and view, interact with the model and pass the data to the view.
 * They pass the view back out to whatever is handling it.
 *
 * It also acts as the loader for all controllers, so you
 * use this class's static method to load an instance of a
 * controller.
 *
 * Controllers are the default go to from the first URL subdir unless
 * you use a router plugin to alias another controller. They can also 
 * be locked so they don't act as a root controller from the URL but
 * are only used in a composite.
 */
	abstract class Controller extends ControlType
	implements ControllerLoadingInterface, PluginLoadingInterface, ViewLoadingInterface
	{
		/** @var string $name The name of the instantiated Controller */
		private $name = null;

		/** @var View $view The view object loaded by the Controller */
		private $view = null;

		/** @var string $frame (TEMPORARY) Used to define the frame, before composite controllers are working */
		private $frame = null;

		/** @var boolean $root Sets whether the controller can be called as a root controller or has to be composite (TRUE automatically) */
		private $root = true;

		/** @var Contoller $reference The reference to the final class after initalising */
		private $reference;

		/** @var ControllerLoader $controllerLoader The controller loader used for chainloading */
		protected $controllerLoader = null;

		/** @var PluginLoader $pluginLoader The plugin loader used for when loading a model */
		private $pluginLoader = null;

		/** @var ViewLoader $viewLoader The view loader used for loading a view object */
		private $viewLoader = null;

		/**
		 * When the object is instantiated, it is set it's name
		 * @method __construct(string $name)
		 * @param string $name The name of the controller
		 * @access public
		 */
		public function __construct($name)
		{
			$this->name = $name;
			$this->reference = $this;
		}

		public final function setControllerLoader(GenericLoader $controllerLoader) {
			$this->controllerLoader = &$controllerLoader;
		}

		public final function setPluginLoader(GenericLoader $pluginLoader) {
			$this->pluginLoader = &$pluginLoader;
		}

		public final function setViewLoader(GenericLoader $viewLoader) {
			$this->viewLoader = &$viewLoader;
		}

		/**
		 * Load a particular view
		 *
		 * This is used by child objects to load a specific
		 * view that is handled by the controller. The view
		 * is instantiated and set in the private $view
		 * property
		 *
		 * @method loadView(string $view)
		 * @param string $view The name of the view to load
		 * @access protected
		 */
		protected function loadView($view)
		{
			try { 
				$this->view = $this->viewLoader->load("{$this->name}.$view");
			} catch (exception $e) {
				echo $e;
			}
		}

		/**
		* this is called to load a template from the view
{'fraction_non_alphanumeric': 0.08331992922631494, 'fraction_numerical': 0.0012867942737654818, 'mean_word_length': 3.5519765739385067, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2110210', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1590, 'n_words': 768}