-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chihiro-adachi
committed
May 29, 2017
1 parent
e275172
commit c399e14
Showing
3 changed files
with
54 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,24 @@ | ||
<?php | ||
|
||
namespace Plugin\EntityEvent\Entity; | ||
|
||
use Doctrine\ORM\Event\LifecycleEventArgs; | ||
use Doctrine\ORM\Event\PreUpdateEventArgs; | ||
use Eccube\Annotation\PreUpdate; | ||
use Eccube\Entity\Event\EntityEventListener; | ||
|
||
/** | ||
* @PreUpdate("Eccube\Entity\BaseInfo") | ||
*/ | ||
class BaseInfoListener implements EntityEventListener | ||
{ | ||
public function execute(LifecycleEventArgs $eventArgs) | ||
{ | ||
/** @var PreUpdateEventArgs $eventArgs */ | ||
$new = $eventArgs->getNewValue('company_name'); | ||
$old = $eventArgs->getOldValue('company_name'); | ||
|
||
error_log($new); | ||
error_log($old); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
app/Plugin/EntityEvent/ServiceProvider/EntityEventServiceProvider.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,25 @@ | ||
<?php | ||
|
||
namespace Plugin\EntityEvent\ServiceProvider; | ||
|
||
use Pimple\Container; | ||
use Pimple\ServiceProviderInterface; | ||
use Plugin\EntityEvent\Entity\BaseInfoListener; | ||
use Silex\Api\BootableProviderInterface; | ||
use Silex\Application; | ||
|
||
class EntityEventServiceProvider implements ServiceProviderInterface, BootableProviderInterface | ||
{ | ||
public function register(Container $app) | ||
{ | ||
$app['plugin.entity_event.base_info_listener'] = function (Container $container) { | ||
return new BaseInfoListener(); | ||
}; | ||
} | ||
|
||
public function boot(Application $app) | ||
{ | ||
$app['eccube.entity.event.dispatcher'] | ||
->addEventListener($app['plugin.entity_event.base_info_listener']); | ||
} | ||
} |
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,5 @@ | ||
name: Entityイベント拡張のサンプル | ||
code: EntityEvent | ||
version: 1.0.0 | ||
service: | ||
- EntityEventServiceProvider |