web/lib/Zend/Tool/Project/Provider/Project.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Tool
    16  * @package    Zend_Tool
    17  * @subpackage Framework
    17  * @subpackage Framework
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Project.php 20898 2010-02-04 07:03:46Z ralph $
    20  * @version    $Id: Project.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * @see Zend_Tool_Project_Provider_Abstract
    24  * @see Zend_Tool_Project_Provider_Abstract
    25  */
    25  */
    26 require_once 'Zend/Tool/Project/Provider/Abstract.php';
    26 require_once 'Zend/Tool/Project/Provider/Abstract.php';
    27 
    27 
    28 /**
    28 /**
    29  * @category   Zend
    29  * @category   Zend
    30  * @package    Zend_Tool
    30  * @package    Zend_Tool
    31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    33  */
    33  */
    34 class Zend_Tool_Project_Provider_Project
    34 class Zend_Tool_Project_Provider_Project
    35     extends Zend_Tool_Project_Provider_Abstract
    35     extends Zend_Tool_Project_Provider_Abstract
    36     //implements Zend_Tool_Framework_Provider_DocblockManifestInterface
    36     //implements Zend_Tool_Framework_Provider_DocblockManifestInterface
    89             ));
    89             ));
    90 
    90 
    91         $newProfile->loadFromData();
    91         $newProfile->loadFromData();
    92 
    92 
    93         $response = $this->_registry->getResponse();
    93         $response = $this->_registry->getResponse();
    94         
    94 
    95         $response->appendContent('Creating project at ' . $path);
    95         $response->appendContent('Creating project at ' . $path);
    96         $response->appendContent('Note: ', array('separator' => false, 'color' => 'yellow'));
    96         $response->appendContent('Note: ', array('separator' => false, 'color' => 'yellow'));
    97         $response->appendContent(
    97         $response->appendContent(
    98             'This command created a web project, '
    98             'This command created a web project, '
    99             . 'for more information setting up your VHOST, please see docs/README');
    99             . 'for more information setting up your VHOST, please see docs/README');
   100 
   100 
       
   101         if (!Zend_Tool_Project_Provider_Test::isPHPUnitAvailable()) {
       
   102             $response->appendContent('Testing Note: ', array('separator' => false, 'color' => 'yellow'));
       
   103             $response->appendContent('PHPUnit was not found in your include_path, therefore no testing actions will be created.');
       
   104         }
       
   105             
   101         foreach ($newProfile->getIterator() as $resource) {
   106         foreach ($newProfile->getIterator() as $resource) {
   102             $resource->create();
   107             $resource->create();
   103         }
   108         }
   104     }
   109     }
   105 
   110 
   118         }
   123         }
   119     }
   124     }
   120 
   125 
   121     protected function _getDefaultProfile()
   126     protected function _getDefaultProfile()
   122     {
   127     {
       
   128         $testAction = '';
       
   129         if (Zend_Tool_Project_Provider_Test::isPHPUnitAvailable()) {
       
   130             $testAction = '                    	<testApplicationActionMethod forActionName="index" />';
       
   131         }
       
   132         
       
   133         $version = Zend_Version::VERSION;
       
   134 
   123         $data = <<<EOS
   135         $data = <<<EOS
   124 <?xml version="1.0" encoding="UTF-8"?>
   136 <?xml version="1.0" encoding="UTF-8"?>
   125 <projectProfile type="default" version="1.10">
   137 <projectProfile type="default" version="$version">
   126     <projectDirectory>
   138     <projectDirectory>
   127         <projectProfileFile />
   139         <projectProfileFile />
   128         <applicationDirectory>
   140         <applicationDirectory>
   129             <apisDirectory enabled="false" />
       
   130             <configsDirectory>
   141             <configsDirectory>
   131                 <applicationConfigFile type="ini" />
   142                 <applicationConfigFile type="ini" />
   132             </configsDirectory>
   143             </configsDirectory>
   133             <controllersDirectory>
   144             <controllersDirectory>
   134                 <controllerFile controllerName="Index">
   145                 <controllerFile controllerName="Index">
   138             </controllersDirectory>
   149             </controllersDirectory>
   139             <formsDirectory enabled="false" />
   150             <formsDirectory enabled="false" />
   140             <layoutsDirectory enabled="false" />
   151             <layoutsDirectory enabled="false" />
   141             <modelsDirectory />
   152             <modelsDirectory />
   142             <modulesDirectory enabled="false" />
   153             <modulesDirectory enabled="false" />
       
   154             <servicesDirectory enabled="false" />
   143             <viewsDirectory>
   155             <viewsDirectory>
   144                 <viewScriptsDirectory>
   156                 <viewScriptsDirectory>
   145                     <viewControllerScriptsDirectory forControllerName="Index">
   157                     <viewControllerScriptsDirectory forControllerName="Index">
   146                         <viewScriptFile forActionName="index" />
   158                         <viewScriptFile forActionName="index" />
   147                     </viewControllerScriptsDirectory>
   159                     </viewControllerScriptsDirectory>
   177         </publicDirectory>
   189         </publicDirectory>
   178         <projectProvidersDirectory enabled="false" />
   190         <projectProvidersDirectory enabled="false" />
   179         <temporaryDirectory enabled="false" />
   191         <temporaryDirectory enabled="false" />
   180         <testsDirectory>
   192         <testsDirectory>
   181             <testPHPUnitConfigFile />
   193             <testPHPUnitConfigFile />
       
   194             <testPHPUnitBootstrapFile />
   182             <testApplicationDirectory>
   195             <testApplicationDirectory>
   183                 <testApplicationBootstrapFile />
   196                 <testApplicationControllerDirectory>
   184             </testApplicationDirectory>
   197                     <testApplicationControllerFile filesystemName="IndexControllerTest.php" forControllerName="Index">
   185             <testLibraryDirectory>
   198 $testAction
   186                 <testLibraryBootstrapFile />
   199                     </testApplicationControllerFile>
   187             </testLibraryDirectory>
   200                 </testApplicationControllerDirectory>
       
   201       	    </testApplicationDirectory>
       
   202             <testLibraryDirectory />
   188         </testsDirectory>
   203         </testsDirectory>
   189     </projectDirectory>
   204     </projectDirectory>
   190 </projectProfile>
   205 </projectProfile>
   191 EOS;
   206 EOS;
   192         return $data;
   207         return $data;
   193     }
   208     }
   194     
   209 
   195     public static function getDefaultReadmeContents($caller = null)
   210     public static function getDefaultReadmeContents($caller = null)
   196     {
   211     {
   197         $projectDirResource = $caller->getResource()->getProfile()->search('projectDirectory');
   212         $projectDirResource = $caller->getResource()->getProfile()->search('projectDirectory');
   198         if ($projectDirResource) {
   213         if ($projectDirResource) {
   199             $name = ltrim(strrchr($projectDirResource->getPath(), DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
   214             $name = ltrim(strrchr($projectDirResource->getPath(), DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
   200             $path = $projectDirResource->getPath() . '/public';
   215             $path = $projectDirResource->getPath() . '/public';
   201         } else {
   216         } else {
   202             $path = '/path/to/public';
   217             $path = '/path/to/public';
   203         }
   218         }
   204         
   219 
   205         return <<< EOS
   220         return <<< EOS
   206 README
   221 README
   207 ======
   222 ======
   208 
   223 
   209 This directory should be used to place project specfic documentation including
   224 This directory should be used to place project specfic documentation including
   210 but not limited to project notes, generated API/phpdoc documentation, or 
   225 but not limited to project notes, generated API/phpdoc documentation, or
   211 manual files generated or hand written.  Ideally, this directory would remain
   226 manual files generated or hand written.  Ideally, this directory would remain
   212 in your development environment only and should not be deployed with your
   227 in your development environment only and should not be deployed with your
   213 application to it's final production location.
   228 application to it's final production location.
   214 
   229 
   215 
   230 
   222    DocumentRoot "$path"
   237    DocumentRoot "$path"
   223    ServerName $name.local
   238    ServerName $name.local
   224 
   239 
   225    # This should be omitted in the production environment
   240    # This should be omitted in the production environment
   226    SetEnv APPLICATION_ENV development
   241    SetEnv APPLICATION_ENV development
   227     
   242 
   228    <Directory "$path">
   243    <Directory "$path">
   229        Options Indexes MultiViews FollowSymLinks
   244        Options Indexes MultiViews FollowSymLinks
   230        AllowOverride All
   245        AllowOverride All
   231        Order allow,deny
   246        Order allow,deny
   232        Allow from all
   247        Allow from all
   233    </Directory>
   248    </Directory>
   234     
   249 
   235 </VirtualHost>
   250 </VirtualHost>
   236 
   251 
   237 EOS;
   252 EOS;
   238     }
   253     }
   239 }
   254 }