You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when creating a ShortUrl, there are two entities that could need to be created or fetched as a side effect, Tag and Domain.
These are always provided as strings that reference to a unique index for their respective entities, which result in the tag/domain being created if it does not exist, or fetched otherwise, resulting in a relationship with ShortUrl in both cases.
This is currently handled differently for tags and domains.
For domains
The ShortUrl expects an object implementing DomainResolverInterface to be optionally provided. If it is not provided, it falls back to the basic implementation, SimpleDomainResolver, which just returns a new Domain instance always.
However, at runtime, a PersistenceDomainResolver is always provided, which depends on the EntityManager, and therefore, it is capable of persisitng/fetching actual domains from persistence layer.
For tags
Services that need to create the list of tags for a ShortUrl, use the TagManagerTrait, which exposes a method to create/fetch tags.
These tags are later set to the ShortUrl via setter.
Proposal
These are the problems we need to resolve:
Lack of consistency between how these entities are handled.
Usage of a trait in the second case.
Requirement of a setter in the second case.
The way in which this problem is handled for domains is better than the other one, but having to pass "resolvers" for each one of them makes it a bit cumbersome.
One option is to have a single "resolver" that can handle all entities and exposes public methods to persist/fetch any kinds of entity.
We would still keep a "simple" implementation to which the logic falls back (for unit tests and such).
Edit 2021-01-04
As part of #882, the DomainResolverInterface interface is now ShortUrlRelationResolverInterface, which means we can add the logic for tags here.
Edit 2021-01-31
As part of this, the PATCH /short-urls/{shortCode} endpoint can gain support to edit the short URL tags.
That should effectively deprecate the PUT /short-urls/{shortCode}/tags endpoint.
It's also interesting if the PATCH endpoint returns the serialized short URL instead of an empty response.
The text was updated successfully, but these errors were encountered:
acelaya
changed the title
Improve how ShortUrl relations are resolved (domains and tags)
Improve how ShortUrl relations are resolved (domains, tags and API keys)
Nov 7, 2020
acelaya
changed the title
Improve how ShortUrl relations are resolved (domains, tags and API keys)
Improve how ShortUrl relations are resolved (domains and tags)
Jan 4, 2021
Currently, when creating a ShortUrl, there are two entities that could need to be created or fetched as a side effect, Tag and Domain.
These are always provided as strings that reference to a unique index for their respective entities, which result in the tag/domain being created if it does not exist, or fetched otherwise, resulting in a relationship with ShortUrl in both cases.
This is currently handled differently for tags and domains.
For domains
The ShortUrl expects an object implementing
DomainResolverInterface
to be optionally provided. If it is not provided, it falls back to the basic implementation,SimpleDomainResolver
, which just returns a new Domain instance always.However, at runtime, a
PersistenceDomainResolver
is always provided, which depends on the EntityManager, and therefore, it is capable of persisitng/fetching actual domains from persistence layer.For tags
Services that need to create the list of tags for a ShortUrl, use the
TagManagerTrait
, which exposes a method to create/fetch tags.These tags are later set to the ShortUrl via setter.
Proposal
These are the problems we need to resolve:
The way in which this problem is handled for domains is better than the other one, but having to pass "resolvers" for each one of them makes it a bit cumbersome.
One option is to have a single "resolver" that can handle all entities and exposes public methods to persist/fetch any kinds of entity.
We would still keep a "simple" implementation to which the logic falls back (for unit tests and such).
Edit 2021-01-04
As part of #882, the
DomainResolverInterface
interface is nowShortUrlRelationResolverInterface
, which means we can add the logic for tags here.Edit 2021-01-31
As part of this, the
PATCH /short-urls/{shortCode}
endpoint can gain support to edit the short URL tags.That should effectively deprecate the
PUT /short-urls/{shortCode}/tags
endpoint.It's also interesting if the PATCH endpoint returns the serialized short URL instead of an empty response.
The text was updated successfully, but these errors were encountered: