Silverstripe中间件无法正常工作

时间:2018-02-28 13:29:42

标签: php middleware silverstripe silverstripe-4

我添加了新的空中间件并收到错误:
" [紧急]未捕获BadMethodCallException:在开始之前无法访问会话"

<?php

use SilverStripe\Control\Middleware\HTTPMiddleware;
use SilverStripe\Control\HTTPRequest;

class MyMiddleware implements HTTPMiddleware
{
    public function process(HTTPRequest $request, callable $delegate){
        $response = $delegate($request);
        return $response;
    }
}


---
Name: myrequestprocessors
After:
  - 'requestprocessors'
---
SilverStripe\Core\Injector\Injector:
  SilverStripe\Control\Director:
    properties:
      Middlewares:
        - '%$MyMiddleware'

recipe-cms v1.0.3

是否有解决方法可以防止此错误并使中间件工作?

1 个答案:

答案 0 :(得分:0)

在我的情况下,其他yml文件中存在拼写错误:

SilverStripe\Core\Injector\Injector:
SilverStripe\Assets\Image_Backend:
  properties:
    Quality: 80

设置中存在错误的偏移。