{"id":317222,"date":"2021-01-30T21:00:26","date_gmt":"2021-01-30T21:00:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=317222"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=317222","title":{"rendered":"\u041f\u0430\u0440\u0430 \u0441\u043b\u043e\u0432 \u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u0445"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a! \u0423\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435 \u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Specification_pattern\" rel=\"nofollow noopener noreferrer\">&quot;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&quot;<\/a> \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 php \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u0434\u043a\u043e. \u0410 \u0432\u0435\u0434\u044c \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <a href=\"https:\/\/beberlei.de\/2013\/03\/04\/doctrine_repositories.html\" rel=\"nofollow noopener noreferrer\">\u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0437\u0440\u044b\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>, \u043d\u043e \u0438 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/334404\/\">\u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/a>. \u042f \u0436\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c. \u0421 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0418 \u043b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u043d\u0438\u044f \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h3 id=\"chto-budem-delat\">\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c task tracker. \u041d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">TaskController.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Controller;  use App\\Entity\\Task; use App\\Repository\\TaskRepository; use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController; use Symfony\\Component\\HttpFoundation\\Response; use Symfony\\Component\\Routing\\Annotation\\Route;  #[Route('\/task')] final class TaskController extends AbstractController {     #[Route('\/', name: 'task_index', methods: ['GET'])]     public function index(TaskRepository $taskRepository): Response     {         return $this-&gt;render('task\/index.html.twig', [             'tasks' =&gt; $taskRepository-&gt;findAll(),         ]);     }      #[Route('\/{id}', name: 'task_show', methods: ['GET'])]     public function show(Task $task): Response     {         return $this-&gt;render('task\/show.html.twig', [             'task' =&gt; $task,         ]);     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 3 \u0442\u0438\u043f\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439:<\/p>\n<p>  <\/p>\n<ul>\n<li>Admin \u2014 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438.<\/li>\n<li>Manager \u2014 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/li>\n<li>Developer \u2014 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0435\u043c\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u0440\u0430\u0432, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0438\u043f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u043c\u0435\u043b \u0434\u043e\u0441\u0442\u0443\u043f \u043b\u0438\u0448\u044c \u043a \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u043c \u0435\u043c\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">TaskController.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">namespace App\\Controller;   use App\\Entity\\Task; +use App\\Entity\\User;  use App\\Repository\\TaskRepository; +use App\\Security\\CurrentUserProvider; +use Doctrine\\ORM\\QueryBuilder;  use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;  use Symfony\\Component\\HttpFoundation\\Response; +use Symfony\\Component\\HttpKernel\\Exception\\AccessDeniedHttpException;  use Symfony\\Component\\Routing\\Annotation\\Route; +use Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface;   #[Route('\/task')]  final class TaskController extends AbstractController  { +    public function __construct(private AuthorizationCheckerInterface $authorizationChecker, private CurrentUserProvider $currentUserProvider) +    { +    } +      #[Route('\/', name: 'task_index', methods: ['GET'])]      public function index(TaskRepository $taskRepository): Response      { +        $queryBuilder = $taskRepository-&gt;createQueryBuilder('t'); +        $this-&gt;filter($queryBuilder); +          return $this-&gt;render('task\/index.html.twig', [ -            'tasks' =&gt; $taskRepository-&gt;findAll(), +            'tasks' =&gt; $queryBuilder-&gt;getQuery() +                -&gt;getResult(),          ]);      }  +    private function filter(QueryBuilder $queryBuilder): void +    { +        if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_ADMIN)) { +            return; +        } + +        $user = $this-&gt;currentUserProvider-&gt;getUser(); + +        if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_MANAGER)) { +            $queryBuilder-&gt;andWhere('t.project in(:projects)') +                -&gt;setParameter('projects', $user-&gt;getProjects()); + +            return; +        } + +        $queryBuilder-&gt;andWhere('t.performedBy = :performedBy') +            -&gt;setParameter('performedBy', $user); +    } +      #[Route('\/{id}', name: 'task_show', methods: ['GET'])]      public function show(Task $task): Response      { +        if (!$this-&gt;isViewable($task)) { +            throw new AccessDeniedHttpException(); +        } +          return $this-&gt;render('task\/show.html.twig', [              'task' =&gt; $task,          ]);      } + +    private function isViewable(Task $task): bool +    { +        if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_ADMIN)) { +            return true; +        } + +        $user = $this-&gt;currentUserProvider-&gt;getUser(); + +        if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_MANAGER)) { +            return $user-&gt;getProjects() +                -&gt;contains($task-&gt;getProject()); +        } + +        return $task-&gt;getPerformedBy() === $user; +    }  }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0440\u0430\u0441\u043a\u0438\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c, \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 symfony voters. \u041d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 filter, \u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 isViewable. \u0418 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u043e\u043b\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e. \u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u044d\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c? \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u043a\u0430\u043a \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d &quot;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&quot;.<\/p>\n<p>  <\/p>\n<h3 id=\"pishem-specifikaciyu\">\u041f\u0438\u0448\u0435\u043c \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e<\/h3>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043d\u0430\u0448\u0435\u043b 2 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u044f php. <a href=\"https:\/\/github.com\/Happyr\/Doctrine-Specification\" rel=\"nofollow noopener noreferrer\">Happyr\/Doctrine-Specification<\/a> \u0438 <a href=\"https:\/\/github.com\/K-Phoen\/rulerz\" rel=\"nofollow noopener noreferrer\">K-Phoen\/rulerz<\/a>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d \u0438 \u043d\u0430 symfony 5 \u0443\u0436\u0435 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0414\u0430 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435, \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c\u0441\u044f, \u043c\u043d\u0435 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435 \u0431\u0435\u0434\u0430, \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u042f \u043f\u043e\u0448\u0435\u043b \u043f\u043e \u043f\u0443\u0442\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0441\u043e\u043f\u0440\u043e\u0442\u0438\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0441\u0430\u043c\u0443 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e. \u042d\u0442\u043e, \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u0433\u0438\u0431\u043a\u043e \u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0441 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043e\u043a\u0442\u0440\u0438\u043d\u044b, \u043d\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u0441\u0447\u0435\u043b \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">Specification.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Specification;  use Doctrine\\ORM\\QueryBuilder; use Symfony\\Component\\PropertyAccess\\PropertyAccess;  abstract class Specification {     abstract public function isSatisfiedBy(object $entity): bool;      abstract public function generateDql(string $alias): ?string;      abstract public function getParameters(): array;      public function modifyQuery(QueryBuilder $queryBuilder): void     {     }      public function filter(QueryBuilder $queryBuilder): void     {         $this-&gt;modifyQuery($queryBuilder);         $alias = $queryBuilder-&gt;getRootAliases()[0];         $dql = $this-&gt;generateDql($alias);          if (null === $dql) {             return;         }          $queryBuilder-&gt;where($dql);          foreach ($this-&gt;getParameters() as $field =&gt; $value) {             $queryBuilder-&gt;setParameter($field, $value);         }     }      protected function getFieldValue(object $entity, string $field): mixed     {         return PropertyAccess::createPropertyAccessorBuilder()             -&gt;enableExceptionOnInvalidIndex()             -&gt;getPropertyAccessor()             -&gt;getValue($entity, $field);     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0432 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u041c\u0435\u0442\u043e\u0434 filter \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 query builder. \u041c\u0435\u0442\u043e\u0434 getFieldValue<br \/>  \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0430\u0432\u0438\u043b, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 CompositeSpecification.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">CompositeSpecification.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Specification;  use Doctrine\\ORM\\QueryBuilder;  abstract class CompositeSpecification extends Specification {     abstract public function getSpecification(): Specification;      public function isSatisfiedBy(object $entity): bool     {         return $this-&gt;getSpecification()             -&gt;isSatisfiedBy($entity);     }      public function generateDql(string $alias): ?string     {         return $this-&gt;getSpecification()             -&gt;generateDql($alias);     }      public function getParameters(): array     {         return $this-&gt;getSpecification()             -&gt;getParameters();     }      public function modifyQuery(QueryBuilder $queryBuilder): void     {         $this-&gt;getSpecification()             -&gt;modifyQuery($queryBuilder);     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0418 \u0435\u0449\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">AlwaysSpecified.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Specification;  final class AlwaysSpecified extends Specification {     public function isSatisfiedBy(object $entity): bool     {         return true;     }      public function generateDql(string $alias): ?string     {         return null;     }      public function getParameters(): array     {         return [];     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">Equals.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Specification;  final class Equals extends Specification {     public function __construct(private string $field, private mixed $value)     {     }      public function isSatisfiedBy(object $entity): bool     {         return $this-&gt;value === $this-&gt;getFieldValue($entity, $this-&gt;field);     }      public function generateDql(string $alias): ?string     {         return sprintf('%s.%s = :%2$s', $alias, $this-&gt;field);     }      public function getParameters(): array     {         return [             $this-&gt;field =&gt; $this-&gt;value,         ];     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">MemberOf.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Specification;  final class MemberOf extends Specification {     public function __construct(private string $field, private object $value)     {     }      public function isSatisfiedBy(object $entity): bool     {         return $this-&gt;getFieldValue($entity, $this-&gt;field)             -&gt;contains($this-&gt;value);     }      public function generateDql(string $alias): ?string     {         return sprintf(':%2$s member of %1$s.%2$s', $alias, $this-&gt;field);     }      public function getParameters(): array     {         return [             $this-&gt;field =&gt; $this-&gt;value,         ];     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">Not.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Specification;  final class Not extends Specification {     public function __construct(private Specification $specification)     {     }      public function isSatisfiedBy(object $entity): bool     {         return !$this-&gt;specification             -&gt;isSatisfiedBy($entity);     }      public function generateDql(string $alias): ?string     {         return sprintf(             'not (%s)',             $this-&gt;specification-&gt;generateDql($alias)         );     }      public function getParameters(): array     {         return $this-&gt;specification             -&gt;getParameters();     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0427\u0443\u0442\u044c \u0445\u0438\u0442\u0440\u0435\u0435 \u043e\u0431\u0441\u0442\u043e\u0438\u0442 \u0434\u0435\u043b\u043e \u0441 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">Join.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Specification;  use Doctrine\\ORM\\QueryBuilder;  final class Join extends Specification {     public function __construct(private string $rootAlias, private string $field, private Specification $specification)     {     }      public function isSatisfiedBy(object $entity): bool     {         return $this-&gt;specification             -&gt;isSatisfiedBy($this-&gt;getFieldValue($entity, $this-&gt;field));     }      public function generateDql(string $alias): ?string     {         return $this-&gt;specification             -&gt;generateDql($this-&gt;field);     }      public function getParameters(): array     {         return $this-&gt;specification             -&gt;getParameters();     }      public function modifyQuery(QueryBuilder $queryBuilder): void     {         $queryBuilder-&gt;join(sprintf('%s.%s', $this-&gt;rootAlias, $this-&gt;field), $this-&gt;field);         $this-&gt;specification             -&gt;modifyQuery($queryBuilder);     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h3 id=\"perehodim-na-biznes-pravila\">\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0430\u0432\u0438\u043b\u0430<\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043d\u0430\u0448\u0435 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">IsViewable.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">&lt;?php  declare(strict_types=1);  namespace App\\Specification\\Task;  use App\\Entity\\User; use App\\Security\\CurrentUserProvider; use App\\Specification\\AlwaysSpecified; use App\\Specification\\CompositeSpecification; use App\\Specification\\Equals; use App\\Specification\\Join; use App\\Specification\\MemberOf; use App\\Specification\\Specification; use Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface;  final class IsViewable extends CompositeSpecification {     public function __construct(private AuthorizationCheckerInterface $authorizationChecker, private CurrentUserProvider $currentUserProvider)     {     }      public function getSpecification(): Specification     {         if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_ADMIN)) {             return new AlwaysSpecified();         }          $user = $this-&gt;currentUserProvider-&gt;getUser();          if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_MANAGER)) {             $isProjectMember = new MemberOf('members', $user);              return new Join('task', 'project', $isProjectMember);         }          return new Equals('performedBy', $user);     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e\u0442 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u043a\u043e\u0434\u0430 \u043f\u043e\u0443\u0431\u0430\u0432\u0438\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">TaskController.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">namespace App\\Controller;   use App\\Entity\\Task; -use App\\Entity\\User;  use App\\Repository\\TaskRepository; -use App\\Security\\CurrentUserProvider; -use Doctrine\\ORM\\QueryBuilder; +use App\\Specification\\Task\\IsViewable;  use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;  use Symfony\\Component\\HttpFoundation\\Response;  use Symfony\\Component\\HttpKernel\\Exception\\AccessDeniedHttpException;  use Symfony\\Component\\Routing\\Annotation\\Route; -use Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface;   #[Route('\/task')]  final class TaskController extends AbstractController  { -    public function __construct(private AuthorizationCheckerInterface $authorizationChecker, private CurrentUserProvider $currentUserProvider) +    public function __construct(private IsViewable $isViewable)      {      }  @@ -26,7 +23,7 @@ final class TaskController extends AbstractController      public function index(TaskRepository $taskRepository): Response      {          $queryBuilder = $taskRepository-&gt;createQueryBuilder('t'); -        $this-&gt;filter($queryBuilder); +        $this-&gt;isViewable-&gt;filter($queryBuilder);           return $this-&gt;render('task\/index.html.twig', [              'tasks' =&gt; $queryBuilder-&gt;getQuery() @@ -34,29 +31,10 @@ final class TaskController extends AbstractController          ]);      }  -    private function filter(QueryBuilder $queryBuilder): void -    { -        if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_ADMIN)) { -            return; -        } - -        $user = $this-&gt;currentUserProvider-&gt;getUser(); - -        if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_MANAGER)) { -            $queryBuilder-&gt;andWhere('t.project in(:projects)') -                -&gt;setParameter('projects', $user-&gt;getProjects()); - -            return; -        } - -        $queryBuilder-&gt;andWhere('t.performedBy = :performedBy') -            -&gt;setParameter('performedBy', $user); -    } -      #[Route('\/{id}', name: 'task_show', methods: ['GET'])]      public function show(Task $task): Response      { -        if (!$this-&gt;isViewable($task)) { +        if (!$this-&gt;isViewable-&gt;isSatisfiedBy($task)) {              throw new AccessDeniedHttpException();          }  @@ -64,20 +42,4 @@ final class TaskController extends AbstractController              'task' =&gt; $task,          ]);      } - -    private function isViewable(Task $task): bool -    { -        if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_ADMIN)) { -            return true; -        } - -        $user = $this-&gt;currentUserProvider-&gt;getUser(); - -        if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_MANAGER)) { -            return $user-&gt;getProjects() -                -&gt;contains($task-&gt;getProject()); -        } - -        return $task-&gt;getPerformedBy() === $user; -    }  }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u041f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442. \u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f?<br \/>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0443 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447\u0438, \u0441\u0442\u0430\u0442\u0443\u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0440\u0430\u0432\u0435\u043d &quot;archived&quot;.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">IsViewable.php<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">use App\\Entity\\User;  use App\\Security\\CurrentUserProvider;  use App\\Specification\\AlwaysSpecified; +use App\\Specification\\AndX;  use App\\Specification\\CompositeSpecification;  use App\\Specification\\Equals;  use App\\Specification\\Join;  use App\\Specification\\MemberOf; +use App\\Specification\\Not; +use App\\Specification\\Project\\IsArchived;  use App\\Specification\\Specification;  use Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface;  @@ -26,14 +29,23 @@ final class IsViewable extends CompositeSpecification              return new AlwaysSpecified();          }  +         $isNotArchived = new Not(new IsArchived());           $user = $this-&gt;currentUserProvider-&gt;getUser();           if ($this-&gt;authorizationChecker-&gt;isGranted(User::ROLE_MANAGER)) {              $isProjectMember = new MemberOf('members', $user);  -            return new Join('task', 'project', $isProjectMember); +            return $this-&gt;getProjectSpecification(new AndX($isNotArchived, $isProjectMember));          }  -        return new Equals('performedBy', $user); +        return new AndX( +            new Equals('performedBy', $user), +            $this-&gt;getProjectSpecification($isNotArchived) +        ); +    } + +    private function getProjectSpecification(Specification $specification): Join +    { +        return new Join('task', 'project', $specification);      }  }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h3 id=\"vyvody\">\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>  <\/p>\n<p>\u0411\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u0432 \u043c\u043e\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0439\u043d\u0430 \u0438 \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0438\u0432\u043d\u0430. \u0411\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0441 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0435\u0439 \u0438\u043c\u0435\u043d, \u0434\u0430 \u0438 \u0441 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446 \u0432\u0441\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0438\u0436\u0443 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u0440\u0435\u0448\u0430\u0435\u043c\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0414\u0430 \u0438 \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u0443. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0438 \u0434\u0430\u043b\u044c\u0448\u0435. \u0412\u044b\u043d\u043e\u0441\u044f \u0438\u0445 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u044f \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e. \u041d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c \u2014 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0411\u0414, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0418 \u043b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u0433\u043e \u0436\u0435. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0443\u043f\u043e\u043c\u044f\u043d\u0435\u0442 \u043e \u043d\u0438\u0445 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435, \u0447\u0442\u043e \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u043e \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435? \u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d \u0442\u0430\u043a \u043c\u0430\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 php? \u0418 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u043e\u0436\u0438\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432?<\/p>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0430 <a href=\"https:\/\/github.com\/vshmakov\/specifications\" rel=\"nofollow noopener noreferrer\">github<\/a>.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/540082\/\"> https:\/\/habr.com\/ru\/post\/540082\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a! \u0423\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435 \u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Specification_pattern\" rel=\"nofollow noopener noreferrer\">&quot;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&quot;<\/a> \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 php \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u0434\u043a\u043e. \u0410 \u0432\u0435\u0434\u044c \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <a href=\"https:\/\/beberlei.de\/2013\/03\/04\/doctrine_repositories.html\" rel=\"nofollow noopener noreferrer\">\u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0437\u0440\u044b\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a>, \u043d\u043e \u0438 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/334404\/\">\u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/a>. \u042f \u0436\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c. \u0421 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0418 \u043b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u043d\u0438\u044f \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-317222","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=317222"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317222\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}