码信号+ HMVC交叉模块呼叫控制器→方法 [英] codeigniter+HMVC cross module call controller->method

查看:186
本文介绍了码信号+ HMVC交叉模块呼叫控制器→方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



添加到文档中。

我把所有的头发都关掉了...正在搜索每一个线程,如果有人可以指点一个工作示例, : https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
我可以使用

调用另一个模块 - >控制器

  modules :: run('module / controller / ,$ params); 
modules :: load('module / controller / method',$ params);

$ this-> load-> module('module / controller');
$ this-> controller-> method();

问题:不会调用method()。



目标是构建自包含的MVC作为模块并由其他控制器使用。
但是不管我做什么,它只调用构造函数,方法不被调用。
我几个星期前开始使用HMVC,我错过了文档中的某些东西,或者不是这样使用?

这是设置:

 模块
| --ztest1
| | --controller / c1.php
| --ztest2
| --controller / c2.php

类C1扩展MX_Controller {
function __construct(){
parent :: __ construct();
}
function index(){
Modules :: run('ztest2 / c2 / testc2 /');
// Modules :: load('ztest2 / c2 / testc2 /');
// $ this-> load-> module('ztest2 / c2 / testc2 /');
// $ this-> c2-> testc2();
}
}

类C2扩展MX_Controller {
function __construct(){
parent :: __ construct()
echo __FILE__。//.__ CLASS __。/.__ FUNCTION __。PHP_EOL;
}
function testc2(){
echo __FILE__。//.__ CLASS __。/.__ FUNCTION __。PHP_EOL;
}
}

输出:
/app/modules/ztest2/controllers/c2.php // C2 / __ construct

注意:脚本没有错误或警告。它只是静静地调用构造函数。

解决方案

这个HMVC适合我。我正在使用这个HMVC的项目。
只需编辑 third_party / MX / Modules.php ,如下面的链接所示,并告诉我响应。



https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-request/5/return-error-messages-instead-of-logging/diff


I am pulling all my hair off... Have been searching every thread, would appreciate if someone can point me to a working example.

Accroding to the doc: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc I can call another module->controller using

modules::run('module/controller/method', $params);
modules::load('module/controller/method', $params);
or
$this->load->module('module/controller');
$this->controller->method();

Problem: the "method()" is never called. only constructor of the controller is called every time.

The objective is to build self-contained MVCs as module and use by other controllers. But no matter what I do, it only calls the constructor, method is not called. I started using HMVC a few weeks ago, did I miss something in the doc or it is not used this way?
Here is the setup:

modules
  |--ztest1
  |   |--controller/c1.php
  |--ztest2
      |--controller/c2.php

class C1 extends MX_Controller {
  function __construct() {
    parent::__construct();
  }
  function index () {
    Modules::run('ztest2/c2/testc2/');
    //Modules::load('ztest2/c2/testc2/');
    //$this->load->module('ztest2/c2/testc2/');
    //$this->c2->testc2();
  }
}

class C2 extends MX_Controller {
  function __construct() {
    parent::__construct();
    echo __FILE__." // ".__CLASS__."/".__FUNCTION__.PHP_EOL;
  }
  function testc2(){
    echo __FILE__." // ".__CLASS__."/".__FUNCTION__.PHP_EOL;
  }
}

output:
/app/modules/ztest2/controllers/c2.php // C2/__construct

additional note: no error or warning with the script. It just quietly calls the constructor.

解决方案

This HMVC works well for me. I'm working on a project using this HMVC now. Just edit third_party/MX/Modules.php as shown in this link below and tell me the response.

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-request/5/return-error-messages-instead-of-logging/diff

这篇关于码信号+ HMVC交叉模块呼叫控制器→方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆