Skip to content

Container::getComponent() throws exception for already attached components #1

@iinfo-dev-mk

Description

@iinfo-dev-mk

Because there is a check for component parent presence in https://github.com/nette/component-model/blob/master/src/ComponentModel/Container.php#L142 it's impossible return already created and attached controls.

class MyControl {

protected function createComponentTest() {
  return $this->anotherControlParent->getComponent("Test");
}

If another parent has attached component "test", exception about unknown component "test" is thrown. Throw such exception in this situation is misleading.

Maybe such component don't need to be attached to current parent but getComponent() method can return such component. That component is already attached to another parent doesn't matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions