function RulesComponentAddForm::getEntityFromRouteMatch

Overrides EntityForm::getEntityFromRouteMatch

File

src/Form/RulesComponentAddForm.php, line 16

Class

RulesComponentAddForm
Provides a form to add a component.

Namespace

Drupal\rules\Form

Code

public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id) {
    // Overridden to customize creation of new entities.
    if ($route_match->getRawParameter($entity_type_id) !== NULL) {
        $entity = $route_match->getParameter($entity_type_id);
    }
    else {
        $values = [];
        // @todo Create the right expression depending on the route.
        $entity = $this->entityTypeManager
            ->getStorage($entity_type_id)
            ->create($values);
        $entity->setExpression($this->expressionManager
            ->createRule());
    }
    return $entity;
}