|
|
@@ -33,6 +33,10 @@ require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
|
|
*/
|
|
|
class Zend_Tool_Project_Provider_Layout extends Zend_Tool_Project_Provider_Abstract implements Zend_Tool_Framework_Provider_Pretendable
|
|
|
{
|
|
|
+ /**
|
|
|
+ * @var string Layout path
|
|
|
+ */
|
|
|
+ protected $_layoutPath = 'APPLICATION_PATH "/layouts/scripts/"';
|
|
|
|
|
|
public static function createResource(Zend_Tool_Project_Profile $profile, $layoutName = 'layout')
|
|
|
{
|
|
|
@@ -75,34 +79,62 @@ class Zend_Tool_Project_Provider_Layout extends Zend_Tool_Project_Provider_Abstr
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- $layoutPath = 'APPLICATION_PATH "/layouts/scripts/"';
|
|
|
-
|
|
|
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', false);
|
|
|
+ $applicationConfigResource->addStringItem('resources.layout.layoutPath', $this->_layoutPath, 'production', false);
|
|
|
$applicationConfigResource->create();
|
|
|
|
|
|
+ $this->_registry->getResponse()->appendContent('A layout entry has been added to the application config file.');
|
|
|
+
|
|
|
$layoutScriptFile = self::createResource($profile);
|
|
|
+ if (!$layoutScriptFile->exists()) {
|
|
|
+ $layoutScriptFile->create();
|
|
|
+ $this->_registry->getResponse()->appendContent(
|
|
|
+ 'A default layout has been created at '
|
|
|
+ . $layoutScriptFile->getPath()
|
|
|
+ );
|
|
|
|
|
|
- $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.');
|
|
|
+ $this->_storeProfile();
|
|
|
}
|
|
|
-
|
|
|
- $this->_storeProfile();
|
|
|
}
|
|
|
|
|
|
public function disable()
|
|
|
{
|
|
|
- // @todo
|
|
|
- }
|
|
|
+ $profile = $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
|
|
|
|
|
+ $applicationConfigResource = $this->_getApplicationConfigResource($profile);
|
|
|
+ $zc = $applicationConfigResource->getAsZendConfig();
|
|
|
+
|
|
|
+ if (isset($zc->resources) && !isset($zc->resources->layout)) {
|
|
|
+ $this->_registry->getResponse()->appendContent('No layout configuration exists in application config file.');
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ if ($this->_registry->getRequest()->isPretend()) {
|
|
|
+ $this->_registry->getResponse()->appendContent('Would remove "resources.layout.layoutPath" key from the application config file.');
|
|
|
+ } else {
|
|
|
|
|
|
+ // Remove the resources.layout.layoutPath directive from application config
|
|
|
+ $applicationConfigResource->removeStringItem('resources.layout.layoutPath', $this->_layoutPath, 'production', false);
|
|
|
+ $applicationConfigResource->create();
|
|
|
+
|
|
|
+ // Tell the user about the good work we've done
|
|
|
+ $this->_registry->getResponse()->appendContent('Layout entry has been removed from the application config file.');
|
|
|
+
|
|
|
+ $this->_storeProfile();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function _getApplicationConfigResource(Zend_Tool_Project_Profile $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.');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $applicationConfigResource;
|
|
|
+ }
|
|
|
}
|