File indexing completed on 2024-09-22 05:21:25

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Tool
0017  * @subpackage Framework
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * @see Zend_Tool_Project_Context_Interface
0025  */
0026 // require_once 'Zend/Tool/Project/Context/Interface.php';
0027 
0028 /**
0029  * This class is the front most class for utilizing Zend_Tool_Project
0030  *
0031  * A profile is a hierarchical set of resources that keep track of
0032  * items within a specific project.
0033  *
0034  * @category   Zend
0035  * @package    Zend_Tool
0036  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0037  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0038  */
0039 abstract class Zend_Tool_Project_Context_Filesystem_Abstract implements Zend_Tool_Project_Context_Interface
0040 {
0041 
0042     /**
0043      * @var Zend_Tool_Project_Profile_Resource
0044      */
0045     protected $_resource = null;
0046 
0047     /**
0048      * @var string
0049      */
0050     protected $_baseDirectory = null;
0051 
0052     /**
0053      * @var string
0054      */
0055     protected $_filesystemName = null;
0056 
0057     /**
0058      * init()
0059      *
0060      * @return Zend_Tool_Project_Context_Filesystem_Abstract
0061      */
0062     public function init()
0063     {
0064         $parentBaseDirectory = $this->_resource->getParentResource()->getContext()->getPath();
0065         $this->_baseDirectory = $parentBaseDirectory;
0066         return $this;
0067     }
0068 
0069     /**
0070      * setResource()
0071      *
0072      * @param Zend_Tool_Project_Profile_Resource $resource
0073      * @return Zend_Tool_Project_Context_Filesystem_Abstract
0074      */
0075     public function setResource(Zend_Tool_Project_Profile_Resource $resource)
0076     {
0077         $this->_resource = $resource;
0078         return $this;
0079     }
0080 
0081     /**
0082      * setBaseDirectory()
0083      *
0084      * @param string $baseDirectory
0085      * @return Zend_Tool_Project_Context_Filesystem_Abstract
0086      */
0087     public function setBaseDirectory($baseDirectory)
0088     {
0089         $this->_baseDirectory = rtrim(str_replace('\\', '/', $baseDirectory), '/');
0090         return $this;
0091     }
0092 
0093     /**
0094      * getBaseDirectory()
0095      *
0096      * @return string
0097      */
0098     public function getBaseDirectory()
0099     {
0100         return $this->_baseDirectory;
0101     }
0102 
0103     /**
0104      * setFilesystemName()
0105      *
0106      * @param string $filesystemName
0107      * @return Zend_Tool_Project_Context_Filesystem_Abstract
0108      */
0109     public function setFilesystemName($filesystemName)
0110     {
0111         $this->_filesystemName = $filesystemName;
0112         return $this;
0113     }
0114 
0115     /**
0116      * getFilesystemName()
0117      *
0118      * @return string
0119      */
0120     public function getFilesystemName()
0121     {
0122         return $this->_filesystemName;
0123     }
0124 
0125     /**
0126      * getPath()
0127      *
0128      * @return string
0129      */
0130     public function getPath()
0131     {
0132         $path = $this->_baseDirectory;
0133         if ($this->_filesystemName) {
0134             $path .= '/' . $this->_filesystemName;
0135         }
0136         return $path;
0137     }
0138 
0139     /**
0140      * exists()
0141      *
0142      * @return bool
0143      */
0144     public function exists()
0145     {
0146         return file_exists($this->getPath());
0147     }
0148 
0149     /**
0150      * create()
0151      *
0152      * Create this resource/context
0153      *
0154      */
0155     abstract public function create();
0156 
0157     /**
0158      * delete()
0159      *
0160      * Delete this resouce/context
0161      *
0162      */
0163     abstract public function delete();
0164 
0165 }