1. Go to this page and download the library: Download zenify/doctrine-filters library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zenify / doctrine-filters example snippets
use Doctrine\ORM\Mapping\ClassMetadata;
use Zenify\DoctrineFilters\Contract\FilterInterface;
final class SoftdeletableFilter implements FilterInterface
{
public function addFilterConstraint(ClassMetadata $entity, string $alias) : string
{
if ($entity->getReflectionClass()->hasProperty('isDeleted')) {
return "$alias.isDeleted = 0");
}
return '';
}
}
use Nette\Security\User;
use Zenify\DoctrineFilters\Contract\ConditionalFilterInterface;
final class SoftdeletableFilter implements ConditionalFilterInterface
{
/**
* @var User
*/
private $user;
public function __construct(User $user)
{
$this->user = $user;
}
public function addFilterConstraint(ClassMetadata $entity, string $alias) : string
{
// same as above
}
public function isEnabled() : bool
{
if ($this->user->isLoggedIn() && $this->user->hasRole('admin')) {
return FALSE;
}
return TRUE;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.