Skip to content

Commit

Permalink
Change props processing
Browse files Browse the repository at this point in the history
  • Loading branch information
rozsival committed Mar 25, 2020
1 parent 9bef157 commit ffb39c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/PropsControl/Props.php
Expand Up @@ -45,8 +45,9 @@ final public function getData(): array
*/
final public function process(?array $data = null): ValidProps
{
$this->data = $data ?? $this->getData();
/** @var ProcessedProps $props */
$props = $this->processor->process($this->schema, $data ?: $this->getData());
$props = $this->processor->process($this->schema, $this->data);
return new ValidProps($this, $props->getValues());
}

Expand Down
6 changes: 6 additions & 0 deletions src/PropsControl/PropsControl.php
Expand Up @@ -87,6 +87,12 @@ public function getControlName(): string
return Strings::getClassName(static::class, true);
}

final public function getProps(): Props
{
$props = $this->getMappedProps();
return $this->createProps($props ? (array)$props : []);
}

/**
* @return string[]
*/
Expand Down
5 changes: 5 additions & 0 deletions tests/PropsControlTests/PropsControlTest.php
Expand Up @@ -51,6 +51,11 @@ public function testCallbacks(): void
ob_get_clean();
}

public function testGetProps(): void
{
$this->assertEquals([], $this->control->getProps()->getData());
}

public function testRender(): void
{
ob_start();
Expand Down

0 comments on commit ffb39c3

Please sign in to comment.