Inheritance: extends Symfony\Component\EventDispatcher\GenericEvent
Ejemplo n.º 1
0
 public function testResponse()
 {
     $event = new EventArgs(array());
     $this->assertNull($event->getResponse());
     $this->assertFalse($event->hasResponse());
     // 通常のレスポンスの検証
     $response = new Response();
     $event->setResponse($response);
     $this->assertNotNull($event->getResponse());
     $this->assertTrue($event->hasResponse());
     // リダイレクトレスポンスの検証
     $response = new RedirectResponse('http://www.ec-cube.net/');
     $event->setResponse($response);
     $this->assertNotNull($event->getResponse());
     $this->assertTrue($event->hasResponse());
 }
Ejemplo n.º 2
0
 /**
  * New Event:function on version >= 3.0.9 (new hook point)
  * Save event.
  *
  * @param EventArgs $eventArgs
  */
 public function onAdminProductEditComplete(EventArgs $eventArgs)
 {
     log_info('Event: product maker hook into the product management complete start.');
     /**
      * @var Form $form
      */
     $form = $eventArgs->getArgument('form');
     /**
      * @var Product $Product
      */
     $Product = $eventArgs->getArgument('Product');
     /**
      * @var ProductMakerRepository $repository
      */
     $repository = $this->app['eccube.plugin.maker.repository.product_maker'];
     /**
      * @var ProductMaker $ProductMaker
      */
     $ProductMaker = $repository->find($Product);
     if (!$ProductMaker) {
         $ProductMaker = new ProductMaker();
     }
     $maker = $form->get('plg_maker')->getData();
     if (!$maker) {
         if ($ProductMaker->getId()) {
             log_info('Event: product maker removed', array('Product maker id' => $ProductMaker->getId()));
             $this->app['orm.em']->remove($ProductMaker);
             $this->app['orm.em']->flush($ProductMaker);
         }
         return;
     }
     $makerUrl = $form->get('plg_maker_url')->getData();
     $ProductMaker->setId($Product->getId())->setMakerUrl($makerUrl)->setDelFlg(Constant::DISABLED)->setMaker($maker);
     /**
      * @var EntityRepository $this->app['orm.em']
      */
     $this->app['orm.em']->persist($ProductMaker);
     $this->app['orm.em']->flush($ProductMaker);
     log_info('Event: product maker save success!', array('Product id' => $ProductMaker->getId()));
     log_info('Event: product maker hook into the product management complete end.');
 }
 /**
  * 管理画面:カテゴリ登録画面で、登録処理を行う.
  *
  * @param EventArgs $event
  */
 public function onAdminProductCategoryEditComplete(EventArgs $event)
 {
     /** @var Application $app */
     $app = $this->app;
     /** @var Category $target_category */
     $TargetCategory = $event->getArgument('TargetCategory');
     /** @var FormInterface $form */
     $form = $event->getArgument('form');
     // 現在のエンティティを取得
     $id = $TargetCategory->getId();
     $CategoryContent = $app['category_content.repository.category_content']->find($id);
     if (is_null($CategoryContent)) {
         $CategoryContent = new CategoryContent();
     }
     // エンティティを更新
     $CategoryContent->setId($id)->setContent($form[self::CATEGORY_CONTENT_TEXTAREA_NAME]->getData());
     // DB更新
     $app['orm.em']->persist($CategoryContent);
     $app['orm.em']->flush($CategoryContent);
 }
Ejemplo n.º 4
0
 /**
  * 管理画面:カテゴリ登録画面で、登録処理を行う.
  *
  * @param EventArgs $event
  */
 public function onAdminProductCategoryEditComplete(EventArgs $event)
 {
     log_info('CategoryContent admin.product.category.index.complete start');
     /** @var Application $app */
     $app = $this->app;
     /* @var Category $TargetCategory */
     $TargetCategory = $event->getArgument('TargetCategory');
     /** @var FormInterface $form */
     $form = $event->getArgument('form');
     // 現在のエンティティを取得
     $id = $TargetCategory->getId();
     $CategoryContent = $app['eccube.plugin.category_content.repository.category_content']->find($id);
     if (!$CategoryContent) {
         $CategoryContent = new CategoryContent();
     }
     // エンティティを更新
     $CategoryContent->setId($id)->setContent($form[self::CATEGORY_CONTENT_TEXTAREA_NAME]->getData());
     // DB更新
     $app['orm.em']->persist($CategoryContent);
     $app['orm.em']->flush($CategoryContent);
     log_info('Category Content save successful !', array('category id' => $id));
     log_info('CategoryContent admin.product.category.index.complete end');
 }
Ejemplo n.º 5
0
 /**
  * 配送先や支払い方法変更時の合計金額と値引きの差額チェック
  * v3.0.9以降で使用
  *
  * @param EventArgs $event
  */
 public function onRestoreDiscount(EventArgs $event)
 {
     if ($event->hasArgument('Order')) {
         $Order = $event->getArgument('Order');
     } else {
         $Shipping = $event->getArgument('Shipping');
         $Order = $Shipping->getOrder();
     }
     $this->restoreDiscount($Order);
 }
Ejemplo n.º 6
0
 /**
  * new hookpoint for save RelatedProduct.
  *
  * @param EventArgs $event
  */
 public function onRenderAdminProductComplete(EventArgs $event)
 {
     log_info('RelatedProduct trigger onRenderAdminProductComplete start');
     $app = $this->app;
     $Product = $event->getArgument('Product');
     $form = $event->getArgument('form');
     $app['eccube.plugin.repository.related_product']->removeChildProduct($Product);
     log_info('remove all now related product data of ', array('Product id' => $Product->getId()));
     $RelatedProducts = $form->get('related_collection')->getData();
     foreach ($RelatedProducts as $RelatedProduct) {
         /* @var $RelatedProduct \Plugin\RelatedProduct\Entity\RelatedProduct */
         if ($RelatedProduct->getChildProduct() instanceof Product) {
             $RelatedProduct->setProduct($Product);
             $app['orm.em']->persist($RelatedProduct);
             $app['orm.em']->flush($RelatedProduct);
             log_info('save new related product data to DB ', array('Related Product id' => $RelatedProduct->getId()));
         }
     }
     log_info('RelatedProduct trigger onRenderAdminProductComplete finish');
 }