Source for file ViewFactory.php

Documentation is available at ViewFactory.php

  1. <?php
  2.  
  3. /**
  4. * MVCnPHP - ViewFactory.class.php
  5. *
  6. * This source file is subject to version 2.02 of the PHP license,
  7. * that is bundled with this package in the file LICENSE, and is
  8. * available at through the world-wide-web at
  9. * http://www.php.net/license/2_02.txt.
  10. * If you did not receive a copy of the PHP license and are unable to
  11. * obtain it through the world-wide-web, please send a note to
  12. * license@php.net so we can mail you a copy immediately.
  13. *
  14. * @author Tony Bibbs <tony@geeklog.net>
  15. * @copyright Tony Bibbs 2003
  16. * @package net.geeklog.mvc
  17. * @version $Id: ViewFactory.class.php,v 1.3 2004/03/23 02:39:35 tony Exp $
  18. *
  19. */
  20.  
  21. /**
  22. * This implements the factory design pattern and is
  23. * responsible for building view objects
  24. *
  25. * @author Tony Bibbs <tony@geeklog.net>
  26. * @package net.geeklog.mvc
  27. *
  28. */
  29. class MVCnPHP_ViewFactory {
  30. /**
  31. * Builds the requested view object
  32. *
  33. * @author Tony Bibbs <tony@geeklog.net>
  34. * @access public
  35. * @param string $path Path to directory holding views
  36. * @param string $name Name of view to create
  37. * @return object viewobject
  38. *
  39. */
  40. public function &getView($path, $name)
  41. {
  42. $filename = $path . $name . '.php';
  43. if (file_exists($filename)) {
  44. require_once($filename);
  45. return new $name();
  46. } else {
  47. throw new Exception('Bad set of parameters to ViewFactory::getView');
  48. }
  49. }
  50. }
  51.  
  52. ?>

Documentation generated on Mon, 7 Mar 2005 22:36:22 -0600 by phpDocumentor 1.3.0RC3