What are the Slack Archives?
Itโs a history of our time together in the Slack Community! Thereโs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonโt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Good Morning, is there a reason to not return an *EntityTransfer from a facade?
Good Morning,
is there a reason to not return an *EntityTransfer from a facade?
Comments
-
Because (db) entities should live only in the Persistence layer in order to avoid spreading those โwrite modelsโ outside the module itself. Thatโs one of the reasons why you want to return only transfer objects, which are plain objects with data.
Is not just for the Facade, but for the Repositories as well. You want to minimise the scope of the objects with Propel magic in order to make your code more predictable. For this reason, in your business layer you also want to use the repository/em interfaces which should return transfer objects as well.
The only exception (in Spryker) is for Middleware. On which they โallowโ to use propel entities for performance reasons.
A great book that explains in details all of this is this one:
Advanced Web Application Architecture ๐
https://chemaclass.es/readings/advance-web-application-architecture/0 -
I'm not talking about Entity objects which would grant write access to the database but about those auto generated EntityTransfers which are Transfer Objects (thus no db write logic inside) that have the same fields as the corresponding EntityObject. (E.g. Generated\Shared\Transfer\SpyQuoteEntityTransfer NOT Orm\Zed\Quote\Persistence\SpyQuote)
0 -
EntityTransfer approach is deprecated.
0 -
How do I know it is deprecated? https://documentation.spryker.com/docs/entity-manager So the whole page is deprecated?
0 -
From my understanding:
โข EntityManager = save/update/delete (command)
โข Repository = get/find (query)
โฆ get: returns something or Exception;
โฆ find: returns something or null
They receive primitives or TransferObjects, and return primitives or TransferObjects. The goal is isolate the scope of entity objects under the Persistence layer only.TL;DR: that docu-page that you shared is a bit unclear; specially with those
SpyFooEntityTransfer
stuffโฆ Maybe the prefix on those examples is just leading to misinterpretation, or I understood that wrong, or is simply just wrong. I canโt tell.0 -
@U015S0C0V29 there are generated *EntityTransfers which are basically the same as propel classes but extend
AbstractTransfer
which disable their ability to update the database.@U01A1HDSVS8 The main reason is to avoid exposing the database representation of a domain object outside of its module. That is internal module knowledge and how we represent it in database is irrelevant for the business layer of other modules. Usually Domain Transfers are a bit more complicated than just database representation and we have the rule that those Transfers are dealt with the same way as propel objects (Do not leave facades)
0 -
Ah! Thanks for clarifying that, @ULL9CA6CB. Is this โEntityTransfersโ a new concept? I didnโt know them before
0 -
Not a new concept though, but they are barely used really.
0 -
Thank you very much @ULL9CA6CB!
0 -
This makes sense now, thanks ๐๐ป
0 -
One more Questions though: Why are those EnitityTransfers there at all? The EntityManger could work with the Entity itself as it is in the Persitence Layer!?
0 -
Good question ๐
As I said, rarely used. I think they are MAINLY used in infrastructural parts of P&S to avoid destroying the rule of โNo facade should return a Propel objectโ0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K ๐ Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random