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.
17 * @subpackage Framework
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: BootstrapFile.php 16971 2009-07-22 18:05:45Z mikaelkael $
24 * @see Zend_Tool_Project_Context_Filesystem_File
26 require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
28 require_once 'Zend/Application.php';
31 * This class is the front most class for utilizing Zend_Tool_Project
33 * A profile is a hierarchical set of resources that keep track of
34 * items within a specific project.
38 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
39 * @license http://framework.zend.com/license/new-bsd New BSD License
41 class Zend_Tool_Project_Context_Zf_BootstrapFile
extends Zend_Tool_Project_Context_Filesystem_File
47 protected $_filesystemName = 'Bootstrap.php';
49 protected $_applicationInstance = null;
50 protected $_bootstrapInstance = null;
57 public function getName()
59 return 'BootstrapFile';
62 public function init()
66 $applicationConfigFile = $this->_resource
->getProfile()->search('ApplicationConfigFile');
67 $applicationDirectory = $this->_resource
->getProfile()->search('ApplicationDirectory');
69 if (($applicationConfigFile === false) ||
($applicationDirectory === false)) {
70 throw new Exception('To use the BootstrapFile context, your project requires the use of both the "ApplicationConfigFile" and "ApplicationDirectory" contexts.');
73 if ($applicationConfigFile->getContext()->exists()) {
74 define('APPLICATION_PATH', $applicationDirectory->getPath());
75 $applicationOptions = array();
76 $applicationOptions['config'] = $applicationConfigFile->getPath();
78 $this->_applicationInstance
= new Zend_Application(
90 public function getContents()
92 $codeGenFile = new Zend_CodeGenerator_Php_File(array(
94 new Zend_CodeGenerator_Php_Class(array(
95 'name' => 'Bootstrap',
96 'extendedClass' => 'Zend_Application_Bootstrap_Bootstrap',
101 return $codeGenFile->generate();