-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementacion de Interceptors (PLUGIN)
- Loading branch information
1 parent
d0ead53
commit 01ff7b6
Showing
13 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
31 changes: 31 additions & 0 deletions
31
code/Foggyline/Plugged/Block/Catalog/Product/AbstractProductPlugin1.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Foggyline\Plugged\Block\Catalog\Product; | ||
|
||
class AbstractProductPlugin1 | ||
{ | ||
public function beforeGetAddToCartUrl( | ||
$subject, | ||
$product, $additional = [] | ||
) | ||
{ | ||
var_dump('Plugin1 - beforeGetAddToCartUrl'); | ||
} | ||
|
||
public function afterGetAddToCartUrl($subject) | ||
{ | ||
var_dump(get_class($subject)); | ||
var_dump('Plugin1 - afterGetAddToCartUrl'); | ||
} | ||
|
||
public function aroundGetAddToCartUrl( | ||
$subject, | ||
\Closure $proceed, | ||
$product, | ||
$additional = [] | ||
) | ||
{ | ||
var_dump('Plugin1 - aroundGetAddToCartUrl'); | ||
return $proceed($product, $additional); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
code/Foggyline/Plugged/Block/Catalog/Product/AbstractProductPlugin2.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Foggyline\Plugged\Block\Catalog\Product; | ||
|
||
class AbstractProductPlugin2 | ||
{ | ||
public function beforeGetAddToCartUrl( | ||
$subject, | ||
$product, $additional = [] | ||
) | ||
{ | ||
var_dump('Plugin2 - beforeGetAddToCartUrl'); | ||
} | ||
|
||
public function afterGetAddToCartUrl($subject) | ||
{ | ||
var_dump(get_class($subject)); | ||
var_dump('Plugin2 - afterGetAddToCartUrl'); | ||
} | ||
|
||
public function aroundGetAddToCartUrl( | ||
$subject, | ||
\Closure $proceed, | ||
$product, | ||
$additional = [] | ||
) | ||
{ | ||
var_dump(get_class($subject)); | ||
var_dump('Plugin2 - aroundGetAddToCartUrl'); | ||
return $proceed($product, $additional); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
code/Foggyline/Plugged/Block/Catalog/Product/AbstractProductPlugin3.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Foggyline\Plugged\Block\Catalog\Product; | ||
|
||
class AbstractProductPlugin3 | ||
{ | ||
public function beforeGetAddToCartUrl( | ||
$subject, | ||
$product, $additional = [] | ||
) | ||
{ | ||
var_dump('Plugin3 - beforeGetAddToCartUrl'); | ||
} | ||
|
||
public function afterGetAddToCartUrl($subject) | ||
{ | ||
var_dump(get_class($subject)); | ||
var_dump('Plugin3 - afterGetAddToCartUrl'); | ||
} | ||
|
||
public function aroundGetAddToCartUrl( | ||
$subject, | ||
\Closure $proceed, | ||
$product, | ||
$additional = [] | ||
) | ||
{ | ||
var_dump('Plugin3 - aroundGetAddToCartUrl'); | ||
return $proceed($product, $additional); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
|
||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Catalog\Block\Product\AbstractProduct"> | ||
<plugin name="foggyPlugin1" | ||
type="Foggyline\Plugged\Block\Catalog\Product\AbstractProductPlugin1" | ||
disabled="false" sortOrder="100"/> | ||
<plugin name="foggyPlugin2" | ||
type="Foggyline\Plugged\Block\Catalog\Product\AbstractProductPlugin2" | ||
disabled="false" sortOrder="200"/> | ||
<plugin name="foggyPlugin3" | ||
type="Foggyline\Plugged\Block\Catalog\Product\AbstractProductPlugin3" | ||
disabled="false" sortOrder="300"/> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
|
||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Foggyline_Plugged" setup_version="1.0.0"> | ||
<sequence> | ||
<module name="Magento_Catalog"/> | ||
</sequence> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
\Magento\Framework\Component\ComponentRegistrar::register( | ||
\Magento\Framework\Component\ComponentRegistrar::MODULE, | ||
'Foggyline_Plugged', | ||
__DIR__ | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters