Skip to content

Instantly share code, notes, and snippets.

@dwaligora
Created April 10, 2013 15:52
Show Gist options
  • Save dwaligora/5355864 to your computer and use it in GitHub Desktop.
Save dwaligora/5355864 to your computer and use it in GitHub Desktop.
doctrine filter so ***** simple test with sf2.1
<?php
namespace Acme\Bundle\Doctrine\Filter;
use Doctrine\ORM\Mapping\ClassMetaData,
Doctrine\ORM\Query\Filter\SQLFilter,
Doctrine\ORM\EntityManager,
Doctrine\DBAL\Types\Type as DBALType;
/**
* Description of TestFilter
*
* @author danielwaligora
*/
class TestFilter extends SQLFilter
{
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
if($targetEntity->name === 'Acme\Bundle\Entity\Clip') {
return $targetTableAlias.'.duration > 1';
}
return ''; //this is MANDATORY!
}
}
?>
orm:
auto_generate_proxy_classes: %kernel.debug%
default_entity_manager: default
entity_managers:
default:
auto_mapping: true
filters:
test:
class: Acme\Bundle\Doctrine\Filter\TestFilter
enabled: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment