getAddFormRoute example


  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = new RouteCollection();

    $entity_type_id = $entity_type->id();

    if ($add_page_route = $this->getAddPageRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.add_page", $add_page_route);
    }

    if ($add_form_route = $this->getAddFormRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.add_form", $add_form_route);
    }

    if ($canonical_route = $this->getCanonicalRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.canonical", $canonical_route);
    }

    if ($edit_route = $this->getEditFormRoute($entity_type)) {
      $collection->add("entity.{$entity_type_id}.edit_form", $edit_route);
    }

    

  public function testGetAddFormRoute(Route $expected = NULL, EntityTypeInterface $entity_type, EntityTypeInterface $bundle_entity_type = NULL, FieldStorageDefinitionInterface $field_storage_definition = NULL) {
    if ($bundle_entity_type) {
      $this->entityTypeManager->getDefinition('the_bundle_entity_type_id')->willReturn($bundle_entity_type);

      if ($field_storage_definition) {
        $this->entityFieldManager->getFieldStorageDefinitions('the_bundle_entity_type_id')
          ->willReturn(['id' => $field_storage_definition]);
      }
    }

    $route = $this->routeProvider->getAddFormRoute($entity_type);
    $this->assertEquals($expected$route);
  }

  public static function providerTestGetAddFormRoute() {
    $prophet = new Prophet();
    $data = [];

    $entity_type1 = static::getEntityType();
    $entity_type1->hasLinkTemplate('add-form')->willReturn(FALSE);

    $data['no_add_form_link_template'] = [NULL, $entity_type1->reveal()];

    
protected function getAddPageRoute(EntityTypeInterface $entity_type) {
    if ($route = parent::getAddPageRoute($entity_type)) {
      $route->setOption('_admin_route', TRUE);
      return $route;
    }
  }

  /** * {@inheritdoc} */
  protected function getAddFormRoute(EntityTypeInterface $entity_type) {
    if ($route = parent::getAddFormRoute($entity_type)) {
      $route->setOption('_admin_route', TRUE);
      return $route;
    }
  }

  /** * {@inheritdoc} */
  protected function getEditFormRoute(EntityTypeInterface $entity_type) {
    if ($route = parent::getEditFormRoute($entity_type)) {
      $route->setOption('_admin_route', TRUE);
      
Home | Imprint | This part of the site doesn't use cookies.