-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Changes 13: New translation classes #6491
Changes 13: New translation classes #6491
Conversation
d0d6e8a
to
b5dc1c9
Compare
@bastianallgeier regarding your code coverage: none of your test methods says that it covers the |
@distantnative wait, am I missing something? https://github.com/getkirby/kirby/pull/6491/files#diff-be3909337c2195af14e3332b8945acaa88ae6801f3b6f92f4fa40343240c0747R111 I really think I'm going crazy here. I even tried to re-type that @Covers part in case I had an invisible character in it or some other typo that I just don't see. |
@bastianallgeier sorry, my bad, mistook |
@bastianallgeier it seems tied to the method name. When I rename the method to
|
So weird about the name! We could try what happens when we add a coverage ignore rule. About the deprecated methods. We don't need to be that strict. My thought behind is that the translation class really acts more like glue for us between language, version and content. To repeat a lot of the version methods would be quite redundant. That's why I think we should encourage to prefer going through the versions. But that's totally up for discussions. Did you specify the language when you used the alternative? |
I'm for the depreciations. But we should adapt the tests then, shouldn't we? Currently the CI throws all the deprecation warnings. |
I have to be honest, I don't really know how to treat the depredations in unit tests so far |
@bastianallgeier I am talking about replacing the deprecated code. Currently the test still use all the deprecated methods, e.g. $this->assertSame('en', $translationEN->code()); should be changed to $this->assertSame('en', $translationEN->language()->code()); etc. |
fc022e9
to
1afa5c5
Compare
90ebb8f
to
36d8df4
Compare
@distantnative I've replaced all deprecated methods in the unit tests. |
1afa5c5
to
b6a949b
Compare
0e54467
to
4648e2a
Compare
4648e2a
to
8f94357
Compare
6c03ae2
to
4b53a08
Compare
8f94357
to
84cdf0a
Compare
4b53a08
to
3bb3d23
Compare
c62e360
to
78b12f5
Compare
cedd533
to
a6ea212
Compare
Co-authored-by: Nico Hoffmann ෴. <[email protected]>
Co-authored-by: Nico Hoffmann ෴. <[email protected]>
78b12f5
to
241501d
Compare
Co-authored-by: Lukas Bestle <[email protected]>
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.
Two methods of ContentTranslation
that Translation
does not implement anymore (and doesn't need to) are parent()
and update()
. In order to make the transition smoother, we need to find bugs early where we maybe still rely on these methods. So I suggest to add overrides for these two methods to the Translation
class that throw an exception.
With that I think we can finally merge this.
This PR …
Reasoning
The
ContentTranslation
class is one of our internal classes that still uses array props in the constructor and also has some logic that shouldn't be in there. To untangle the translation knot, it really helps to refactor this class to named properties and turn most of its methods into proxies to access the underlying version or language objects.In order to turn this into a smooth transition, I've decided to extend the
ContentTranslation
class for now. This way, we can use it as a replacement forContentTranslation
in many parts already before we replace it later. We can also change methods more freely without affecting the CMS Models and their unit tests too drastically for now.Features
Kirby\Content\Translation
class (to eventually replaceKirby\Content\ContentTranslation
)Kirby\Content\Translations
class to help inModelWithContent::translations
later and to provide a more type-safe collection for all translations.The following changes to
Translation
will be new features as soon as it replaces theContentTranslation
class.Translation::version
method to return the parentVersion
instanceTranslation::create
method to setup a new translation from an array of fields.Deprecated
Translation::code
Use::language()->code()
insteadTranslation::content
Use::version()->content()->toArray()
insteadTranslation::contentFile
Use::version()->contentFile()
insteadTranslation::exists
Use::version()->exists()
insteadTranslation::isDefault
Use::language()->isDefault()
insteadBreaking changes
The following changes to the
Translation
class will be breaking changes as soon as it will replace theContentTranslation
class.Translation::parent
has been replace withTranslation::model
Translation::update
has been removedCode coverage
No matter what I do,
Translations::load
is simply not covered and I don't know why.Ready?
For review team