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 is there any way calling function of another module's class except creating new object using
Hi team
is there any way calling function of another module's class except creating new object using new or dependency injection every time
Comments
-
You could make a method static to call it via
<class>::<method>
but if you neither want to create an object via new nor inject it through DI you might try something very odd and should reconsider if this is the right way to solve your requirement.0 -
ok thanks
0 -
please suggest for the following scenario:
If we need to create category from our custom module then we will call existing function of category module. If in this case we will create object of category class using new to call function of the same class then please let me confirm whether this will not be against spryker coding structure or we can go ahead with using new0 -
There is the
\Spryker\Zed\Category\Business\CategoryFacadeInterface::createCategory
method you can use to add a new category.
Creating transfer objects withnew
is completely fine.You can then inject the
CategoryFacadeInterface
into your object that will need to create a new category, by using the respective<YourModule>DependencyProvider
as described in the tutorial section: https://docs.spryker.com/docs/scos/dev/tutorials-and-howtos/introduction-tutorials/tutorial-architectural-walkthrough-spryker-commerce-os.html#e[โฆ]e0 -
Thanks @UL6DGRULR. I am able to reach the function
create
ofvendor/spryker/category/src/Spryker/Zed/Category/Business/CategoryFacade.php
. Now there is the dependency ofCategoryTransfer
in that function. Please suggest do I need to follow all the steps given increateCategory
function ofvendor/spryker/category/tests/SprykerTest/Zed/Category/_support/Helper/CategoryHelper.php
All dependencies mentioned in the above function will need to be resolved or there is any better approach for the same to create category.0 -
You could use "find usage" in your editor to see where the
\Spryker\Zed\Category\Business\CategoryFacade::create
is used and how it's done. That would lead you to the\Spryker\Zed\Category\Communication\Controller\CreateController::indexAction
and\Spryker\Zed\Category\Communication\Form\CategoryType
where you can see what data needs to be passed into the transfer to create a new category. Use this code as a blueprint for what you want to achieve as it is almost the same.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
- 930 Developer Corner
- 788 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
- 33 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random