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