我目前正在使用 OctoberCMS 并正在创建一个插件,该插件具有一个自定义页面和一个显示网格的小部件
正如您在此图像中看到的那样,可以管理此网格,并且可以使用“保存更改”按钮进行保存。这将向服务器发送一个 POST 请求,但我在“监听”这个 POST 请求时遇到了问题。由于 octoberCMS 的文档不是很好,我正尝试像在 Laravel 中那样做。但即使这样也不能正常工作。
Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\ServiceProvider
ftsf/grid/routes.php
<?php
Route::post('/backend/ftsf/grid', 'Ftsf\Grid\Widgets\GridManager@saveGrid');
ftsf/grid/widgets/GridManager.php
<?php namespace Ftsf\Grid\Widgets;
use App;
use Backend\Classes\WidgetBase;
use Cms\Classes\Content;
use Cms\Classes\Controller;
use Cms\Classes\Theme;
use Cms\Twig\Extension;
use Ftsf\Grid\Models\PatternOrder;
use Illuminate\Http\Request;
use System\Twig\Engine as TwigEngine;
class GridManager extends WidgetBase {
protected $defaultAlias = 'ftsf_grid_manager';
public function init() {
}
public function render() {
$env = App::make('twig.environment');
$env->addExtension(new Extension(new Controller(Theme::getActiveTheme())));
return (new TwigEngine($env))->get($this->getViewPath('_gridmanager.htm'),
['patterns' => PatternOrder::orderBy('order')->with('pages')->get(),
'contents' => Content::all()]);
}
public function loadAssets() {
$this->addCss('css/gridmanager.css', 'Ftsf.Grid');
$this->addJs('js/gridmanager.js', 'Ftsf.Grid');
}
public function saveGrid(Request $request){
return dd($request);
}
}
如果需要更多信息,请告诉我什么。