-
-
Couldn't load subscription status.
- Fork 205
Feature/1713 - Replace slugify to symfony string #1827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.x
Are you sure you want to change the base?
Feature/1713 - Replace slugify to symfony string #1827
Conversation
fa5bd18 to
1b2b50f
Compare
|
hey @VincentLanglet do you know why doctrine.orm.entity_listener does not work 😄 ? Edit: I used Entity/BasePage (it worked) |
005f0e5 to
47641d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there is to many changes in a single PR.
If the purpose is to replace suglify by symfony string, why not JUST:
- changing SlugifyInterface into
SlugifyInterface|SluggerInterface - Updating the code to work with both
- Deprecating SlugifyInterface
?
Currently you are
- Introducing a new interface
- Introducing a new class
- Allowing
SlugifyInterface|FixPageUrlInterfacein PageManager - Adding a deprecation
- Introducing an Adapter
- Introducing a Factory
- Introducing a Listener
- And removing a
fixUrlcall in the validator
Be aware that sonata-project repository have almost no maintainer, so the smaller are the change, the better it is
Yeah I know it is a bit big , I was trying to avoid it.
It was my first thought, but I wanted to move this logical for a separated layer. But extracting the logical lead for a PR with too many things. I was trying to avoid change the arguments, and later change again. But I will see how to make changes small. Maybe I back with the first solution accepting both Slug interface |
261d840 to
9d6aa9e
Compare
|
@VincentLanglet could you take a look. I just extracted the |
src/Entity/PageManager.php
Outdated
| self::class, | ||
| FixPageUrlInterface::class, | ||
| ), \E_USER_DEPRECATED); | ||
| $fixPageUrl = FixPageUrlSlugifyFactory::create($fixPageUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this factory could be removed, since it is used only here and it won't be reused in the code. it will be like this
$fixPageUrl = new FixPageUrlService(new SluggerSlugifyAdapter($slugify));There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're already planning to pass a Symfony slugger to this service, we could already have a small change of behavior here, so I don't think we have to force the use of sluggify here, you could
(new FixPageUrlService(new AsciiSlugger()))->fix()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it will make the things easier, I do not need to keep support for slugify.
But don't you think we should keep an option to use Slugify in case someone find an issue and want to keep the old way?
or if someone want to use the old version, they should implement an SlugifyAdapter in their side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In next major we will remove sluggify anyway so if someone encounter an issue with the change it's better to fix it instead of keeping slugify support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed!
ab6ed87 to
181d376
Compare
| string $class, | ||
| ManagerRegistry $registry, | ||
| private SlugifyInterface $slugify, | ||
| private SlugifyInterface|FixPageUrlInterface $fixPageUrl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not changing this signature to
private SlugifyInterface|SluggerInterface
?
Either it make sens to introduce a FixPageUrl service and this should be done in a separate PR in which the name will be challenged, either it is not needed and we could simplify this pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently,
- I see no reason to introduce a FixPageUrlInterface because we don't plan having multiple implementation
- PageManager::fixUrl is basically useless since you can call FixPageUrl::fix directly (Which is not a bad thing but then the fixUrl method could be deprecated and the service injection)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private SlugifyInterface|SluggerInterface
if you see in my first try, I added some if statement to check which interface I am getting, and It makes the code more complex.
edit: those managers are like repositories: https://github.com/sonata-project/sonata-doctrine-extensions/blob/2.x/src/Entity/BaseEntityManager.php. and this logical should be in other layer.
Either it make sens to introduce a FixPageUrl service and this should be done in a separate PR in which the name will be challenged, either it is not needed and we could simplify this pr
But don't you think this PR is simple enough to review? I basically extracted the logical and I am injecting it.
I see no reason to introduce a FixPageUrlInterface because we don't plan having multiple implementation
we do not plan to have multi implementation in our code. But it will help the devs to override the code if they need.
PageManager::fixUrl is basically useless since you can call FixPageUrl::fix directly (Which is not a bad thing but then the fixUrl method could be deprecated and the service injection)
yep that is true. but I am planning to deprecate this in other PR.
cbad503 to
dab31e4
Compare
dab31e4 to
729d077
Compare
729d077 to
c6205ac
Compare
| use Sonata\PageBundle\Service\Contract\FixPageUrlInterface; | ||
| use Symfony\Component\String\Slugger\SluggerInterface; | ||
|
|
||
| final class FixPageUrlService implements FixPageUrlInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should go with
final class PageFixer impelments PageFixerInterface
{}
and a method PageFixerInterface::fixUrl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as it is a generic name, probably it will contain more methods with more fix. then you prefer have everything centralized in one place, even if it increases for 3 or 5 methods. and if we see it is necessary we refactor.
I do not have problem to change to PageFixer I just want to get your idea :). it will help for future PRs 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other question:
without suffix Service? if I keep inside of Service it will be different of other classes that already exist.
edit: it is mixed, there are services inside of src/Page/Service, src/Bock and src/Service
edit 2: I will keep with Service suffix as others services uses the same way, is it ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally hate the suffix service, didn't know some of the had.
On the opposite, other service like PageManager don't have such suffix.
We could create a folder Fixer ? with:
src/Fixer/PageFixerInterface
src/Fixer/PageFixer
WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in src/ level we should keep things like
- Adapter
- Bridge
- Serializer
- Http
- Runtime
- Service
- Listener
etc I guess you know what I mean 😄 .. Fixer does not sound good IMO in src/ level.
I guess inside of Services fits good, But wihout Suffix, maybe we need to decide to keep or not Suffix.
well the problem in not using suffix, is it is in PSR for others things like MyCodeInterface.
Replace slugify to symfony string
Closes #1713.
Related PR: #1718.
Changelog