Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extends Sonata\DoctrineORMAdminBundle\Model\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?

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);
}
like image 333
Kunwar Siddharth Singh Avatar asked Dec 01 '25 14:12

Kunwar Siddharth Singh


1 Answers

You have a very big problem here:

class ModelManager extends ModelManager

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
like image 52
Michael Sivolobov Avatar answered Dec 03 '25 07:12

Michael Sivolobov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!