Skip to content

Commit

Permalink
Merge pull request #22 from bwaidelich/21-throw-exception-for-missing…
Browse files Browse the repository at this point in the history
…-context-variables

BUGFIX: Throw exception for missing context variables
  • Loading branch information
Bastian Waidelich authored Apr 5, 2018
2 parents b63099e + 374924b commit ff433c4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Classes/Fusion/FinisherImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class FinisherImplementation extends AbstractFusionObject
public function evaluate()
{
$context = $this->runtime->getCurrentContext();
if (!isset($context['form'])) {
throw new FusionException(sprintf('Missing "form" in context for Finisher Fusion object "%s" at "%s"', $this->fusionObjectName, $this->path), 1522829109);
}
// TODO error handling if "form" is not available
/** @var FormDefinition $formDefinition */
$formDefinition = $context['form'];
Expand Down
4 changes: 3 additions & 1 deletion Classes/Fusion/FormElementImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public function getPath(): string
public function evaluate()
{
$context = $this->runtime->getCurrentContext();
// TODO error handling if "parentRenderable" is not available
if (!isset($context['parentRenderable'])) {
throw new FusionException(sprintf('Missing "parentRenderable" in context for Form Element Fusion object "%s" at "%s"', $this->fusionObjectName, $this->path), 1522828967);
}
/** @var Page $renderable */
$renderable = $context['parentRenderable'];

Expand Down
5 changes: 4 additions & 1 deletion Classes/Fusion/FormElementWrappingImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Neos\Form\Core\Model\Page;
use Neos\Form\Core\Model\Renderable\RootRenderableInterface;
use Neos\Form\Core\Runtime\FormRuntime;
use Neos\Fusion\Exception as FusionException;
use Neos\Fusion\FusionObjects\AbstractFusionObject;
use Neos\Neos\Service\ContentElementWrappingService;

Expand All @@ -30,7 +31,9 @@ public function evaluate()
{
$context = $this->runtime->getCurrentContext();

// TODO error handling if "formRuntime" is not available
if (!isset($context['formRuntime'])) {
throw new FusionException(sprintf('Missing "formRuntime" in context for Form Element Wrapping Fusion object "%s" at "%s"', $this->fusionObjectName, $this->path), 1522829151);
}
/** @var FormRuntime $formRuntime */
$formRuntime = $context['formRuntime'];
$formRuntime->registerRenderCallback(function (string $output, RootRenderableInterface $renderable) {
Expand Down
5 changes: 2 additions & 3 deletions Classes/Fusion/FormPageImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ public function getPath(): string
public function evaluate()
{
$context = $this->runtime->getCurrentContext();
// TODO error handling if "form" is not available
if (!isset($context['form'])) {
return '';
throw new FusionException(sprintf('Missing "form" in context for Form Page Fusion object "%s" at "%s"', $this->fusionObjectName, $this->path), 1522829233);
}
/** @var FormDefinition $formDefinition */
$formDefinition = $context['form'];
Expand Down Expand Up @@ -56,4 +55,4 @@ private function getLabel()
{
return $this->fusionValue('label');
}
}
}
4 changes: 3 additions & 1 deletion Classes/Fusion/SectionImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public function getPath(): string
public function evaluate()
{
$context = $this->runtime->getCurrentContext();
// TODO error handling if "parentRenderable" is not available
if (!isset($context['parentRenderable'])) {
throw new FusionException(sprintf('Missing "parentRenderable" in context for Section Fusion object "%s" at "%s"', $this->fusionObjectName, $this->path), 1522829260);
}
/** @var Page $renderable */
$renderable = $context['parentRenderable'];

Expand Down
4 changes: 3 additions & 1 deletion Classes/Fusion/ValidatorImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class ValidatorImplementation extends AbstractFusionObject
public function evaluate()
{
$context = $this->runtime->getCurrentContext();
// TODO error handling if "element" is not available
if (!isset($context['element'])) {
throw new FusionException(sprintf('Missing "element" in context for Validator Fusion object "%s" at "%s"', $this->fusionObjectName, $this->path), 1522829281);
}
/** @var AbstractRenderable $element */
$element = $context['element'];

Expand Down

0 comments on commit ff433c4

Please sign in to comment.