Skip to content

Commit

Permalink
Merge pull request #2510 from kiy0taka/dev/remove-soft-delete-filter
Browse files Browse the repository at this point in the history
SoftDeleteFilterの廃止
  • Loading branch information
Chihiro Adachi committed Sep 19, 2017
2 parents a818b9d + eecdb13 commit 1e387ca
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 163 deletions.
5 changes: 0 additions & 5 deletions src/Eccube/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

namespace Eccube;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\DBAL\Types\Type;
use Eccube\Doctrine\DBAL\Types\UTCDateTimeType;
use Eccube\Doctrine\DBAL\Types\UTCDateTimeTzType;
Expand Down Expand Up @@ -718,10 +715,8 @@ function (\Doctrine\ORM\Configuration $config, \Silex\Application $app) {

// filters
$config = $em->getConfiguration();
$config->addFilter("soft_delete", '\Eccube\Doctrine\Filter\SoftDeleteFilter');
$config->addFilter("nostock_hidden", '\Eccube\Doctrine\Filter\NoStockHiddenFilter');
$config->addFilter("incomplete_order_status_hidden", '\Eccube\Doctrine\Filter\OrderStatusFilter');
$em->getFilters()->enable('soft_delete');

return $em;
});
Expand Down
12 changes: 2 additions & 10 deletions src/Eccube/Controller/Admin/Order/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager;
use Eccube\Annotation\Inject;
use Eccube\Annotation\Component;
use Eccube\Annotation\Inject;
use Eccube\Application;
use Eccube\Common\Constant;
use Eccube\Controller\AbstractController;
use Eccube\Entity\Master\CustomerStatus;
use Eccube\Entity\Master\DeviceType;
Expand All @@ -47,9 +46,9 @@
use Eccube\Service\PurchaseFlow\PurchaseException;
use Eccube\Service\PurchaseFlow\PurchaseFlow;
use Eccube\Service\TaxRuleService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bridge\Monolog\Logger;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\FormFactory;
Expand Down Expand Up @@ -164,13 +163,6 @@ class EditController extends AbstractController
*/
public function index(Application $app, Request $request, $id = null)
{
/* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */
$softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete');
$softDeleteFilter->setExcludes(array(
'Eccube\Entity\ProductClass',
'Eccube\Entity\Product',
));

$TargetOrder = null;
$OriginOrder = null;

Expand Down
17 changes: 2 additions & 15 deletions src/Eccube/Controller/Admin/Product/ProductClassController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManager;
use Eccube\Annotation\Inject;
use Eccube\Annotation\Component;
use Eccube\Annotation\Inject;
use Eccube\Application;
use Eccube\Common\Constant;
use Eccube\Entity\BaseInfo;
Expand All @@ -47,7 +47,6 @@
use Eccube\Repository\TaxRuleRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
Expand Down Expand Up @@ -356,13 +355,6 @@ public function index(Application $app, Request $request, $id)
*/
public function edit(Application $app, Request $request, $id)
{

/* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */
$softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete');
$softDeleteFilter->setExcludes(array(
'Eccube\Entity\TaxRule',
));

/** @var $Product \Eccube\Entity\Product */
$Product = $this->productRepository->find($id);

Expand Down Expand Up @@ -576,14 +568,9 @@ public function edit(Application $app, Request $request, $id)
$ProductClass->setVisible(false);
}

/* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */
$softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete');
$softDeleteFilter->setExcludes(array(
'Eccube\Entity\ProductClass'
));

// デフォルトの商品規格を表示
/** @var ProductClass $defaultProductClass */

$defaultProductClass = $this->productClassRepository
->findOneBy(array('Product' => $Product, 'ClassCategory1' => null, 'ClassCategory2' => null, 'visible' => false));
$defaultProductClass->setVisible(true);
Expand Down
5 changes: 0 additions & 5 deletions src/Eccube/Controller/Admin/Product/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,6 @@ public function copy(Application $app, Request $request, $id = null)

// 規格あり商品の場合は, デフォルトの商品規格を取得し登録する.
if ($CopyProduct->hasProductClass()) {
$softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete');
$softDeleteFilter->setExcludes(array(
'Eccube\Entity\ProductClass'
));
$dummyClass = $this->productClassRepository->findOneBy(array(
'visible' => false,
'ClassCategory1' => null,
Expand All @@ -730,7 +726,6 @@ public function copy(Application $app, Request $request, $id = null)
$dummyClass = clone $dummyClass;
$dummyClass->setProduct($CopyProduct);
$CopyProduct->addProductClass($dummyClass);
$softDeleteFilter->setExcludes(array());
}

$CopyProductClasses = $CopyProduct->getProductClasses();
Expand Down
16 changes: 1 addition & 15 deletions src/Eccube/Controller/Admin/Shipping/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,20 @@
use Eccube\Annotation\Component;
use Eccube\Annotation\Inject;
use Eccube\Application;
use Eccube\Common\Constant;
use Eccube\Controller\AbstractController;
use Eccube\Entity\Master\CsvType;
use Eccube\Entity\Master\ShippingStatus;
use Eccube\Entity\Shipping;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Form\Type\AddCartType;
use Eccube\Form\Type\Admin\SearchCustomerType;
use Eccube\Form\Type\Admin\SearchOrderType;
use Eccube\Form\Type\Admin\SearchProductType;
use Eccube\Form\Type\Admin\ShipmentItemType;
use Eccube\Form\Type\Admin\ShippingType;
use Eccube\Repository\CategoryRepository;
use Eccube\Repository\DeliveryRepository;
use Eccube\Repository\Master\ShippingStatusRepository;
use Eccube\Repository\ShipmentItemRepository;

use Eccube\Repository\ShippingRepository;
use Eccube\Service\TaxRuleService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
Expand All @@ -36,7 +29,7 @@
use Symfony\Component\Form\FormFactory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Serializer\Serializer;

/**
Expand Down Expand Up @@ -134,13 +127,6 @@ class EditController
*/
public function edit(Application $app, Request $request, $id = null)
{
/* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */
$softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete');
$softDeleteFilter->setExcludes(array(
'Eccube\Entity\ProductClass',
'Eccube\Entity\Product',
));

$TargetShipping = null;
$OriginShipping = null;

Expand Down
16 changes: 0 additions & 16 deletions src/Eccube/Controller/Mypage/MypageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,6 @@ public function index(Application $app, Request $request)
{
$Customer = $app['user'];

/* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */
$softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete');
$softDeleteFilter->setExcludes(
array(
'Eccube\Entity\ProductClass',
)
);

// 購入処理中/決済処理中ステータスの受注を非表示にする.
$this->entityManager
->getFilters()
Expand Down Expand Up @@ -202,14 +194,6 @@ public function index(Application $app, Request $request)
*/
public function history(Application $app, Request $request, $id)
{
/* @var $softDeleteFilter \Eccube\Doctrine\Filter\SoftDeleteFilter */
$softDeleteFilter = $this->entityManager->getFilters()->getFilter('soft_delete');
$softDeleteFilter->setExcludes(
array(
'Eccube\Entity\ProductClass',
)
);

$this->entityManager->getFilters()->enable('incomplete_order_status_hidden');
$Order = $this->orderRepository->findOneBy(
array(
Expand Down
54 changes: 0 additions & 54 deletions src/Eccube/Doctrine/Filter/SoftDeleteFilter.php

This file was deleted.

43 changes: 0 additions & 43 deletions tests/Eccube/Tests/Util/EntityUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ public function setUp()
{
parent::setUp();

$softDeleteFilter = $this->app['orm.em']->getFilters()->getFilter('soft_delete');
$softDeleteFilter->setExcludes(array(
'Eccube\Entity\ProductClass'
));
// soft_delete filter を有効にする
$config = $this->app['orm.em']->getConfiguration();
$config->addFilter("soft_delete", '\Eccube\Doctrine\Filter\SoftDeleteFilter');
$this->app['orm.em']->getFilters()->enable('soft_delete');

// eccube_install.sh で追加される Member
$Member = $this->app['eccube.repository.member']->find(1);

Expand Down Expand Up @@ -69,27 +60,6 @@ public function setUp()
$this->ProductClass = $ProductClass;
}

/**
* EntityUtil::isEmpty() のテストケース.
*
* soft_delete の対象となったオブジェクトを LAZY loading しようとすると
* Entity was not found エラーとなるため、 EntityUtil::isEmpty() で取得するテスト
*
* @see https://github.com/EC-CUBE/ec-cube/pull/602#issuecomment-125431246
*/
public function testIsEmpty()
{
// migration で追加されるサンプル商品
$Product = $this->app['eccube.repository.product']->find(1);
// migration で追加されるダミーの Member. del_flg = 1 の状態で INSERT されている
$Member = $Product->getCreator();
/*
* member.del_flg = 1 になっているので、soft_delete filter が適用され
* LAZY loading しようとすると Entity was not found のエラーとなる
*/
$this->assertTrue(EntityUtil::isEmpty($Member));
}

public function testIsEmptyWithFalse()
{
// setUp() で追加したサンプル商品
Expand All @@ -103,19 +73,6 @@ public function testIsEmptyWithFalse()
$this->assertFalse(EntityUtil::isEmpty($Member));
}

public function testIsNotEmpty()
{
// migration で追加されるサンプル商品
$Product = $this->app['eccube.repository.product']->find(1);
// migration で追加されるダミーの Member
$Member = $Product->getCreator();
/*
* member.del_flg = 1 になっているので、soft_delete filter が適用され
* LAZY loading しようとすると Entity was not found のエラーとなる
*/
$this->assertFalse(EntityUtil::isNotEmpty($Member));
}

public function testDumpToArray()
{
$arrProps = array(
Expand Down

0 comments on commit 1e387ca

Please sign in to comment.