-
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.
1.- creamos nuestro controlador Myevent , aqui tenemos el evento dispacth que activa el vento registrado en events.xml 2.- creamos nuestro evento events.xml el cual declara un observador llamado TestObserver 3.- creamos nuestro Observador
- Loading branch information
1 parent
2d443be
commit d0ead53
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
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,14 @@ | ||
<?php | ||
namespace Pfay\Contacts\Controller\Test; | ||
|
||
use Magento\Framework\App\Action\Action; | ||
|
||
class Myevent extends Action | ||
{ | ||
public function execute() | ||
{ | ||
|
||
$this->_eventManager->dispatch('pfay_contacts_event_test'); | ||
die('test'); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
namespace Pfay\Contacts\Observer; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\Event\ObserverInterface; | ||
|
||
/** | ||
* Class TestObserver | ||
*/ | ||
class TestObserver implements ObserverInterface | ||
{ | ||
|
||
/** | ||
* @param Observer $observer | ||
* @return void | ||
*/ | ||
public function execute(Observer $observer) | ||
{ | ||
die('test observer'); | ||
} | ||
} |
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,6 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> | ||
<event name="pfay_contacts_event_test"> | ||
<observer name="pfay_contacts_observer_test" instance="Pfay\Contacts\Observer\TestObserver" /> | ||
</event> | ||
</config> |