2
0
Просмотр исходного кода

ZF-7940
- Added static configuration writer
- Added better DbTable support
- Added Form support
- Modified Layout to use static config writer

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19643 44c647ce-9c0f-0410-b52a-842ac1e357ba

ralph 16 лет назад
Родитель
Сommit
9e2ada26bf

+ 112 - 2
library/Zend/Tool/Project/Context/Zf/ApplicationConfigFile.php

@@ -45,6 +45,11 @@ class Zend_Tool_Project_Context_Zf_ApplicationConfigFile extends Zend_Tool_Proje
     protected $_filesystemName = 'application.ini';
 
     /**
+     * @var string
+     */
+    protected $_content = null;
+    
+    /**
      * getName()
      *
      * @return string
@@ -83,6 +88,111 @@ class Zend_Tool_Project_Context_Zf_ApplicationConfigFile extends Zend_Tool_Proje
      */
     public function getContents()
     {
+        if ($this->_content === null) {
+            $this->_content = $this->_getDefaultContents();
+        }
+        
+        return $this->_content;
+    }
+
+    public function getAsZendConfig($section = 'production')
+    {
+        return new Zend_Config_Ini($this->getPath(), $section);
+    }
+    
+    /**
+     * addStringItem()
+     * 
+     * @param string $key 
+     * @param string $value
+     * @param string $section
+     * @param bool   $quoteValue
+     * @return Zend_Tool_Project_Context_Zf_ApplicationConfigFile
+     */
+    public function addStringItem($key, $value, $section = 'production', $quoteValue = true)
+    {
+        if ($quoteValue) {
+            $value = '"' . $value . '"';
+        }
+        
+        $contentLines = file($this->getPath());
+        
+        $newLines = array();
+        $insideSection = false;
+        
+        foreach ($contentLines as $contentLineIndex => $contentLine) {
+            
+            if ($insideSection === false && preg_match('#^\[' . $section . '#', $contentLine)) {
+                $insideSection = true;
+            }
+            
+            if ($insideSection) {
+                if ((trim($contentLine) == null) || ($contentLines[$contentLineIndex + 1][0] == '[')) {
+                    $newLines[] = $key . ' = ' . $value . "\n";
+                    $insideSection = null;
+                }
+            }
+            
+            $newLines[] = $contentLine;
+        }
+
+        $this->_content = implode('', $newLines);
+        return $this;
+    }
+    
+    /**
+     * 
+     * @param array $item
+     * @param string $section
+     * @param bool $quoteValue
+     * @return Zend_Tool_Project_Context_Zf_ApplicationConfigFile
+     */
+    public function addItem($item, $section = 'production', $quoteValue = true)
+    {
+        $stringItems = array();
+        $stringValues = array();
+        $configKeyNames = array();
+        
+        $rii = new RecursiveIteratorIterator(
+            new RecursiveArrayIterator($item),
+            RecursiveIteratorIterator::SELF_FIRST
+            );
+        
+        $lastDepth = 0;
+        
+        // loop through array structure recursively to create proper keys
+        foreach ($rii as $name => $value) {
+            $lastDepth = $rii->getDepth();
+            
+            if (is_array($value)) {
+                array_push($configKeyNames, $name);
+            } else {
+                $stringItems[] = implode('.', $configKeyNames) . '.' . $name;
+                $stringValues[] = $value;
+            }
+        }
+        
+        foreach ($stringItems as $stringItemIndex => $stringItem) {
+            $this->addStringItem($stringItem, $stringValues[$stringItemIndex], $section, $quoteValue);
+        }
+        
+        return $this;
+    }
+    
+//    public function removeStringItem($key, $section = 'production')
+//    {
+//        
+//    }
+//    
+//    public function removeItem($item, $section = 'production')
+//    {
+//        
+//    }
+    
+    protected function _getDefaultContents()
+    {
+        // resources.log.zendmonitor.writerName = "ZendMonitor"
+        
         $contents =<<<EOS
 [production]
 phpSettings.display_startup_errors = 0
@@ -93,7 +203,6 @@ bootstrap.class = "Bootstrap"
 appnamespace = "Application"
 resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
 resources.frontController.params.displayExceptions = 0
-resources.log.zendmonitor.writerName = "ZendMonitor"
 
 [staging : production]
 
@@ -105,8 +214,9 @@ phpSettings.display_errors = 1
 phpSettings.display_startup_errors = 1
 phpSettings.display_errors = 1
 resources.frontController.params.displayExceptions = 1
+
 EOS;
         return $contents;
     }
-
+    
 }

+ 5 - 0
library/Zend/Tool/Project/Context/Zf/BootstrapFile.php

@@ -116,4 +116,9 @@ EOS;
 
         return $codeGenFile->generate();
     }
+    
+    public function getApplicationInstance()
+    {
+        return $this->_applicationInstance;
+    }
 }

+ 41 - 18
library/Zend/Tool/Project/Context/Zf/DbTableFile.php

@@ -21,11 +21,6 @@
  */
 
 /**
- * @see Zend_Tool_Project_Context_Filesystem_File
- */
-require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
-
-/**
  * This class is the front most class for utilizing Zend_Tool_Project
  *
  * A profile is a hierarchical set of resources that keep track of
@@ -36,10 +31,12 @@ require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Tool_Project_Context_Zf_DbTableFile extends Zend_Tool_Project_Context_Filesystem_File
+class Zend_Tool_Project_Context_Zf_DbTableFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
 {
 
-    protected $_dbTableName;
+    protected $_dbTableName = null;
+    
+    protected $_actualTableName = null;
     
     /**
      * getName()
@@ -51,25 +48,51 @@ class Zend_Tool_Project_Context_Zf_DbTableFile extends Zend_Tool_Project_Context
         return 'DbTableFile';
     }
 
-    public function getPersistentAttributes()
-    {
-        return array('dbTableName' => $this->_dbTableName);
-    }
-
-    public function setDbTableName($dbTableName)
+    /**
+     * init()
+     *
+     */
+    public function init()
     {
-        $this->_dbTableName = $dbTableName;
-        $this->_filesystemName = $dbTableName . '.php';
+        $this->_dbTableName = $this->_resource->getAttribute('dbTableName');
+        $this->_actualTableName = $this->_resource->getAttribute('actualTableName');
+        $this->_filesystemName = ucfirst($this->_dbTableName) . '.php';
+        parent::init();
     }
-
-    public function getDbTableName()
+    
+    public function getPersistentAttributes()
     {
-        return $this->_dbTableName;
+        return array('dbTableName' => $this->_dbTableName);
     }
 
     public function getContents()
     {
+        $className = $this->getFullClassName($this->_dbTableName, 'Model_DbTable');
         
+        $codeGenFile = new Zend_CodeGenerator_Php_File(array(
+            'fileName' => $this->getPath(),
+            'classes' => array(
+                new Zend_CodeGenerator_Php_Class(array(
+                    'name' => $className,
+                    'extendedClass' => 'Zend_Db_Table_Abstract',
+                    'properties' => array(
+                        new Zend_CodeGenerator_Php_Property(array(
+                            'name' => '_name',
+                            'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED,
+                            'defaultValue' => $this->_actualTableName
+                            ))
+                        ),
+//                    'methods' => array(
+//                        new Zend_CodeGenerator_Php_Method(array(
+//                            'name' => 'init',
+//                            'body' => '/* Form Elements & Other Definitions Here ... */',
+//                            ))
+//                        )
+                
+                    ))
+                )
+            ));
+        return $codeGenFile->generate();
     }
     
 }

+ 62 - 6
library/Zend/Tool/Project/Context/Zf/FormFile.php

@@ -21,11 +21,6 @@
  */
 
 /**
- * @see Zend_Tool_Project_Context_Filesystem_File
- */
-require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
-
-/**
  * This class is the front most class for utilizing Zend_Tool_Project
  *
  * A profile is a hierarchical set of resources that keep track of
@@ -36,10 +31,43 @@ require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Tool_Project_Context_Zf_FormFile extends Zend_Tool_Project_Context_Filesystem_File
+class Zend_Tool_Project_Context_Zf_FormFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
 {
 
     /**
+     * @var string
+     */
+    protected $_formName = 'Base';
+    
+    /**
+     * @var string
+     */
+    protected $_filesystemName = 'formName';
+    
+    /**
+     * init()
+     *
+     */
+    public function init()
+    {
+        $this->_formName = $this->_resource->getAttribute('formName');
+        $this->_filesystemName = ucfirst($this->_formName) . '.php';
+        parent::init();
+    }
+
+    /**
+     * getPersistentAttributes
+     *
+     * @return array
+     */
+    public function getPersistentAttributes()
+    {
+        return array(
+            'formName' => $this->getFormName()
+            );
+    }
+    
+    /**
      * getName()
      *
      * @return string
@@ -49,4 +77,32 @@ class Zend_Tool_Project_Context_Zf_FormFile extends Zend_Tool_Project_Context_Fi
         return 'FormFile';
     }
 
+    public function getFormName()
+    {
+        return $this->_formName;
+    }
+    
+    public function getContents()
+    {
+        
+        $className = $this->getFullClassName($this->_formName, 'Form');
+        
+        $codeGenFile = new Zend_CodeGenerator_Php_File(array(
+            'fileName' => $this->getPath(),
+            'classes' => array(
+                new Zend_CodeGenerator_Php_Class(array(
+                    'name' => $className,
+                    'extendedClass' => 'Zend_Form',
+                    'methods' => array(
+                        new Zend_CodeGenerator_Php_Method(array(
+                            'name' => 'init',
+                            'body' => '/* Form Elements & Other Definitions Here ... */',
+                            ))
+                        )
+                
+                    ))
+                )
+            ));
+        return $codeGenFile->generate();
+    }
 }

+ 0 - 12
library/Zend/Tool/Project/Context/Zf/ModelFile.php

@@ -38,11 +38,6 @@ class Zend_Tool_Project_Context_Zf_ModelFile extends Zend_Tool_Project_Context_Z
      * @var string
      */
     protected $_modelName = 'Base';
-
-    /**
-     * @var string
-     */
-    protected $_moduleName = null;
     
     /**
      * @var string
@@ -56,7 +51,6 @@ class Zend_Tool_Project_Context_Zf_ModelFile extends Zend_Tool_Project_Context_Z
     public function init()
     {
         $this->_modelName = $this->_resource->getAttribute('modelName');
-        //$this->_moduleName = $this->_resource->getAttribute('moduleName');
         $this->_filesystemName = ucfirst($this->_modelName) . '.php';
         parent::init();
     }
@@ -98,12 +92,6 @@ class Zend_Tool_Project_Context_Zf_ModelFile extends Zend_Tool_Project_Context_Z
             'classes' => array(
                 new Zend_CodeGenerator_Php_Class(array(
                     'name' => $className,
-                    //'methods' => array(
-                    //    new Zend_CodeGenerator_Php_Method(array(
-                    //        'name' => 'someMethodName',
-                    //        'body' => '/* method body here */',
-                    //    	  ))
-                    //    )
                     ))
                 )
             ));

+ 3 - 0
library/Zend/Tool/Project/Profile/FileParser/Xml.php

@@ -69,6 +69,9 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
         $this->_profile = $profile;
         $xmlElement = new SimpleXMLElement('<projectProfile />');
 
+//        $xmlElement->addAttribute('version', $profile->getVersion());
+//        $xmlElement->addAttribute('type', $profile->getType());
+        
         self::_serializeRecurser($profile, $xmlElement);
 
         $doc = new DOMDocument('1.0');

+ 66 - 8
library/Zend/Tool/Project/Provider/DbTable.php

@@ -41,7 +41,7 @@ class Zend_Tool_Project_Provider_DbTable extends Zend_Tool_Project_Provider_Abst
      */
     protected $_nameFilter = null;
     
-    public static function createResource(Zend_Tool_Project_Profile $profile, $dbTableName, $moduleName = null)
+    public static function createResource(Zend_Tool_Project_Profile $profile, $dbTableName, $actualTableName, $moduleName = null)
     {
         $profileSearchParams = array();
 
@@ -50,27 +50,86 @@ class Zend_Tool_Project_Provider_DbTable extends Zend_Tool_Project_Provider_Abst
         }
 
         $profileSearchParams[] = 'modelsDirectory';
-
+        
         $modelsDirectory = $profile->search($profileSearchParams);
         
         if (!($dbTableDirectory = $modelsDirectory->search('DbTableDirectory'))) {
             $dbTableDirectory = $modelsDirectory->createResource('DbTableDirectory');
         }
         
-        $dbTableFile = $dbTableDirectory->createResource('DbTableFile', array('dbTableName' => $dbTableName));
+        $dbTableFile = $dbTableDirectory->createResource('DbTableFile', array('dbTableName' => $dbTableName, 'actualTableName' => $actualTableName));
         
         return $dbTableFile;
     }
+    
+    public static function hasResource(Zend_Tool_Project_Profile $profile, $dbTableName, $moduleName = null)
+    {
+        $profileSearchParams = array();
+
+        if ($moduleName != null && is_string($moduleName)) {
+            $profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
+        }
+
+        $profileSearchParams[] = 'modelsDirectory';
+        
+        $modelsDirectory = $profile->search($profileSearchParams);
+        
+        if (!($dbTableDirectory = $modelsDirectory->search('DbTableDirectory'))) {
+            return false;
+        }
+        
+        $dbTableFile = $dbTableDirectory->search(array('DbTableFile' => array('dbTableName' => $dbTableName)));
+        
+        return ($dbTableFile instanceof Zend_Tool_Project_Profile_Resource) ? true : false;
+    }
       
     
-    public function create($tableName, $module = null)
+    public function create($name, $actualTableName, $module = null, $forceOverwrite = true)
     {
-        //@todo create
+        $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
+
+        if ($actualTableName == '') {
+            throw new Zend_Tool_Project_Provider_Exception('You must provide both the DbTable name as well as the actual db table\'s name.');
+        }
+        
+        if (self::hasResource($this->_loadedProfile, $name, $module)) {
+            throw new Zend_Tool_Project_Provider_Exception('This project already has a DbTable named ' . $name);
+        }
+
+        // Check that there is not a dash or underscore, return if doesnt match regex
+        if (preg_match('#[_-]#', $name)) {
+            throw new Zend_Tool_Project_Provider_Exception('DbTable names should be camel cased.');
+        }
+        
+        $name = ucwords($name);
+        
+        try {
+            $modelResource = self::createResource($this->_loadedProfile, $name, $actualTableName, $module);
+        } catch (Exception $e) {
+            $response = $this->_registry->getResponse();
+            $response->setException($e);
+            return;
+        }
+
+        // do the creation
+        if ($this->_registry->getRequest()->isPretend()) {
+
+            $this->_registry->getResponse()->appendContent('Would create a DbTable at '  . $modelResource->getContext()->getPath());
+
+        } else {
+
+            $this->_registry->getResponse()->appendContent('Creating a model at ' . $modelResource->getContext()->getPath());
+            $modelResource->create();
+
+            $this->_storeProfile();
+        }
     }
     
-    public function createFromDatabase($module = null)
+    public function createFromDatabase($module = null, $forceOverwrite = true)
     {
-        //@todo create from db
+        $bootstrapResource = $profile->search('Bootstrap');
+        $bi = $bootstrapResource->getApplicationInstance();
+        var_dump($bi);
     }
     
     protected function _convertTableNameToClassName($tableName)
@@ -81,7 +140,6 @@ class Zend_Tool_Project_Provider_DbTable extends Zend_Tool_Project_Provider_Abst
                 ->addFilter(new Zend_Filter_Word_UnderscoreToCamelCase());
         }
         
-        
         return $this->_nameFilter->filter($tableName);
     }
     

+ 120 - 2
library/Zend/Tool/Project/Provider/Form.php

@@ -29,9 +29,127 @@
 class Zend_Tool_Project_Provider_Form extends Zend_Tool_Project_Provider_Abstract
 {
 
-    public function create($name)
+    public static function createResource(Zend_Tool_Project_Profile $profile, $formName, $moduleName = null)
     {
-        echo '@todo - create form';
+        if (!is_string($formName)) {
+            throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Form::createResource() expects \"formName\" is the name of a form resource to create.');
+        }
+
+        if (!($formsDirectory = self::_getFormsDirectoryResource($profile, $moduleName))) {
+            if ($moduleName) {
+                $exceptionMessage = 'A form directory for module "' . $moduleName . '" was not found.';
+            } else {
+                $exceptionMessage = 'A form directory was not found.';
+            }
+            throw new Zend_Tool_Project_Provider_Exception($exceptionMessage);
+        }
+
+        $newForm = $formsDirectory->createResource(
+            'formFile', 
+            array('formName' => $formName, 'moduleName' => $moduleName)
+            );
+
+        return $newForm;
+    }
+
+    /**
+     * hasResource()
+     *
+     * @param Zend_Tool_Project_Profile $profile
+     * @param string $formName
+     * @param string $moduleName
+     * @return Zend_Tool_Project_Profile_Resource
+     */
+    public static function hasResource(Zend_Tool_Project_Profile $profile, $formName, $moduleName = null)
+    {
+        if (!is_string($formName)) {
+            throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Form::createResource() expects \"formName\" is the name of a form resource to check for existence.');
+        }
+
+        $formsDirectory = self::_getFormsDirectoryResource($profile, $moduleName);
+        return (($formsDirectory->search(array('formFile' => array('formName' => $formName)))) instanceof Zend_Tool_Project_Profile_Resource);
+    }
+    
+    /**
+     * _getFormsDirectoryResource()
+     *
+     * @param Zend_Tool_Project_Profile $profile
+     * @param string $moduleName
+     * @return Zend_Tool_Project_Profile_Resource
+     */
+    protected static function _getFormsDirectoryResource(Zend_Tool_Project_Profile $profile, $moduleName = null)
+    {
+        $profileSearchParams = array();
+
+        if ($moduleName != null && is_string($moduleName)) {
+            $profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
+        }
+
+        $profileSearchParams[] = 'formsDirectory';
+
+        return $profile->search($profileSearchParams);
+    }
+    
+    /**
+     * Create a new form
+     *
+     * @param string $name
+     * @param string $module
+     */
+    public function create($name, $module = null)
+    {
+        $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
+
+        // determine if testing is enabled in the project
+        $testingEnabled = Zend_Tool_Project_Provider_Test::isTestingEnabled($this->_loadedProfile);
+
+        if (self::hasResource($this->_loadedProfile, $name, $module)) {
+            throw new Zend_Tool_Project_Provider_Exception('This project already has a form named ' . $name);
+        }
+
+        // Check that there is not a dash or underscore, return if doesnt match regex
+        if (preg_match('#[_-]#', $name)) {
+            throw new Zend_Tool_Project_Provider_Exception('Form names should be camel cased.');
+        }
+        
+        $name = ucwords($name);
+        
+        try {
+            $formResource = self::createResource($this->_loadedProfile, $name, $module);
+
+            if ($testingEnabled) {
+                $testFormResource = null;
+                // $testFormResource = Zend_Tool_Project_Provider_Test::createApplicationResource($this->_loadedProfile, $name, 'index', $module);
+            }
+
+        } catch (Exception $e) {
+            $response = $this->_registry->getResponse();
+            $response->setException($e);
+            return;
+        }
+
+        // do the creation
+        if ($this->_registry->getRequest()->isPretend()) {
+
+            $this->_registry->getResponse()->appendContent('Would create a form at '  . $formResource->getContext()->getPath());
+
+            if ($testFormResource) {
+                $this->_registry->getResponse()->appendContent('Would create a form test file at ' . $testFormResource->getContext()->getPath());
+            }
+
+        } else {
+
+            $this->_registry->getResponse()->appendContent('Creating a form at ' . $formResource->getContext()->getPath());
+            $formResource->create();
+
+            if ($testFormResource) {
+                $this->_registry->getResponse()->appendContent('Creating a form test file at ' . $testFormResource->getContext()->getPath());
+                $testFormResource->create();
+            }
+
+            $this->_storeProfile();
+        }
+
     }
 
 

+ 36 - 50
library/Zend/Tool/Project/Provider/Layout.php

@@ -31,49 +31,9 @@ require_once 'Zend/Tool/Project/Provider/Abstract.php';
  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-class Zend_Tool_Project_Provider_Layout extends Zend_Tool_Project_Provider_Abstract
+class Zend_Tool_Project_Provider_Layout extends Zend_Tool_Project_Provider_Abstract implements Zend_Tool_Framework_Provider_Pretendable
 {
     
-    public static function prepareApplicationConfig(Zend_Tool_Project_Profile $profile, $section = 'production', $layoutPath = 'layout/scripts/')
-    {
-        $appConfigFileResource = $profile->search('ApplicationConfigFile');
-                
-        if ($appConfigFileResource == false) {
-            throw new Zend_Tool_Project_Exception('A project with an application config file is required to use this provider.');
-        }
-        
-        $appConfigFilePath = $appConfigFileResource->getPath();
-        
-        $config = new Zend_Config_Ini($appConfigFilePath, null, array('skipExtends' => true, 'allowModifications' => true));
-        
-        if (!isset($config->{$section})) {
-            throw new Zend_Tool_Project_Exception('The config does not have a ' . $section . ' section.');
-        }
-        
-        $currentSection = $config->{$section};
-        
-        if (!isset($currentSection->resources)) {
-            $currentSection->resources = array();
-        }
-        
-        $configResources = $currentSection->resources;
-        
-        if (!isset($configResources->layout)) {
-            $configResources->layout = array();
-        }
-        
-        $layout = $configResources->layout;
-        
-        $layout->layoutPath = 'APPLICATION_PATH "layouts/scripts"';
-        
-        $writer = new Zend_Config_Writer_Ini(array(
-            'config' => $config,
-            'filename' => $appConfigFilePath
-            ));
-        $writer->write();
-        
-    }
-    
     public static function createResource(Zend_Tool_Project_Profile $profile, $layoutName = 'layout')
     {
         $applicationDirectory = $profile->search('applicationDirectory');
@@ -102,24 +62,50 @@ class Zend_Tool_Project_Provider_Layout extends Zend_Tool_Project_Provider_Abstr
     {
         $profile = $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
         
-        self::prepareApplicationConfig($profile);
+        $applicationConfigResource = $profile->search('ApplicationConfigFile');
+
+        if (!$applicationConfigResource) {
+            throw new Zend_Tool_Project_Exception('A project with an application config file is required to use this provider.');
+        }
+        
+        $zc = $applicationConfigResource->getAsZendConfig();
+        
+        if (isset($zc->resources) && isset($zf->resources->layout)) {
+            $this->_registry->getResponse()->appendContent('A layout resource already exists in this project\'s application configuration file.');
+            return;
+        }
         
-        $layoutScriptFile = self::createResource($profile);
+        $layoutPath = 'APPLICATION_PATH "/layouts/scripts/"';
         
-        $layoutScriptFile->create();
+        $quoteValue = (preg_match('#"\'#', $layoutPath)) ? false : true;
         
-        $this->_registry->getResponse()->appendContent(
-            'Layouts have been enabled, and a default layout created at ' 
-            . $layoutScriptFile->getPath()
-            );
+        if ($this->_registry->getRequest()->isPretend()) {
+            $this->_registry->getResponse()->appendContent('Would add "resources.layout.layoutPath" key to the application config file.');
+        } else {
+            $applicationConfigResource->addStringItem('resources.layout.layoutPath', $layoutPath, 'production', $quoteValue);
+            $applicationConfigResource->create(); 
             
-        $this->_registry->getResponse()->appendContent('A layout entry has been added to the application config file.');
+            $layoutScriptFile = self::createResource($profile);
+            
+            $layoutScriptFile->create();
+            
+            $this->_registry->getResponse()->appendContent(
+                'Layouts have been enabled, and a default layout created at ' 
+                . $layoutScriptFile->getPath()
+                );
+                
+            $this->_registry->getResponse()->appendContent('A layout entry has been added to the application config file.');
+        }
+        
+       
         
     }
     
     public function disable()
     {
-        
+        // @todo
     }
     
+    
+    
 }

+ 1 - 0
library/Zend/Tool/Project/Provider/Manifest.php

@@ -57,6 +57,7 @@ class Zend_Tool_Project_Provider_Manifest implements
             'Zend_Tool_Project_Provider_Module',
         
             // application problem providers
+            'Zend_Tool_Project_Provider_Form',
             'Zend_Tool_Project_Provider_Layout',
             'Zend_Tool_Project_Provider_DbAdapter',
             'Zend_Tool_Project_Provider_DbTable',

+ 1 - 1
library/Zend/Tool/Project/Provider/Model.php

@@ -101,7 +101,7 @@ class Zend_Tool_Project_Provider_Model extends Zend_Tool_Project_Provider_Abstra
         $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
 
         // determine if testing is enabled in the project
-        $testingEnabled = Zend_Tool_Project_Provider_Test::isTestingEnabled($this->_loadedProfile);
+        $testingEnabled = false; //Zend_Tool_Project_Provider_Test::isTestingEnabled($this->_loadedProfile);
 
         if (self::hasResource($this->_loadedProfile, $name, $module)) {
             throw new Zend_Tool_Project_Provider_Exception('This project already has a model named ' . $name);

+ 2 - 1
library/Zend/Tool/Project/Provider/Project.php

@@ -116,7 +116,7 @@ class Zend_Tool_Project_Provider_Project
     {
         $data = <<<EOS
 <?xml version="1.0" encoding="UTF-8"?>
-    <projectProfile type="default">
+    <projectProfile type="default" version="1.10">
         <projectDirectory>
             <projectProfileFile />
             <applicationDirectory>
@@ -130,6 +130,7 @@ class Zend_Tool_Project_Provider_Project
                     </controllerFile>
                     <controllerFile controllerName="Error" />
                 </controllersDirectory>
+                <formsDirectory enabled="false" />
                 <layoutsDirectory enabled="false" />
                 <modelsDirectory />
                 <modulesDirectory enabled="false" />

+ 57 - 0
library/Zend/Tool/Project/Utility/ApplicationConfigWriter.php

@@ -0,0 +1,57 @@
+<?php
+
+class Zend_Tool_Project_Utility_ApplicationConfigWriter
+{
+    
+    public function setFilename()
+    {
+        
+    }
+    
+    
+    protected function _writeArrayToConfig($configArray)
+    {
+        
+    }
+    
+    protected function _writeStringToConfig()
+    {
+        $configKeyNames = array('resources', 'db');
+        
+        $newDbLines = array();
+        
+
+        
+        $originalLines = file($this->_appConfigFilePath);
+        
+        $newLines = array();
+        $insideSection = false;
+        
+        foreach ($originalLines as $originalLineIndex => $originalLine) {
+            
+            if ($insideSection === false && preg_match('#^\[' . $this->_sectionName . '#', $originalLine)) {
+                $insideSection = true;
+            }
+            
+            if ($insideSection) {
+                if ((trim($originalLine) == null) || ($originalLines[$originalLineIndex + 1][0] == '[')) {
+                    foreach ($newDbLines as $newDbLine) {
+                        $newLines[] = $newDbLine;
+                    }
+                    $insideSection = null;
+                }
+            }
+            
+            $newLines[] = $originalLine;
+        }
+
+        $newConfigContents = implode('', $newLines);
+        
+        if (!$isPretend) {
+            file_put_contents($this->_appConfigFilePath, $newConfigContents);
+        }
+        
+        return $newConfigContents;
+    }
+    
+}