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, everyone, I try to find out the concept behind the Bridge-classes, e.g. `ProductValidi
Good morning, everyone,
I try to find out the concept behind the Bridge-classes, e.g. ProductValidityToProductFacadeBridgeInterface
. I remember something like "Don't use Bridge-classes on project level.". I've heard or read it somewhere. Now I want to understand what the purpose of those classes is and why they shouldn't be used on project level but sadly, I can't find any documentation.
As far as I understand the purpose is to reduce the access to the methods of a facade to a set that is relevant to the current module. But this would mean that it's not possible to not use them on project level.
Does somebody of you know about it or can provide some docs for this?
Comments
-
@UJN2JRU4F this is related to the question of @U01LLUGR1F0 that you were talking about yesterday (if my information is correct π )
0 -
bonjour
0 -
let me check the docs, because there is info for sure.
0 -
in a nutshell, bridges are the core-side standard adapter implementation for the
ModuleToModuleInterfaces
you can find in theDependency/
directory in most Zed modules0 -
these abstractions (the interfaces) exist to isolate a moduleβs business context. nothing in the Business layer directly depends on anything outside the module
0 -
itβs a bit of module level interface segregation and the second part of dependency inversion
0 -
docs here π https://documentation.spryker.com/docs/ht-extend-inuse-core
0 -
i will happily discuss the proposed solution there. and i have my own opinions about it. π
0 -
Spryker/Zed/ProductValidity/Business/ProductConcrete/ProductConcreteSwitcher.php
/** * @param \Spryker\Zed\ProductValidity\Persistence\ProductValidityQueryContainerInterface $queryContainer * @param \Spryker\Zed\ProductValidity\Dependency\Facade\ProductValidityToProductFacadeInterface $productFacade */ public function __construct( ProductValidityQueryContainerInterface $queryContainer, ProductValidityToProductFacadeInterface $productFacade ) { $this->queryContainer = $queryContainer; $this->productFacade = $productFacade; }
-> here the Bridge is type hinted
We have overwritten the ProductFacade
so we get this in the overwritten Dependency Provider
use ProductFacadeDependencyProviderTrait; /** * @param \Spryker\Zed\Kernel\Container $container * * @return \Spryker\Zed\Kernel\Container */ public function provideBusinessLayerDependencies(Container $container): Container { $container = parent::provideBusinessLayerDependencies($container); $this->addProductFacade($container); return $container; }
the used trait overwrites the addProductFacade method like this:
/** * @param \Spryker\Zed\Kernel\Container $container * * @return \Spryker\Zed\Kernel\Container */ protected function addProductFacade(Container $container): Container { $container->set( ProductDependencyProviderConstants::FACADE_PRODUCT, static function (Container $container) { /* @phpstan-ignore-next-line */ return $container->getLocator()->product()->facade(); } ); return $container; }
In the parent class it looks like this:
/** * @param \Spryker\Zed\Kernel\Container $container * * @return \Spryker\Zed\Kernel\Container */ protected function addProductFacade(Container $container) { $container->set(static::FACADE_PRODUCT, function (Container $container) { return new ProductValidityToProductFacadeBridge($container->getLocator()->product()->facade()); }); return $container; }
so therefore we had to add
ProductValidityToProductFacadeInterface
to over overwritten ProductFacade
also we had to overwrite these functions in our overwritten ProductFacade, because the bridge type hints with int, but the facade doesn't
public function activateProductConcrete($idProductConcrete): void { parent::activateProductConcrete($idProductConcrete); } public function deactivateProductConcrete($idProductConcrete): void { parent::deactivateProductConcrete($idProductConcrete); }
this seems really hacky to us, hence my question yesterday if this is really the right way to do it
0 -
I just read the documentation you provided. It basically says that we're doing it the way it is proposed there. (And there is the sentence I remembered: "Bridges are for core-level only.")
0 -
Thanks a lot
0 -
well, yes. roughly π
0 -
there are actually no type hints for the bridge but the ModuleToModuleInterface
0 -
is the above trait from core side?
0 -
the documentation also leaves a bit of room for interpretation, but on first glance your solution looks like what is proposed in the docs
0 -
The trait is implemented on project level.
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
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random