CraftCamp /
official-website
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Manager\Community; |
||||
| 4 | |||||
| 5 | use Doctrine\ORM\EntityManagerInterface; |
||||
| 6 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
||||
| 7 | |||||
| 8 | use App\Entity\Community\{ |
||||
| 9 | Community, |
||||
| 10 | Member |
||||
| 11 | }; |
||||
| 12 | use App\Entity\User\User; |
||||
| 13 | |||||
| 14 | use App\Event\Community\NewMemberEvent; |
||||
| 15 | |||||
| 16 | class MemberManager |
||||
| 17 | { |
||||
| 18 | /** @var EntityManagerInterface **/ |
||||
| 19 | protected $em; |
||||
| 20 | /** @var EventDispatcherInterface **/ |
||||
| 21 | protected $eventDispatcher; |
||||
| 22 | |||||
| 23 | |||||
| 24 | 9 | public function __construct(EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher) |
|||
| 25 | { |
||||
| 26 | 9 | $this->em = $em; |
|||
| 27 | 9 | $this->eventDispatcher = $eventDispatcher; |
|||
| 28 | 9 | } |
|||
| 29 | |||||
| 30 | 1 | public function getCommunityMembers(Community $community): array |
|||
| 31 | { |
||||
| 32 | 1 | return $this->em->getRepository(Member::class)->findByCommunity($community); |
|||
|
0 ignored issues
–
show
|
|||||
| 33 | } |
||||
| 34 | |||||
| 35 | 2 | public function getMemberCommunities(User $user): array |
|||
| 36 | { |
||||
| 37 | 2 | return $this->em->getRepository(Member::class)->findByUser($user); |
|||
|
0 ignored issues
–
show
The method
findByUser() does not exist on Doctrine\Common\Persistence\ObjectRepository. Did you maybe mean findBy()?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 38 | } |
||||
| 39 | |||||
| 40 | 3 | public function createMembership(Community $community, User $user, bool $isLead = false, bool $isNews = true): Member |
|||
| 41 | { |
||||
| 42 | $membership = |
||||
| 43 | 3 | (new Member()) |
|||
| 44 | 3 | ->setCommunity($community) |
|||
| 45 | 3 | ->setUser($user) |
|||
| 46 | 3 | ->setIsLead($isLead) |
|||
| 47 | ; |
||||
| 48 | 3 | $this->em->persist($membership); |
|||
| 49 | 3 | $this->em->flush($membership); |
|||
| 50 | 3 | if ($isNews === true) { |
|||
| 51 | 2 | $this->eventDispatcher->dispatch(NewMemberEvent::NAME, new NewMemberEvent($community, $user)); |
|||
| 52 | } |
||||
| 53 | 3 | return $membership; |
|||
| 54 | } |
||||
| 55 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.