【问题标题】:CakePHP 3.x: how to extend the Request classCakePHP 3.x:如何扩展 Request 类
【发布时间】:2015-04-02 08:34:45
【问题描述】:

我有一个插件,我希望扩展 Request 类 (Cake\Network\Request),以添加可供我的插件控制器使用的新方法和属性。

怎么办? 谢谢。

【问题讨论】:

    标签: cakephp cakephp-3.0


    【解决方案1】:

    创建您的扩展请求类并简单地将它的一个实例传递给您的应用程序中的调度程序webroot/index.php 前端控制器:

    https://github.com/cakephp/app/blob/3.0.0/webroot/index.php#L35

    // ....
    
    use App\Network\MyCustomRequest;
    
    $dispatcher = DispatcherFactory::create();
    $dispatcher->dispatch(
        MyCustomRequest::createFromGlobals(), // there it goes
        new Response()
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-18
      • 1970-01-01
      • 1970-01-01
      • 2019-05-14
      • 2015-12-05
      • 2017-03-11
      • 1970-01-01
      相关资源
      最近更新 更多