sonata-project/admin-bundle 3.48.1 3.48.1
$ php -v
PHP 7.2.17-1+ubuntu16.04.1+deb.sury.org+3 (cli) (built: Apr 10 2019 10:50:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.17-1+ubuntu16.04.1+deb.sury.org+3, Copyright (c) 1999-2018, by Zend Technologies
md5-43965285198c7b82108e40109daf762b
PHP Warning: Uncaught Error: Call to a member function setRequest() on boolean
md5-f026ddacd06567efd6ffceea38adbc59
$admin = $this->sonata->getAdminByAdminCode($code);
$admin->setRequest($request);
So calling \Sonata\AdminBundle\Admin\Pool::getAdminByAdminCode() could return \Sonata\AdminBundle\Admin\AdminInterface or boolean false. You would say that in my code I should add a check for a false value returned by getAdminByAdminCode(), but I think the method should be improved and not return false but throw exceptions, because:
false checks in my code when I use this method.false I have to write my own messages (to be written to a log) on all places where I use the method.public function getAdminByAdminCode(string $adminCode) : AdminInterfaceI'm not issuing this as a bug, but a feature request, because implementing throwing errors will break things.
If you want to contribute this, you can start by making a PR on the stable branch with this:
@trigger_error(sprintf(
'Calling "%s" with an invalid admin code is deprecated since sonata-project/admin-bundle 3.x and will throw an exception in 4.0',
__METHOD__
), E_USER_DEPRECATED);
Also, a new hasAdminByAdminCode() method should be introduced.
If you want to contribute this [...]
I'd really like to. Just wanted to check if this is a good idea to you too.
Also, a new
hasAdminByAdminCode()method should be introduced.
Good point. I'll add that too.
B.t.w. there's no 4.0 branch to contribute the actual code to, right?
This should go into 3.x branch 馃憤馃徎
B.t.w. there's no 4.0 branch to contribute the actual code to, right?
It's called master :wink: , but you would have to do what I said on 3.x first, then wait for 3.x to be merged on master (happens nightly), and then make the PR on master.
I will be waiting on #5543 before issuing a PR for the 3.x branch
@7ochem, #5543 is now merged :+1:
Most helpful comment
@7ochem, #5543 is now merged :+1: