PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/application/libraries/Zend/Tool/Project/Provider/View.php

https://bitbucket.org/masnug/grc276-blog-laravel
PHP | 118 lines | 55 code | 18 blank | 45 comment | 12 complexity | 374fad97d1a5d2d015161bdeffaad164 MD5 | raw file
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Tool
  17. * @subpackage Framework
  18. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: View.php 24068 2011-05-28 19:56:54Z ralph $
  21. */
  22. /**
  23. * @see Zend_Tool_Project_Provider_Abstract
  24. */
  25. require_once 'Zend/Tool/Project/Provider/Abstract.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Tool
  29. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Tool_Project_Provider_View extends Zend_Tool_Project_Provider_Abstract
  33. {
  34. /**
  35. * createResource()
  36. *
  37. * @param Zend_Tool_Project_Profile $profile
  38. * @param string $actionName
  39. * @param string $controllerName
  40. * @param string $moduleName
  41. * @return Zend_Tool_Project_Profile_Resource
  42. */
  43. public static function createResource(Zend_Tool_Project_Profile $profile, $actionName, $controllerName, $moduleName = null)
  44. {
  45. if (!is_string($actionName)) {
  46. require_once 'Zend/Tool/Project/Provider/Exception.php';
  47. throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_View::createResource() expects \"actionName\" is the name of a controller resource to create.');
  48. }
  49. if (!is_string($controllerName)) {
  50. require_once 'Zend/Tool/Project/Provider/Exception.php';
  51. throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_View::createResource() expects \"controllerName\" is the name of a controller resource to create.');
  52. }
  53. $profileSearchParams = array();
  54. if ($moduleName) {
  55. $profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
  56. $noModuleSearch = null;
  57. } else {
  58. $noModuleSearch = array('modulesDirectory');
  59. }
  60. $profileSearchParams[] = 'viewsDirectory';
  61. $profileSearchParams[] = 'viewScriptsDirectory';
  62. if (($viewScriptsDirectory = $profile->search($profileSearchParams, $noModuleSearch)) === false) {
  63. require_once 'Zend/Tool/Project/Provider/Exception.php';
  64. throw new Zend_Tool_Project_Provider_Exception('This project does not have a viewScriptsDirectory resource.');
  65. }
  66. $profileSearchParams['viewControllerScriptsDirectory'] = array('forControllerName' => $controllerName);
  67. // @todo check if below is failing b/c of above search params
  68. if (($viewControllerScriptsDirectory = $viewScriptsDirectory->search($profileSearchParams)) === false) {
  69. $viewControllerScriptsDirectory = $viewScriptsDirectory->createResource('viewControllerScriptsDirectory', array('forControllerName' => $controllerName));
  70. }
  71. $newViewScriptFile = $viewControllerScriptsDirectory->createResource('ViewScriptFile', array('forActionName' => $actionName));
  72. return $newViewScriptFile;
  73. }
  74. /**
  75. * create()
  76. *
  77. * @param string $controllerName
  78. * @param string $actionNameOrSimpleName
  79. */
  80. public function create($controllerName, $actionNameOrSimpleName, $module = null)
  81. {
  82. if ($controllerName == '' || $actionNameOrSimpleName == '') {
  83. require_once 'Zend/Tool/Project/Provider/Exception.php';
  84. throw new Zend_Tool_Project_Provider_Exception('ControllerName and/or ActionName are empty.');
  85. }
  86. $profile = $this->_loadProfile();
  87. $view = self::createResource($profile, $actionNameOrSimpleName, $controllerName, $module);
  88. if ($this->_registry->getRequest()->isPretend()) {
  89. $this->_registry->getResponse(
  90. 'Would create a view script in location ' . $view->getContext()->getPath()
  91. );
  92. } else {
  93. $this->_registry->getResponse(
  94. 'Creating a view script in location ' . $view->getContext()->getPath()
  95. );
  96. $view->create();
  97. $this->_storeProfile();
  98. }
  99. }
  100. }