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..
Hi Team Please let me know which layer should be used to consume third-party APIs.
Hi Team
Please let me know which layer should be used to consume third-party APIs.
Comments
-
It depends on what type of 3rd party. It could be Zed or Service, depending on what do you want to do with that API.
0 -
With that API , we want to save Data in Database. and simultaneously publish and synchronize to RabbitMq
Currently, flow going fromPyz/Zed/Module/Communication/Console
Command toBusiness Facade
and then from facade toBusiness Factory
and there depends on parameter, newbusiness model
objects are getting instantiated. In those business models, third party API is consumed and API response is getting saved to Database
Please confirm the flow.0 -
Looks all right to me. I think I would have done a similar flow if not the same π
0 -
ok thanks.π
One more point if I am running code sniffer architecure on my module then I am getting
method in factories must not contain anew
keyword violation. Can you please help me how to resolve the above violation.0 -
Thatβs right. you need to extract in βprivate methodsβ, one βnewβ per method. For example:
# Spryker\Zed\Cms\Business\CmsBusinessFactory:110 public function createGlossaryKeyMappingManager(): GlossaryKeyMappingManagerInterface { return new GlossaryKeyMappingManager( $this->getGlossaryFacade(), $this->getQueryContainer(), $this->createTemplateManager(), $this->createPageManager() ); } [...] // public/private depends on the scope of the function itself, of course public function createTemplateManager(): TemplateManagerInterface { return new TemplateManager( $this->getQueryContainer(), $this->getConfig(), $this->createFinder() ); } [...] # etc
you can see, there is only one
new
keyword on each factory method π0 -
Please look into that, I found some contradiction here. If I have written only one new statement in factory method then also it is giving error
if I have written following function:public function getBSLSprykerDataWriter()
{
return new BSLSprykerDataMappingWriter();
}
then also c:s:a giving following errorFactories: The factory method Pyz\Zed\BSLSprykerDataMapping\Business\BSLSprykerDataMappingBusinessFactory::getBSLSprykerDataWriter() contains 1 new statements which violates rule "A
get*()
method in factories must not contain anew
keyword."0 -
Factories have a naming convention. You must use the
create
prefix if you are usingnew
. You should only use theget
prefix if you are fetching an instance from the container.0 -
In other words change your method to
createBSLSprykerDataWriter
and everything will be ok π0 -
Exactly.
β’ createFoo(): Foo -> needs anew
β’ getBar(): Bar -> nonew
keyword -> this uses theDependencyProvider
from the Factory0 -
ok got it
Thank you so much @UKEP86J66 and @U015S0C0V29 π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