nette / component-model Goto Github PK
View Code? Open in Web Editor NEW⚛ Component model foundation for Nette.
Home Page: https://doc.nette.org/component-model
License: Other
⚛ Component model foundation for Nette.
Home Page: https://doc.nette.org/component-model
License: Other
Either IContainer::getComponent()
must have @throws
annotation or Container::getComponent()
must not throw by default (i.e. default value of bool $throw
by me false
).
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.
Describe use case:
If i prepare structure of the form by $form->addContainer('foo');
in every template i must use {foreach $form->getComponent('foo')->getComponents() as $key => $input}
this help make shorter {foreach $form->getComponent('foo') as $key => $input}
, because i never need parameters from getComponents() $deep and $fileter in template.
Implementation is easy.
namespace Nette\ComponentModel;
use Nette;
class Container extends Component implements IContainer, \IteratorAggregate
{
public function getIterator()
{
return $this->getComponents();
}
}
What do you think?
When component monitors e.g. interface and monitors its descendant too, the attached()
method is called twice with the same monitored object.
Following sandbox branch calls attached()
with Presenter twice:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.