web/Zend/Tool/Project/Context/Filesystem/Directory.php
changeset 0 4eba9c11703f
equal deleted inserted replaced
-1:000000000000 0:4eba9c11703f
       
     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: Directory.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Tool_Project_Context_Filesystem_Abstract
       
    25  */
       
    26 require_once 'Zend/Tool/Project/Context/Filesystem/Abstract.php';
       
    27 
       
    28 /**
       
    29  * This class is the front most class for utilizing Zend_Tool_Project
       
    30  *
       
    31  * A profile is a hierarchical set of resources that keep track of
       
    32  * items within a specific project.
       
    33  *
       
    34  * @category   Zend
       
    35  * @package    Zend_Tool
       
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    38  */
       
    39 class Zend_Tool_Project_Context_Filesystem_Directory extends Zend_Tool_Project_Context_Filesystem_Abstract
       
    40 {
       
    41 
       
    42     /**
       
    43      * getName()
       
    44      * 
       
    45      * @return string
       
    46      */
       
    47     public function getName()
       
    48     {
       
    49         return 'directory';
       
    50     }
       
    51     
       
    52     /**
       
    53      * create()
       
    54      *
       
    55      * @return Zend_Tool_Project_Context_Filesystem_Directory;
       
    56      */
       
    57     public function create()
       
    58     {
       
    59         // check to ensure the parent exists, if not, call it and create it
       
    60         if (($parentResource = $this->_resource->getParentResource()) instanceof Zend_Tool_Project_Profile_Resource) {
       
    61             if ((($parentContext = $parentResource->getContext()) instanceof Zend_Tool_Project_Context_Filesystem_Abstract)
       
    62                 && (!$parentContext->exists())) {
       
    63                 $parentResource->create();
       
    64             }
       
    65         }
       
    66 
       
    67         if (!file_exists($this->getPath())) {
       
    68             mkdir($this->getPath());
       
    69         }
       
    70 
       
    71         return $this;
       
    72     }
       
    73 
       
    74     /**
       
    75      * delete()
       
    76      *
       
    77      * @return Zend_Tool_Project_Context_Filesystem_Directory
       
    78      */
       
    79     public function delete()
       
    80     {
       
    81         $this->_resource->setDeleted(true);
       
    82         rmdir($this->getPath());
       
    83 
       
    84         return $this;
       
    85     }
       
    86 
       
    87 }