English 中文(简体)
供另一单元使用的共享单元控制器
原标题:Share zend module controllers for use in another module

请允许我说,我有一位用户——我想从另一个模块中延伸到的RegistrationController。

class Clinic_RegisterController extends User_RegisterController

但我发现PHP的错误:

( ! ) Fatal error: Class  User_RegisterController  not found /application/modules/clinic/controllers/RegisterController.php on line 4

是否有办法将控制人员从另一个模块扩大到另一个单元?

最佳回答

你可以将基地控制员带入一个单独的图书馆课:

class App_Controller_Action_MyController extends Zend_Controller_Action
{
    // your base controller code here
}

然后,模块<代码>foo中的控制器 可能是空洞的:

class Foo_MyController extends App_Controller_Action_MyController
{
}

模块bar中的控制器 您可以提出以下建议:

class Bar_MyController extends App_Controller_Action_MyController
{
     // override your members/methods
}

Don tabes App_ as an autoloadernamespace.

问题回答

自动载荷仅仅是为了从其他模块中找到控制器。

如果你想做些什么,你可以简单地在“你”类别定义之上添加“<条码>查询”。

require_once APPLICATION_PATH .  /modules/user/controllers/RegisterController.php ;

class Clinic_RegisterController extends User_RegisterController
{
    //...
}

为什么需要从另一个模块中扩大控制员? 这造成对另一个模块的依赖。 如果在两种控制器中使用在应用层面使用。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签