Closed kravcik closed 5 years ago
Change to customForm (Form responsibility create custom container)?
But how? the only solution that comes to mind: create interface IFormContainerProvider, form implements the interface and multiplier checks if form implement interface...
I just have a "strange" feeling about function (addCustomContainer()
). Thats all. Origin idea was something like this.
protected function applyDefaultValues(Container $container) {
$form = new CustomForm('_foo_multiplier');
$factoryContainer = $form->addContainer('foo'); //return customContainer
Btw atm it's works well with custom Form and container.
$form = new customForm;
$form->addMultiplier('m', function($container, $form)
{
$form->addWhisperer();
});
Should I prepare test for this solution?
how about
trait TFormComponents {
public function addContainer(...) {
// returns CustomContainer
}
public function addMultiplier(...) {
// returns CustomMultiplier
}
}
class CustomMultiplier extends Multiplier {
use TFormComponents;
}
class CustomForm extends Form {
use TFormComponents;
}
class CustomContainer extends Container {
use TFormComponents;
}
Good idea. So I guess I will this implement outside multiplier. Should I close this?
Thank you for your time :)
customForm
(Form responsibility create custom container)?Do you think this need deeper look? I don't think function
addCustomContainer($form, $name)
is necessary - better option would be add customForm and implement this function there.This can be temporary solution.