Persisting value objects in Typo3












0















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.










share|improve this question





























    0















    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.










    share|improve this question



























      0












      0








      0








      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.










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 19 at 12:41









      Peter Kraume

      714415




      714415










      asked Jan 18 at 16:04









      Rudolph GottesheimRudolph Gottesheim

      1,46111226




      1,46111226
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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 incrementing uid field as well as the fields you need for your VO. Ensure that you create a combined unique index on the amount and currency 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.






          share|improve this answer








          New contributor




          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





















          • 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











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          1














          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 incrementing uid field as well as the fields you need for your VO. Ensure that you create a combined unique index on the amount and currency 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.






          share|improve this answer








          New contributor




          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





















          • 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
















          1














          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 incrementing uid field as well as the fields you need for your VO. Ensure that you create a combined unique index on the amount and currency 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.






          share|improve this answer








          New contributor




          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





















          • 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














          1












          1








          1







          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 incrementing uid field as well as the fields you need for your VO. Ensure that you create a combined unique index on the amount and currency 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.






          share|improve this answer








          New contributor




          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.










          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 incrementing uid field as well as the fields you need for your VO. Ensure that you create a combined unique index on the amount and currency 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.







          share|improve this answer








          New contributor




          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered Jan 20 at 20:49









          Jacob RasmussenJacob Rasmussen

          811




          811




          New contributor




          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Jacob Rasmussen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.













          • 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











          • 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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Liquibase includeAll doesn't find base path

          How to use setInterval in EJS file?

          Petrus Granier-Deferre