MetaModels\BackendIntegration\InputScreen\InputScreen::transformCondition PHP Method

transformCondition() protected method

Transform a single condition into a valid condition object.
protected transformCondition ( array $condition ) : ContaoCommunityAlliance\DcGeneral\DataDefinition\Palette\Condition\Property\PropertyConditionInterface
$condition array The condition to transform.
return ContaoCommunityAlliance\DcGeneral\DataDefinition\Palette\Condition\Property\PropertyConditionInterface
    protected function transformCondition($condition)
    {
        $dispatcher = $GLOBALS['container']['event-dispatcher'];
        $event = new CreatePropertyConditionEvent($condition, $this->getMetaModel());
        /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
        $dispatcher->dispatch(CreatePropertyConditionEvent::NAME, $event);
        if ($event->getInstance() === null) {
            throw new \RuntimeException(sprintf('Condition of type %s could not be transformed to an instance.', $condition['type']));
        }
        return $event->getInstance();
    }