-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better comparison for users on admin list batch action
- Loading branch information
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* (c) FSi sp. z o.o. <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FSi\Bundle\AdminSecurityBundle\Twig; | ||
|
||
use Symfony\Component\Security\Core\User\UserInterface; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFunction; | ||
|
||
final class SecurityExtension extends AbstractExtension | ||
{ | ||
/** | ||
* @return array<TwigFunction> | ||
*/ | ||
public function getFunctions(): array | ||
{ | ||
return [ | ||
new TwigFunction( | ||
'are_same_users', | ||
static function (UserInterface $a, UserInterface $b): bool { | ||
if (false === $a instanceof $b && false === $b instanceof $a) { | ||
return false; | ||
} | ||
|
||
return $a->getUsername() === $b->getUsername(); | ||
} | ||
) | ||
]; | ||
} | ||
} |