-
-
Notifications
You must be signed in to change notification settings - Fork 166
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 3: New Version class #6442
base: v5/develop
Are you sure you want to change the base?
Conversation
80b56cc
to
e884d2b
Compare
d62afaf
to
5bcc7ef
Compare
5bcc7ef
to
d01a480
Compare
d01a480
to
a9f038d
Compare
/** | ||
* Creates a new version for the given language | ||
*/ | ||
public function create(array $fields, string $language = 'default'): void |
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.
With our current translation architecture (automatic field fallbacks to the default language) we can only lock all language versions together to the same user when editing.
So e.g. when creating a changes
version from an existing published
version, the changes
version must always contain all languages that the published
version has.
I don't fully understand how this $version->create()
instance method is going to be used. To ensure that the version is complete and consistent, I feel like creation needs to happen atomically, e.g. with a static Version::create(ModelWithContent $model, VersionId $id)
method that then takes care to take the content fields from the right source (changes takes content from published, drafts start with empty content, published cannot be created standalone) and to ensure all languages.
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.
You are right. This was implemented before we talked about returning null for non-existing versions. That would have meant that the version instance could be initalized and the creat method could have been called like that before it exists.
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.
How do we proceed here? I guess we will produce a lot of merge conflicts if we change it here. So maybe let's continue and add it to the todo list?
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.
Yes, sounds good to me. We already have a todo list item in Notion. I think it makes sense to fix it in a separate PR when we get to that point.
} | ||
|
||
// delete a single language | ||
$this->model->storage()->delete($this->id, $language); |
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.
What is the use case for deleting a single language? Do we already support that in v4?
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.
Tbh I mostly just moved over what we had in ContentStorage here. I think you are right and we don't need it so far. This would also clean up the method some more. I'm not super happy about the ambiguous usage depending on what's passed.
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'll check the code and concept history again. If there is no reason, I'll remove it. We can still add it back if we ever need it.
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.
Did you have time to check it already or should I have another look at it?
This PR β¦
Refactoring
Version
class which inherits most of the logic from theContentStorage
handler and will eventually replace it.Outlook
Version
class and add additional unit tests (Changes 6: Version class improvements and unit testsΒ #6450) The steps are separated to make sure that all other unit tests always keep passing. It's sometimes a bit of a chicken and egg situation here.ContentStorageHandler
methods accept aLanguage
object instead of a string (Changes 4: Refactor PlainTextContentStorageHandler to use Language objectΒ #6448) theVersion
class also needs to pass aLanguage
object instead of language codes. It will therefor get a new protectedVersion::language()
method that is mostly adapted fromContentStorage::language()
but will always return aLanguage
object - even in a single-language installation. There's a newLanguage::single()
method coming up in Changes 4: Refactor PlainTextContentStorageHandler to use Language objectΒ #6448 for that.Version
class will also inherit a few more specific logic methods fromContentStorage
in preparation of removingContentStorage
entirely::deleteLanguage
::touchLanguage
::contentFile
Version::modified
will later return null if the version does not exist.Version::ensure
will later useContentStorageHandler::ensure
Changes 10: New MemoryContentStorageHandlerΒ #6457Breaking changes
None
Ready?
For review team