Documentation is available at BaseLoader.php
- <?php
- /**
- * MVCnPHP - BaseLoader.class.php
- *
- * This source file is subject to version 2.02 of the PHP license,
- * that is bundled with this package in the file LICENSE, and is
- * available at through the world-wide-web at
- * http://www.php.net/license/2_02.txt.
- * If you did not receive a copy of the PHP license and are unable to
- * obtain it through the world-wide-web, please send a note to
- * license@php.net so we can mail you a copy immediately.
- *
- * @author Tony Bibbs <tony@geeklog.net>
- * @copyright Tony Bibbs 2003
- * @package net.geeklog.mvc
- * @version $Id: BaseLoader.class.php,v 1.4 2004/03/23 02:38:53 tony Exp $
- *
- */
- /**
- * Mapping class which holds all data mapped to a given
- * model or view
- */
- require_once 'Mapping.php';
- /**
- * This is an abstract loader class which provides
- * 90% of all functionality to the various loaders since
- * we assume all config data will eventually be turned into
- * a PHP array
- *
- * @author Tony Bibbs <tony@geeklog.net>
- * @package net.geeklog.mvc
- *
- */
- abstract class MVCnPHP_BaseLoader {
- /**
- * @access protected
- * @var array
- */
- protected $arrayData = null;
- /**
- * Gets config data for given object in the form of
- * a mapping object
- *
- * @author Tony Bibbs <tony@geeklog.net>
- * @access public
- * @param string $name Name of object to get mapping for
- * @param array $arrayData Array of configuration data
- * @return object Mapping object
- *
- */
- public function &getMapping($name, $viewsDir, $commandsDir, $baseURL, $arrayData = '')
- {
- $mapping = new MVCnPHP_Mapping();
- if ($name == 'default') {
- $name = $this->getDefaultMapping();
- }
- if (!empty($arrayData[MVC_VIEWS][$name])) {
- $mapping->setName($arrayData[MVC_VIEWS][$name][MVC_NAME]);
- $mapping->setType('view');
- $mapping->setTypePath($viewsDir);
- } elseif (!empty($arrayData[MVC_COMMANDS][$name])) {
- $mapping->setName($arrayData[MVC_COMMANDS][$name][MVC_NAME]);
- $mapping->setType('command');
- $mapping->setTypePath($commandsDir);
- }
- $mapping->setBaseURL($baseURL);
- $mapping->setForwards($this->getForwards($name, $mapping->getType()));
- return $mapping;
- }
- /**
- * If no object was specified in the request, this will return
- * the default mapping if one was specified in the configuration
- *
- * @author Tony Bibbs <tony@geeklog.net>
- * @access private
- * @return array Mapping data for given model or view
- *
- */
- private function getDefaultMapping()
- {
- foreach ($this->arrayData[MVC_VIEWS] as $curView) {
- $curView = current($this->arrayData[MVC_VIEWS]);
- if ($curView[MVC_DEFAULT] == true) {
- return key($this->arrayData[MVC_VIEWS]);
- }
- next($this->arrayData[MVC_VIEWS]);
- }
- }
- /**
- * Gets all forwards for a given object
- *
- * @author Tony Bibbs <tony@geeklog.net>
- * @access private
- * @param string $name Name of model to get forwards for
- * @param string $type Type of object (command or view)
- * @return array Forwards for given model
- *
- */
- private function getForwards($name, $type)
- {
- if ($type == 'view') {
- return $this->arrayData[MVC_VIEWS][$name][MVC_FORWARDS];
- } else {
- return $this->arrayData[MVC_COMMANDS][$name][MVC_FORWARDS];
- }
- }
- }
Documentation generated on Mon, 7 Mar 2005 22:36:19 -0600 by phpDocumentor 1.3.0RC3