Giter Club home page Giter Club logo

Comments (5)

VincentLanglet avatar VincentLanglet commented on July 18, 2024

Indeed, the callback wasn't updated
https://github.com/sonata-project/SonataPageBundle/blob/4.x/src/Admin/PageAdmin.php#L197

It should be something like

'callback' => static function (ProxyQueryInterface $queryBuilder, string $alias, string $field, FilterData $data): void {
                    $builder = $queryBuilder->getQueryBuilder();

                    if (\in_array($data->getValue(), ['hybrid', 'cms'], true)) {
                        $builder->andWhere(sprintf('%s.routeName %s :routeName', $alias, 'cms' === $data->getValue() ? '=' : '!='));
                        $builder->setParameter('routeName', PageInterface::PAGE_ROUTE_CMS_NAME);
                    }
                },

from sonatapagebundle.

kursez avatar kursez commented on July 18, 2024

Seems that the issue is on 197:113 instead of a array the type should be \Sonata\AdminBundle\Filter\Model\FilterData
and instead of data['value'] it should be data->getValue()

from sonatapagebundle.

kursez avatar kursez commented on July 18, 2024

you got me some minutes earlier ;) I tried this already but there is also an issue with the twig sonat-admin/resources/CRUD/base_list.html.twig the issue is that the callback should return also some boolean so the type should be changed from void to bool and the proper bool should be returned accordingly

so it should be

'callback' => static function (ProxyQueryInterface $queryBuilder, string $alias, string $field, \Sonata\AdminBundle\Filter\Model\FilterData $data): bool {
$builder = $queryBuilder->getQueryBuilder();

                if (\in_array($data->getValue(), ['hybrid', 'cms'], true)) {
                    $builder->andWhere(sprintf('%s.routeName %s :routeName', $alias, 'cms' === $data->getValue() ? '=' : '!='));
                    $builder->setParameter('routeName', PageInterface::PAGE_ROUTE_CMS_NAME);
                }

                return true;
            },

but it should not always return true I guess

from sonatapagebundle.

kursez avatar kursez commented on July 18, 2024

I guess I can overwrite the admin with some extension until this get's fixed

from sonatapagebundle.

VincentLanglet avatar VincentLanglet commented on July 18, 2024

I guess I can overwrite the admin with some extension until this get's fixed

You can also provide a PR with the fix and I'll review/merge/release it.

from sonatapagebundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.