Issues

ZF-11512: Zend_Tool_Project_Provider_Layout not properly detecting existing layout configuration

Description

When enabling layout using "zf enable layout" on a project that has already has been enabled doesn't get picked up. This is due to a typo in the if-statement. Nothing drastic happens except another " resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/" " is added to the application.ini file Also, the .zfproject.xml file isn't updated correctly

Comments

Apologies for pasting in the patch here, not sure how to attach it

Index: Layout.php

--- Layout.php (revision 24161) +++ Layout.php (working copy) @@ -70,7 +70,7 @@

     $zc = $applicationConfigResource->getAsZendConfig();
  • if (isset($zc->resources) && isset($zf->resources->layout)) {
  •  if (isset($zc->resources) && isset($zc->resources->layout)) {
         $this->_registry->getResponse()->appendContent('A layout resource already exists in this project\'s application configuration file.');
         return;
     }
    

    @@ -93,6 +93,8 @@ );

         $this->_registry->getResponse()->appendContent('A layout entry has been added to the application config file.');
    
  • $this->_storeProfile(); }

Hi Rob,

Thanks for the patch to contribute to ZF. However, before contributing code you should sign the cla (http://framework.zend.com/wiki/display/…). After then you can attach files.

Patch attached. Also implements {{zf disable layout}}.

Disable layout feature removed from the patch.

Reproduce (stdout trimmed for brevity):


[adam@zfdev tmp] zf create project ZF-11512
[adam@zfdev tmp] cd ZF-11512
[adam@zfdev ZF-11512] zf enable layout
[adam@zfdev ZF-11512] zf enable layout

Result: {{application/configs/application.ini}} now contains two {{resources.layout.layoutPath}} lines under the {{production}} group:


resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"

Rob's suggested fix:



Index: library/Zend/Tool/Project/Provider/Layout.php
===================================================================
--- library/Zend/Tool/Project/Provider/Layout.php       (revision 24163)
+++ library/Zend/Tool/Project/Provider/Layout.php       (working copy)
@@ -70,7 +70,7 @@

         $zc = $applicationConfigResource->getAsZendConfig();

-        if (isset($zc->resources) && isset($zf->resources->layout)) {
+        if (isset($zc->resources) && isset($zc->resources->layout)) {
             $this->_registry->getResponse()->appendContent('A layout resource already exists in this project\'s application configuration file.');
             return;
         }
@@ -95,8 +95,7 @@
             $this->_registry->getResponse()->appendContent('A layout entry has been added to the application config file.');
         }

-
-
+        $this->_storeProfile();
     }

     public function disable()

After applying patch, running reproduce sequence from above now shows desired result: (most stdout trimmed for brevity):


[adam@zfdev tmp] zf create project ZF-11512
[adam@zfdev tmp] cd ZF-11512
[adam@zfdev ZF-11512] zf enable layout
[adam@zfdev ZF-11512] zf enable layout
A layout resource already exists in this project's application configuration file.

Fixed in trunk r24164 Merged to release-1.11 in r24165