このチュートリアルに従いました http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-2-the-magento-config
URL を実行すると、構成が表示されず、機能しません。以下は私のコードです。
config.xml
<config>
<modules>
<Magentotutorial_Configviewer>
<version>0.1.0</version>
</Magentotutorial_Configviewer>
</modules>
<global>
<events>
<controller_front_init_routers>
<observers>
<Magentotutorial_configviewer_model_observer>
<type>singleton</type>
<class>Magentotutorial_Configviewer_Model_Observer</class>
<method>checkForConfigRequest</method>
</Magentotutorial_configviewer_model_observer>
</observers>
</controller_front_init_routers>
</events>
</global>
Magentotutorial_Configviewer.xml
<config>
<modules>
<Magentotutorial_Configviewer>
<active>true</active>
<codePool>local</codePool>
</Magentotutorial_Configviewer>
</modules>
モデルの Observer.php
<?php
class Magentotutorial_Configviewer_Model_Observer {
const FLAG_SHOW_CONFIG = 'showConfig';
const FLAG_SHOW_CONFIG_FORMAT = 'showConfigFormat';
private $request;
public function checkForConfigRequest($observer) {
$this->request = $observer->getEvent()->getData('front')->getRequest();
if ($this->request->FLAG_SHOW_CONFIG === 'true') {
$this->setHeader();
$this->outputConfig();
}
}
private function setHeader() {
$format = isset ( $this->request->FLAG_SHOW_CONFIG_FORMAT ) ? $this->request->FLAG_SHOW_CONFIG_FORMAT : 'xml';
switch ($format) {
case 'text' :
header("Content-Type: text/plain");
break;
default :
header("Content-Type: text/xml");
}
}
private function outputConfig() {
die( Mage::app()->getConfig()->getNode()->asXML() );
}
}
?>