1<?php
2
3declare(strict_types=1);
4
5
6/**
7 * Circles - Bring cloud-users closer together.
8 *
9 * This file is licensed under the Affero General Public License version 3 or
10 * later. See the COPYING file.
11 *
12 * @author Maxence Lange <maxence@artificial-owl.com>
13 * @copyright 2017
14 * @license GNU AGPL version 3 or any later version
15 *
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as
18 * published by the Free Software Foundation, either version 3 of the
19 * License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 * GNU Affero General Public License for more details.
25 *
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28 *
29 */
30
31
32namespace OCA\Circles\GlobalScale;
33
34use OCA\Circles\Exceptions\MemberAlreadyExistsException;
35use OCA\Circles\Model\GlobalScale\GSEvent;
36
37/**
38 * Class CircleCreate
39 *
40 * @package OCA\Circles\GlobalScale
41 */
42class CircleCreate extends AGlobalScaleEvent {
43
44
45	/**
46	 * Circles are created on the original instance, so do no check;
47	 *
48	 * @param GSEvent $event
49	 * @param bool $localCheck
50	 * @param bool $mustBeChecked
51	 */
52	public function verify(GSEvent $event, bool $localCheck = false, bool $mustBeChecked = false): void {
53		//parent::verify($event, $localCheck, $mustBeChecked);
54	}
55
56
57	/**
58	 * @param GSEvent $event
59	 *
60	 * @throws MemberAlreadyExistsException
61	 */
62	public function manage(GSEvent $event): void {
63		if (!$event->hasCircle()) {
64			return;
65		}
66
67		$circle = $event->getDeprecatedCircle();
68		$this->circlesRequest->createCircle($circle);
69
70		$owner = $circle->getOwner();
71		if ($owner->getInstance() === '') {
72			$owner->setInstance($event->getSource());
73		}
74		$this->membersRequest->createMember($owner);
75
76		$this->eventsService->onCircleCreation($circle);
77	}
78
79
80	/**
81	 * @param GSEvent[] $events
82	 */
83	public function result(array $events): void {
84	}
85}
86