1 回答
TA贡献1825条经验 获得超4个赞
我不知道如何订阅服务,但这里是如何注入它。
向控制器添加一个构造函数并注入 DataTableFactory:
//use Omines\DataTablesBundle\DataTableFactory;
private $factory;
public function __construct(
DataTableFactory $factory
) {
$this->factory = $factory;
}
/**
* Creates and returns a basic DataTable instance.
*
* @param array $options Options to be passed
* @return DataTable
*/
protected function createDataTable(array $options = [])
{
return $this->factory->create($options);
}
/**
* Creates and returns a DataTable based upon a registered DataTableType or an FQCN.
*
* @param string $type FQCN or service name
* @param array $typeOptions Type-specific options to be considered
* @param array $options Options to be passed
* @return DataTable
*/
protected function createDataTableFromType($type, array $typeOptions = [], array $options = [])
{
return $this->factory->createFromType($type, $typeOptions, $options);
}
然后你可以像这样使用它:
$this->createDateTable();
- 1 回答
- 0 关注
- 102 浏览
添加回答
举报