*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Tool / Project / Context / Zf / BootstrapFile.php
blob19ce3bd97d7435ffffa4f17e5c7c503b2f3d7d95
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
16 * @package Zend_Tool
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 $
23 /**
24 * @see Zend_Tool_Project_Context_Filesystem_File
26 require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
28 require_once 'Zend/Application.php';
30 /**
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.
36 * @category Zend
37 * @package Zend_Tool
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
44 /**
45 * @var string
47 protected $_filesystemName = 'Bootstrap.php';
49 protected $_applicationInstance = null;
50 protected $_bootstrapInstance = null;
52 /**
53 * getName()
55 * @return string
57 public function getName()
59 return 'BootstrapFile';
62 public function init()
64 parent::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(
79 'development',
80 $applicationOptions
85 /**
86 * getContents()
88 * @return array
90 public function getContents()
92 $codeGenFile = new Zend_CodeGenerator_Php_File(array(
93 'classes' => array(
94 new Zend_CodeGenerator_Php_Class(array(
95 'name' => 'Bootstrap',
96 'extendedClass' => 'Zend_Application_Bootstrap_Bootstrap',
97 )),
99 ));
101 return $codeGenFile->generate();