本文介绍了Magento Oauth Adminhtml控制器类覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想覆盖"Oauth"模块下的magento核心控制器类.法师/Oauth/控制器/Adminhtml/Oauth/AuthorizeController.php

I want to Override magento core controller class which is present under 'Oauth' module.Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php

模块声明xml:

<?xml version="1.0" encoding="UTF-8"?>

<config>
    <modules>
        <DS_Adminextended>
            <active>true</active>
            <codePool>local</codePool>
        </DS_Adminextended>
    </modules>
</config>

我的config.xml是:

My config.xml is :

<?xml version="1.0" encoding="UTF-8"?>

<config>
    <modules>
        <DS_Adminextended>
            <version>1.0.0</version>
        </DS_Adminextended>
    </modules>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <DS_Adminextended before="Mage_Adminhtml">DS_Adminextended</DS_Adminextended>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config> 

我也曾用过这个但徒劳无功:

i had also use this one but invain:

<modules>
 <DS_Adminextended before="Mage_Adminhtml">DS_Adminextended_Adminhtml_Oauth</DS_Adminextended>
 </modules>

和扩展的AuthorizeController.php:

and extended AuthorizeController.php :

<?php

 require_once("Mage/Oauth/Adminhtml/Oauth/AuthorizeController.php");

die('bla bla bla');

class DS_Adminextended_Adminhtml_Oauth_AuthorizeController extends Mage_Oauth_Adminhtml_Oauth_AuthorizeController {

 public function indexAction()
 {
 echo 'extendedController';exit;
 $this->_initForm();
 $this->_initLayoutMessages($this->_sessionName);
 $this->renderLayout();
 }
}

但是它不包含扩展文件.这个'Adminhtml'出现在Mage/Oauth文件夹中,而不在Mage:Adminhtml中所以问题是我们如何扩展非管理模块下的管理控制器类,例如:1)法师/Oauth/控制器/Adminhtml/Oauth/AuthorizeController.php或者2)Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php

But it did not include the extended file.This 'Adminhtml' present inside the Mage/Oauth Folder not in Mage:AdminhtmlSo Question is how we can extend admin controller class present under non admin module like:1) Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.phpOR2) Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php

上面的代码中我缺少什么?

what i am missing in above code ?

推荐答案

我找到了解决方法:

<admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <DS_Adminextended before="Mage_Oauth">DS_Adminextended_Adminhtml</DS_Adminextended>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

如果要扩展Mage :: admin中不存在的管理模块,这是正确的配置文件魔术在这里:

This is the correct config file if you want to extend admin module not present in Mage::adminmagic is here:

<modules><DS_Adminextended before="Mage_Oauth">DS_Adminextended_Adminhtml</DS_Adminextended></modules>

您必须先将"Mage_Oauth"放在"Mage_Adminhtml"中,即使它出现在adminhtml中.其次控制器调用的路径应为" DS_Adminextended_Adminhtml ",即使您的基本控制器内部还有一个目录(就我的情况而言,按照核心目录" DS_Adminextended_Adminhtml_Oauth "").

you have to place "Mage_Oauth" in before instead to "Mage_Adminhtml" even if its appearing in adminhtml. secondlypath to controller call should be "DS_Adminextended_Adminhtml" not even if your base contrroller have one more directory inside like in my case as per core directory 'DS_Adminextended_Adminhtml_Oauth' .

希望这会帮助某人并节省时间,如果可以帮助您,请先进行排名:-)

Hope this will help someone and save time, please rank up if it help you :-)

这篇关于Magento Oauth Adminhtml控制器类覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 03:55