Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnexpectedValueException with $throw = false on presenter->getComponent #295

Open
mskocik opened this issue Aug 20, 2021 · 0 comments
Open

Comments

@mskocik
Copy link

mskocik commented Aug 20, 2021

Version: 3.1.2

Bug Description

👉 Presenter with component that can return null under specific conditions.

// exprecting null being stored in $var
$var = $presenter->getComponent('ControlOrNull', false); 

// exception is being thrown in Nette\ComponentModel\Container::createComponent method

Despite setting $throw to false, exception is thrown.

Steps To Reproduce

class MyPresenter extends Presenter {
    public function createComponentControlOrNull(): ?Form
    {
        return null;
    }
}
$val = $presenter->getComponent('ControlOrNull', false); // no exception should be thrown
$vall === true; // should equal true

Expected Behavior

I am able to return null value from createComponent* methods.

Possible Solution

$throw property should be propagated to Nette\ComponentModel\Container::createComponent method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant