Я пытаюсь использовать softdelete
вариант gedmo/doctrine-extensions, но по какой-то причине, когда я называю romove()
, запись в базе данных получает удалена вместо обновления deletedAt
поля.Config запись для DoctrineExtensions SoftDeleteable: gedmo/Доктрина-расширений
В here, док говорит нам, чтобы обновить конфигурации с:
$ config-> AddFilter ('мягкой deleteable', 'Gedmo \ SoftDeleteable \ Filter \ SoftDeleteableFilter');
Это лишь один из примеров, которые я пробовал:
# app/config/config.yml
doctrine:
orm:
entity_managers:
default:
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
Список литературы (всего лишь несколько из них):
- DoctrineExtensions SoftDeleteable
- http://knplabs.com/en/blog/gedmo-doctrine-extensions-on-symfony2
- Can't enable SoftDeleteable in Symfony2 - Unrecognized options "filters"
Итак, вопрос простыми словами, как его настроить в config.yml?
КОНТРОЛЛЕР
public function delete($id)
{
$profile = $this->profileRepository->findOneBy(['id' => $id]);
if (!$profile instanceof Profile) {
throw new ........
}
$this->entityManager->remove($profile);
$this->entityManager->flush();
return true;
}
СУЩНОСТЬ
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity()
* @ORM\Table(name="profile")
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
*/
class Profile
{
/**
* @ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
private $deletedAt;
......
}
COMPOSER.JSON
"require": {
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"gedmo/doctrine-extensions": "2.3.*@dev",
......
},
config.yml
doctrine:
dbal:
default_connection: front
connections:
front:
driver: %database_driver%
host: %database_host%
........
back:
driver: %database_driver%
host: %database_host%
........
orm:
auto_generate_proxy_classes: %kernel.debug%
default_entity_manager: front
entity_managers:
front:
connection: front
mappings:
MyWebsiteBundle:
dir: Entity
FOSUserBundle: ~
back:
connection: back
КАРТ INFO:
[email protected]:/var/www/html/local$ php app/console doctrine:mapping:info
Found 8 mapped entities:
[OK] My\Bundle\Entity\AbstractMerchantProfile
[OK] My\Bundle\Entity\AbstractIntegration
[OK] My\Bundle\Entity\APIConsumer
[OK] My\Bundle\WebsiteBundle\Entity\User
[OK] My\Bundle\WebsiteBundle\Entity\Profile
[OK] My\Bundle\WebsiteBundle\Entity\Integration
[OK] FOS\UserBundle\Model\Group
[OK] FOS\UserBundle\Model\User