| Total Complexity | 4 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Coverage | 75% |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class NewsSubscriber implements EventSubscriberInterface |
||
| 17 | { |
||
| 18 | /** @var NewsManager **/ |
||
| 19 | protected $newsManager; |
||
| 20 | |||
| 21 | 1 | public function __construct(NewsManager $newsManager) |
|
| 22 | { |
||
| 23 | 1 | $this->newsManager = $newsManager; |
|
| 24 | 1 | } |
|
| 25 | |||
| 26 | 1 | public static function getSubscribedEvents(): array |
|
| 27 | { |
||
| 28 | return [ |
||
| 29 | 1 | CommunityCreationEvent::NAME => 'onCommunityCreation', |
|
| 30 | NewMemberEvent::NAME => 'onNewMember', |
||
| 31 | ]; |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | public function onCommunityCreation(CommunityCreationEvent $event) |
|
| 35 | { |
||
| 36 | 1 | $this->newsManager->create($event->getCommunity(), News::CATEGORY_COMMUNITY_CREATION, [ |
|
| 37 | 1 | '%username%' => $event->getFounder()->getUsername() |
|
| 38 | ]); |
||
| 39 | 1 | } |
|
| 40 | |||
| 41 | public function onNewMember(NewMemberEvent $event) |
||
| 45 | ]); |
||
| 46 | } |
||
| 47 | } |