问题描述
我想要对ModelMangaer进行一些更改,然后我扩展了ModelManager,但是它不起作用.我不知道为什么?
I want some changes in ModelMangaer then I was extending ModelManager but It's not working. I don't know why ?
有人告诉我为什么它不起作用吗?
Any one tell me why it is not working?
我在其中扩展Sonata \ DoctrineORMAdminBundle \ Model \ ModelManager->的文件
File where I extend Sonata\DoctrineORMAdminBundle\Model\ModelManager->
<?php
use Sonata\DoctrineORMAdminBundle\Model\ModelManager;
class ModelManager extends ModelManager
{
/**
* {@inheritdoc}
*/
public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid)
{
$values = $datagrid->getValues();
$values = $_GET['filter'];
if ($fieldDescription->getName() == $values['_sort_by']) {
if ($values['_sort_order'] == 'ASC') {
$values['_sort_order'] = 'DESC';
} else {
$values['_sort_order'] = 'ASC';
}
} else {
$values['_sort_order'] = 'ASC';
$values['_sort_by'] = $fieldDescription->getName();
}
return array('filter' => $values);
}
推荐答案
您在这里遇到了很大的问题:
You have a very big problem here:
class ModelManager extends ModelManager
您尝试从自我扩展课堂.这是不对的!您需要使用完全限定名称声明基类或使用use
语句.您也忘记放置名称空间声明.这样的事情会起作用:
You try to extend class from self. It's wrong! You need to declare your base class with Fully Qualified Name or use use
statement. Also you forgot to put namespace declaration. Something like this will work:
namespace Acme\Bundle\DemoBundle\Model;
use Sonata\DoctrineORMAdminBundle\Model\ModelManager as BaseClass;
class ModelManager extends BaseClass
这篇关于如何扩展Sonata \ DoctrineORMAdminBundle \ Model \ ModelManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!