/** * Intercept missing methods, pass any methods that begin with add to the * internal fieldsBuilder * @param string $method * @param array $args * @return mixed */ public function __call($method, $args) { if (preg_match('/^add.+/', $method) && method_exists($this->fieldsBuilder, $method)) { $field = $this->callAddFieldMethod($method, $args); $field->setParentContext($this); return $field; } return parent::__call($method, $args); }
/** * Return a configuration array * @return array */ public function build() { return array_merge(parent::build(), ['layouts' => $this->buildLayouts()]); }
public function testBuild() { $subject = new FieldBuilder('my_field', 'text', ['prepend' => '$']); $this->assertArraySubset(['key' => 'field_my_field', 'name' => 'my_field', 'label' => 'My Field', 'type' => 'text', 'prepend' => '$'], $subject->build()); }