โดย Ittichai_chupol » 09/10/2018 7:02 pm
วิธีแก้คือ
ปรับเปลี่ยน ในไฟล์ main.php กับ ไฟล์ services.yml ดังนี้
ไฟล์ main.php
โค้ด: เลือกทั้งหมด
<?php
namespace mindphp\sample1\controller;
use Symfony\Component\DependencyInjection\Container;
class main {
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db,
\phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, Container $phpbb_container, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, $table_prefix, $phpbb_root_path, $php_ext) {
$this->config = $config;
$this->db = $db;
$this->template = $template;
$this->user = $user;
$this->helper = $helper;
$this->phpbb_container = $phpbb_container;
$this->request = $request;
$this->auth = $auth;
$this->pagination = $pagination;
$this->table_prefix = $table_prefix;
$this->phpbb_root_path = $root_path;
$this->php_ext = $php_ext;
}
function base($page = 1) {
$page_title = $this->user->lang('MINDPHP');
print_r($this->user->ip);
print_r($this->user->data['user_id']);
return $this->helper->render('sample1_body.html', $page);
}
}
ไฟล์ services.yml
โค้ด: เลือกทั้งหมด
services:
mindphp.sample1.controller:
class: mindphp\sample1\controller\main
arguments:
- @config
- @dbal.conn
- @template
- @user
- @controller.helper
- @service_container
- @request
- @auth
- @pagination
- %core.table_prefix%
- %core.root_path%
- %core.php_ext%
วิธีแก้คือ
ปรับเปลี่ยน ในไฟล์ main.php กับ ไฟล์ services.yml ดังนี้
ไฟล์ main.php
[code]
<?php
namespace mindphp\sample1\controller;
use Symfony\Component\DependencyInjection\Container;
class main {
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db,
\phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, Container $phpbb_container, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, $table_prefix, $phpbb_root_path, $php_ext) {
$this->config = $config;
$this->db = $db;
$this->template = $template;
$this->user = $user;
$this->helper = $helper;
$this->phpbb_container = $phpbb_container;
$this->request = $request;
$this->auth = $auth;
$this->pagination = $pagination;
$this->table_prefix = $table_prefix;
$this->phpbb_root_path = $root_path;
$this->php_ext = $php_ext;
}
function base($page = 1) {
$page_title = $this->user->lang('MINDPHP');
print_r($this->user->ip);
print_r($this->user->data['user_id']);
return $this->helper->render('sample1_body.html', $page);
}
}
[/code]
ไฟล์ services.yml
[code]
services:
mindphp.sample1.controller:
class: mindphp\sample1\controller\main
arguments:
- @config
- @dbal.conn
- @template
- @user
- @controller.helper
- @service_container
- @request
- @auth
- @pagination
- %core.table_prefix%
- %core.root_path%
- %core.php_ext%
[/code]