Persisting value objects in Typo3
I've got a Money
class that extends AbstractValueObject
with the properties $amount
(int) and $currency
(string). And I've got an AbstractEntity
with a $price
property holding an instance of Money
. How do I get Typo3 to persist that value object? How do I define the mapping?
Coming from Doctrine, I'd expect it to be persisted in two columns price_amount
and price_currency
.
typo3 extbase
add a comment |
I've got a Money
class that extends AbstractValueObject
with the properties $amount
(int) and $currency
(string). And I've got an AbstractEntity
with a $price
property holding an instance of Money
. How do I get Typo3 to persist that value object? How do I define the mapping?
Coming from Doctrine, I'd expect it to be persisted in two columns price_amount
and price_currency
.
typo3 extbase
add a comment |
I've got a Money
class that extends AbstractValueObject
with the properties $amount
(int) and $currency
(string). And I've got an AbstractEntity
with a $price
property holding an instance of Money
. How do I get Typo3 to persist that value object? How do I define the mapping?
Coming from Doctrine, I'd expect it to be persisted in two columns price_amount
and price_currency
.
typo3 extbase
I've got a Money
class that extends AbstractValueObject
with the properties $amount
(int) and $currency
(string). And I've got an AbstractEntity
with a $price
property holding an instance of Money
. How do I get Typo3 to persist that value object? How do I define the mapping?
Coming from Doctrine, I'd expect it to be persisted in two columns price_amount
and price_currency
.
typo3 extbase
typo3 extbase
edited Jan 19 at 12:41
Peter Kraume
714415
714415
asked Jan 18 at 16:04
Rudolph GottesheimRudolph Gottesheim
1,46111226
1,46111226
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Extbase does things a bit differently - so value objects needs to be stored in their own tables and relations between objects are stored by using identifiers just like entities.
The only real difference between Entities and VOs is that the persistence manager will use property values
(except the identifier field) when looking for VOs for persistence whereas the identifier
will be used on Entities.
- So you need to add the database schema for the value object to
ext_tables.sql
and as the table should contain an auto incrementinguid
field as well as the fields you need for your VO. Ensure that you create a combined unique index on theamount
andcurrency
columns. - Define the TCA mapping and then you can persist value objects either directly if you create a repository or by attaching them to aggregate root objects and persisting these.
The price
property on your entity should be an integer in the database schema, as extbase will either store a reference to the uid of the VO (if you only refer to one Money object on your entity) and if you wish to store a collection of Money objects, Extbase will store the number of relations between your entity object and the Money VOs.
New contributor
That's exactly the information I was looking for. I think it's kind of a weird implementation, but at least I know what to do now. Thank you so much.
– Rudolph Gottesheim
2 days ago
You're welcome and I agree with you about the strange way it's implemented. However due to the integration of Doctrine in TYPO3 8LTS and the continued work on getting TYPO3 to be more standards compliant, one could hope that the implementation will change in a future major release.
– Jacob Rasmussen
2 days ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257536%2fpersisting-value-objects-in-typo3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Extbase does things a bit differently - so value objects needs to be stored in their own tables and relations between objects are stored by using identifiers just like entities.
The only real difference between Entities and VOs is that the persistence manager will use property values
(except the identifier field) when looking for VOs for persistence whereas the identifier
will be used on Entities.
- So you need to add the database schema for the value object to
ext_tables.sql
and as the table should contain an auto incrementinguid
field as well as the fields you need for your VO. Ensure that you create a combined unique index on theamount
andcurrency
columns. - Define the TCA mapping and then you can persist value objects either directly if you create a repository or by attaching them to aggregate root objects and persisting these.
The price
property on your entity should be an integer in the database schema, as extbase will either store a reference to the uid of the VO (if you only refer to one Money object on your entity) and if you wish to store a collection of Money objects, Extbase will store the number of relations between your entity object and the Money VOs.
New contributor
That's exactly the information I was looking for. I think it's kind of a weird implementation, but at least I know what to do now. Thank you so much.
– Rudolph Gottesheim
2 days ago
You're welcome and I agree with you about the strange way it's implemented. However due to the integration of Doctrine in TYPO3 8LTS and the continued work on getting TYPO3 to be more standards compliant, one could hope that the implementation will change in a future major release.
– Jacob Rasmussen
2 days ago
add a comment |
Extbase does things a bit differently - so value objects needs to be stored in their own tables and relations between objects are stored by using identifiers just like entities.
The only real difference between Entities and VOs is that the persistence manager will use property values
(except the identifier field) when looking for VOs for persistence whereas the identifier
will be used on Entities.
- So you need to add the database schema for the value object to
ext_tables.sql
and as the table should contain an auto incrementinguid
field as well as the fields you need for your VO. Ensure that you create a combined unique index on theamount
andcurrency
columns. - Define the TCA mapping and then you can persist value objects either directly if you create a repository or by attaching them to aggregate root objects and persisting these.
The price
property on your entity should be an integer in the database schema, as extbase will either store a reference to the uid of the VO (if you only refer to one Money object on your entity) and if you wish to store a collection of Money objects, Extbase will store the number of relations between your entity object and the Money VOs.
New contributor
That's exactly the information I was looking for. I think it's kind of a weird implementation, but at least I know what to do now. Thank you so much.
– Rudolph Gottesheim
2 days ago
You're welcome and I agree with you about the strange way it's implemented. However due to the integration of Doctrine in TYPO3 8LTS and the continued work on getting TYPO3 to be more standards compliant, one could hope that the implementation will change in a future major release.
– Jacob Rasmussen
2 days ago
add a comment |
Extbase does things a bit differently - so value objects needs to be stored in their own tables and relations between objects are stored by using identifiers just like entities.
The only real difference between Entities and VOs is that the persistence manager will use property values
(except the identifier field) when looking for VOs for persistence whereas the identifier
will be used on Entities.
- So you need to add the database schema for the value object to
ext_tables.sql
and as the table should contain an auto incrementinguid
field as well as the fields you need for your VO. Ensure that you create a combined unique index on theamount
andcurrency
columns. - Define the TCA mapping and then you can persist value objects either directly if you create a repository or by attaching them to aggregate root objects and persisting these.
The price
property on your entity should be an integer in the database schema, as extbase will either store a reference to the uid of the VO (if you only refer to one Money object on your entity) and if you wish to store a collection of Money objects, Extbase will store the number of relations between your entity object and the Money VOs.
New contributor
Extbase does things a bit differently - so value objects needs to be stored in their own tables and relations between objects are stored by using identifiers just like entities.
The only real difference between Entities and VOs is that the persistence manager will use property values
(except the identifier field) when looking for VOs for persistence whereas the identifier
will be used on Entities.
- So you need to add the database schema for the value object to
ext_tables.sql
and as the table should contain an auto incrementinguid
field as well as the fields you need for your VO. Ensure that you create a combined unique index on theamount
andcurrency
columns. - Define the TCA mapping and then you can persist value objects either directly if you create a repository or by attaching them to aggregate root objects and persisting these.
The price
property on your entity should be an integer in the database schema, as extbase will either store a reference to the uid of the VO (if you only refer to one Money object on your entity) and if you wish to store a collection of Money objects, Extbase will store the number of relations between your entity object and the Money VOs.
New contributor
New contributor
answered Jan 20 at 20:49
Jacob RasmussenJacob Rasmussen
811
811
New contributor
New contributor
That's exactly the information I was looking for. I think it's kind of a weird implementation, but at least I know what to do now. Thank you so much.
– Rudolph Gottesheim
2 days ago
You're welcome and I agree with you about the strange way it's implemented. However due to the integration of Doctrine in TYPO3 8LTS and the continued work on getting TYPO3 to be more standards compliant, one could hope that the implementation will change in a future major release.
– Jacob Rasmussen
2 days ago
add a comment |
That's exactly the information I was looking for. I think it's kind of a weird implementation, but at least I know what to do now. Thank you so much.
– Rudolph Gottesheim
2 days ago
You're welcome and I agree with you about the strange way it's implemented. However due to the integration of Doctrine in TYPO3 8LTS and the continued work on getting TYPO3 to be more standards compliant, one could hope that the implementation will change in a future major release.
– Jacob Rasmussen
2 days ago
That's exactly the information I was looking for. I think it's kind of a weird implementation, but at least I know what to do now. Thank you so much.
– Rudolph Gottesheim
2 days ago
That's exactly the information I was looking for. I think it's kind of a weird implementation, but at least I know what to do now. Thank you so much.
– Rudolph Gottesheim
2 days ago
You're welcome and I agree with you about the strange way it's implemented. However due to the integration of Doctrine in TYPO3 8LTS and the continued work on getting TYPO3 to be more standards compliant, one could hope that the implementation will change in a future major release.
– Jacob Rasmussen
2 days ago
You're welcome and I agree with you about the strange way it's implemented. However due to the integration of Doctrine in TYPO3 8LTS and the continued work on getting TYPO3 to be more standards compliant, one could hope that the implementation will change in a future major release.
– Jacob Rasmussen
2 days ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257536%2fpersisting-value-objects-in-typo3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown