ParamNotConvertedException example

// Continue if no converter has been specified.         continue;
      }

      // If a converter returns NULL it means that the parameter could not be       // converted.       $value = $defaults[$name];
      $defaults[$name] = $this->getConverter($definition['converter'])->convert($value$definition$name$defaults);
      if (!isset($defaults[$name])) {
        $message = 'The "%s" parameter was not converted for the path "%s" (route name: "%s")';
        $route_name = $defaults[RouteObjectInterface::ROUTE_NAME];
        throw new ParamNotConvertedException(sprintf($message$name$route->getPath()$route_name), 0, NULL, $route_name[$name => $value]);
      }
    }

    return $defaults;
  }

}

  protected function getEntityTypeFromDefaults($definition$name, array $defaults) {
    $type_part = strstr($definition['type'], ':');
    if (!$type_part) {
      throw new ParamNotConvertedException(sprintf('The type definition "%s" is invalid. The expected format is "entity_revision:<entity_type_id>".', $definition['type']));
    }
    $entity_type_id = substr($type_part, 1);

    // If the entity type is dynamic, it will be pulled from the route defaults.     if (str_starts_with($entity_type_id, '{')) {
      $entity_type_slug = substr($entity_type_id, 1, -1);
      if (!isset($defaults[$entity_type_slug])) {
        throw new ParamNotConvertedException(sprintf('The "%s" parameter was not converted because the "%s" parameter is missing.', $name$entity_type_slug));
      }
      $entity_type_id = $defaults[$entity_type_slug];
    }
    

  public function testIsValidWithParamNotConverted() {
    $this->account->expects($this->once())
      ->method('hasPermission')
      ->with('link to any page')
      ->willReturn(FALSE);
    $this->accessUnawareRouter->expects($this->never())
      ->method('match');
    $this->accessAwareRouter->expects($this->once())
      ->method('match')
      ->with('/test-path')
      ->willThrowException(new ParamNotConvertedException());
    $this->pathProcessor->expects($this->once())
      ->method('processInbound')
      ->willReturnArgument(0);

    $this->assertFalse($this->pathValidator->isValid('test-path'));
  }

  /** * @covers ::isValid * @covers ::getPathAttributes */
  
Home | Imprint | This part of the site doesn't use cookies.