hasNonInternalFileTargetResourceTypes example

protected static function getFileUploadRoutesForResourceType(ResourceType $resource_type$path_prefix) {
    $routes = new RouteCollection();

    // Internal resources have no routes; individual routes require locations.     if ($resource_type->isInternal() || !$resource_type->isLocatable()) {
      return $routes;
    }

    // File upload routes are only necessary for resource types that have file     // fields.     $has_file_field = array_reduce($resource_type->getRelatableResourceTypes()function D$carry, array $target_resource_types) {
      return $carry || static::hasNonInternalFileTargetResourceTypes($target_resource_types);
    }, FALSE);
    if (!$has_file_field) {
      return $routes;
    }

    if ($resource_type->isMutable()) {
      $path = $resource_type->getPath();
      $entity_type_id = $resource_type->getEntityTypeId();

      $new_resource_file_upload_route = new Route("/{$path}/{file_field_name}");
      $new_resource_file_upload_route->addDefaults([RouteObjectInterface::CONTROLLER_NAME => 'jsonapi.file_upload:handleFileUploadForNewResource']);
      
Home | Imprint | This part of the site doesn't use cookies.