Device-Cheat

service container symfony php main method

Apr 24th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2. // src/BlogBundle/Service/PostTest
  3. namespace BlogBundle\Service;
  4.  
  5. use BlogBundle\Entity\Post;
  6. use BlogBundle\Repository\PostRepository;
  7.  
  8. class PostTest
  9. {
  10.     /** @var PostRepository */
  11.     private $repository;
  12.     /** @var SubscriberNotifier */
  13.     private $notifier;
  14.  
  15.     function __construct(PostRepository $repository, SubscriberNotifier $notifier)
  16.     {
  17.         $this->repository = $repository;
  18.         $this->notifier = $notifier;
  19.     }
  20.  
  21.     public function create(Post $post)
  22.     {
  23.         $this->repository->persist($post);
  24.         $this->notifier->notifyCreate($post);
  25.     }
  26. }
  27.  
  28.  
  29.  
  30.  
  31. https://github.com/shfx17
Add Comment
Please, Sign In to add comment