Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #16 from PackageFactory/feature/split-component-ev…
Browse files Browse the repository at this point in the history
…aluate

TASK: Split ComponentImplementation->evaluate into two separate methods
  • Loading branch information
grebaldi authored Jan 4, 2018
2 parents ef501f1 + b8ebf48 commit 72ef38b
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ class ComponentImplementation extends ArrayImplementation
protected $ignoreProperties = ['__meta', 'renderer'];

/**
* Evaluate the fusion-keys and transfer the result into the context as ``props``
* afterwards evaluate the ``renderer`` with this context
* Get the component props as an associative array
*
* @return void|string
* @return array
*/
public function evaluate()
public function getProps()
{
$sortedChildFusionKeys = $this->sortNestedFusionKeys();

Expand All @@ -54,6 +53,17 @@ public function evaluate()
}
}

return $props;
}

/**
* Render the component with the given props
*
* @param array $props
* @return void|string
*/
public function renderComponent(array $props)
{
$context = $this->runtime->getCurrentContext();
$context['props'] = $props;
$this->runtime->pushContextArray($context);
Expand All @@ -62,4 +72,16 @@ public function evaluate()

return $result;
}

/**
* Evaluate the fusion-keys and transfer the result into the context as ``props``
* afterwards evaluate the ``renderer`` with this context
*
* @return void|string
*/
public function evaluate()
{
$props = $this->getProps();
return $this->renderComponent($props);
}
}

0 comments on commit 72ef38b

Please sign in to comment.