ProjectDirectory.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Tool_Project_Context_Filesystem_Directory
  24. */
  25. require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
  26. /**
  27. * @see Zend_Tool_Project_Context_System_Interface
  28. */
  29. require_once 'Zend/Tool/Project/Context/System/Interface.php';
  30. /**
  31. * @see Zend_Tool_Project_Context_System_TopLevelRestrictable
  32. */
  33. require_once 'Zend/Tool/Project/Context/System/TopLevelRestrictable.php';
  34. /**
  35. * @see Zend_Tool_Project_Context_System_NotOverwritable
  36. */
  37. require_once 'Zend/Tool/Project/Context/System/NotOverwritable.php';
  38. /**
  39. * This class is the front most class for utilizing Zend_Tool_Project
  40. *
  41. * A profile is a hierarchical set of resources that keep track of
  42. * items within a specific project.
  43. *
  44. * @category Zend
  45. * @package Zend_Tool
  46. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  47. * @license http://framework.zend.com/license/new-bsd New BSD License
  48. */
  49. class Zend_Tool_Project_Context_System_ProjectDirectory
  50. extends Zend_Tool_Project_Context_Filesystem_Directory
  51. implements Zend_Tool_Project_Context_System_Interface,
  52. Zend_Tool_Project_Context_System_NotOverwritable,
  53. Zend_Tool_Project_Context_System_TopLevelRestrictable
  54. {
  55. /**
  56. * @var string
  57. */
  58. protected $_filesystemName = null;
  59. /**
  60. * getName()
  61. *
  62. * @return string
  63. */
  64. public function getName()
  65. {
  66. return 'ProjectDirectory';
  67. }
  68. /**
  69. * init()
  70. *
  71. * @return Zend_Tool_Project_Context_System_ProjectDirectory
  72. */
  73. public function init()
  74. {
  75. // get base path from attributes (would be in path attribute)
  76. $projectDirectory = $this->_resource->getAttribute('path');
  77. // if not, get from profile
  78. if ($projectDirectory == null) {
  79. $projectDirectory = $this->_resource->getProfile()->getAttribute('projectDirectory');
  80. }
  81. // if not, exception.
  82. if ($projectDirectory == null) {
  83. require_once 'Zend/Tool/Project/Exception.php';
  84. throw new Zend_Tool_Project_Exception('projectDirectory cannot find the directory for this project.');
  85. }
  86. $this->_baseDirectory = rtrim($projectDirectory, '\\/');
  87. return $this;
  88. }
  89. /**
  90. * create()
  91. *
  92. * @return Zend_Tool_Project_Context_System_ProjectDirectory
  93. */
  94. public function create()
  95. {
  96. if (file_exists($this->getPath())) {
  97. /*
  98. foreach (new DirectoryIterator($this->getPath()) as $item) {
  99. if (!$item->isDot()) {
  100. if ($registry->getClient()->isInteractive()) {
  101. // @todo prompt for override
  102. } else {
  103. require_once 'Zend/Tool/Project/Context/Exception.php';
  104. throw new Zend_Tool_Project_Context_Exception('This directory is not empty, project creation aborted.');
  105. }
  106. break;
  107. }
  108. }
  109. */
  110. }
  111. parent::create();
  112. return $this;
  113. }
  114. }