Closed (won't fix)
Project:
Drupal core
Version:
8.8.x-dev
Component:
file system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Sep 2014 at 23:12 UTC
Updated:
23 Jul 2019 at 19:54 UTC
Jump to comment: Most recent
Comments
Comment #7
johnpitcairn commentedThat would be handy. Redirecting to a file at present present some difficulties.
Comment #8
berdirWon't fix IMHO, with media.module, files will IMHO remain second-class citizens and we will not introduce an actual canonical route in core, and we decided against having one that points to the physical file.
Comment #9
no74hUsing File entity as an Entity type may lead to unwanted behaviors. One of which I encounter when trying to get url of File instance by calling this: `$file->toUrl()`
Abstract class Entity (which File entity indirectly extends) does implement toUrl() but it's not suitable with File entity.
Because File entity doesn't have default link templates (canonical); therefore this error is raised.
(In my case, overriding toUrl() in File class and returning File::url() can avoid this exception. But it's not the solution for this issue. )
I think, if file is considered an Entity type, it has to respect EntityInterface specs.
Not having canonical routes that points to physical files is legit too, but should Files in this case be of another type than Entities?
Comment #10
berdirtoUrl() is documented as throwing exceptions if a link template doesn't exist, you have to handle that or check first. Files are entities, nothing says that entities must have canonical link templates.
Closing this now as I suggested above.