Sepultura가 주석 처리 한 링크는 필터를 활성화/비활성화하고 사용자 정의 필터를 작성하는 방법에 대한 몇 가지 예를 제공합니다.
From the docs
예 필터 :
<?php
namespace Example;
use Doctrine\ORM\Mapping\ClassMetaData,
Doctrine\ORM\Query\Filter\SQLFilter;
class MyLocaleFilter extends SQLFilter
{
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
// Check if the entity implements the LocalAware interface
if (!$targetEntity->getReflectionClass()->implementsInterface('LocaleAware')) {
return "";
}
return $targetTableAlias.'.locale = ' . $this->getParameter('locale'); // getParameter applies quoting automatically
}
}
워드 프로세서는이 필터를 추가하기 위해 다음 코드 줄을 사용하는 말을 (당신이 사용할 수 있도록/비활성화) :
$config->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter");
그러나이 필터를 어디에서나 사용하고 싶다면 원하는 곳에서이 코드를 삽입하고 $config
에 액세스해야합니다. Doctrine의 Configuration
개체가 있음).
'doctrine' => [
'configuration' => [
'orm_default' => [
'filters' => [
'locale' => MyLocaleFilter::class,
],
],
],
],
위의 코드 라인과 구성은 무효로,이 필터를 사용 :
젠드 프레임 워크 2에서
3 당신은 코어/MVC 모듈 또는 응용 프로그램 구성에 다음과 같은 구성을 추가 할 수 있습니다 //docs.doctrine- : 어쩌면 당신은 Doctring SQLFilter (HTTP를 사용하여 자신의 필터를 작성할 수 있습니다
<?php
$filter = $em->getFilters()->enable("locale");
$filter->setParameter('locale', 'en');
// Disable it
$filter = $em->getFilters()->disable("locale");
: 특정 위치는, (워드 프로세서 당 (첫 번째 &를 구성 할 수 있습니다)) 사용하지 않도록 설정할 다음 줄을 사용 project.org/projects/doctrine-orm/en/latest/refere nce/filters.html)? – Sepultura
해결할 수 있었습니까? – Nukeface
나는 @Nukeface를 생각하지 않는다. 생각하고있다. 어쨌든 이것이 소프트 삭제의 유효한 사용법이라고 생각하지 않는다. (사실 삭제와 똑같이 취급되어야한다. 이 속성을 처리하기위한 사용자 정의 속성 및 교리 필터 –