I'm using Sonata with SonataAdmin & SonataOrm as told in several tutorials.
I simply would like to remove some default method of DoctrineOrmBundle- ModelManager.php
I tried to override the ModelManager by putting
<?php
namespace Project\AdminBundle\Model;
use Sonata\DoctrineORMAdminBundle\Model\ModelManager as 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']) {
//echo $fieldDescription->getName() . ' --- ' . $values['_sort_order'] . '<br />';
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);
}
}
?>
And tell Sonata DoctrineOrm to use it by default.
But I don't know how to do it.
Am I at least on the right track ?