Completed
Pull Request — master (#3233)
by Christoph
14:23
created
lib/private/Contacts/ContactsMenu/ActionFactory.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,28 +30,28 @@
 block discarded – undo
30 30
 
31 31
 class ActionFactory implements IActionFactory {
32 32
 
33
-	/**
34
-	 * @param string $icon
35
-	 * @param string $name
36
-	 * @param string $href
37
-	 * @return ILinkAction
38
-	 */
39
-	public function newLinkAction($icon, $name, $href) {
40
-		$action = new LinkAction();
41
-		$action->setName($name);
42
-		$action->setIcon($icon);
43
-		$action->setHref($href);
44
-		return $action;
45
-	}
33
+    /**
34
+     * @param string $icon
35
+     * @param string $name
36
+     * @param string $href
37
+     * @return ILinkAction
38
+     */
39
+    public function newLinkAction($icon, $name, $href) {
40
+        $action = new LinkAction();
41
+        $action->setName($name);
42
+        $action->setIcon($icon);
43
+        $action->setHref($href);
44
+        return $action;
45
+    }
46 46
 
47
-	/**
48
-	 * @param string $icon
49
-	 * @param string $name
50
-	 * @param string $email
51
-	 * @return ILinkAction
52
-	 */
53
-	public function newEMailAction($icon, $name, $email) {
54
-		return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email));
55
-	}
47
+    /**
48
+     * @param string $icon
49
+     * @param string $name
50
+     * @param string $email
51
+     * @return ILinkAction
52
+     */
53
+    public function newEMailAction($icon, $name, $email) {
54
+        return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email));
55
+    }
56 56
 
57 57
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 	 * @return ILinkAction
52 52
 	 */
53 53
 	public function newEMailAction($icon, $name, $email) {
54
-		return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email));
54
+		return $this->newLinkAction($icon, $name, 'mailto:'.urlencode($email));
55 55
 	}
56 56
 
57 57
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/Actions/LinkAction.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -28,76 +28,76 @@
 block discarded – undo
28 28
 
29 29
 class LinkAction implements ILinkAction {
30 30
 
31
-	/** @var string */
32
-	private $icon;
33
-
34
-	/** @var string */
35
-	private $name;
36
-
37
-	/** @var string */
38
-	private $href;
39
-
40
-	/** @var int */
41
-	private $priority = 10;
42
-
43
-	/**
44
-	 * @param string $icon absolute URI to an icon
45
-	 */
46
-	public function setIcon($icon) {
47
-		$this->icon = $icon;
48
-	}
49
-
50
-	/**
51
-	 * @param string $name
52
-	 */
53
-	public function setName($name) {
54
-		$this->name = $name;
55
-	}
56
-
57
-	/**
58
-	 * @return string
59
-	 */
60
-	public function getName() {
61
-		return $this->name;
62
-	}
63
-
64
-	/**
65
-	 * @param int $priority
66
-	 */
67
-	public function setPriority($priority) {
68
-		$this->priority = $priority;
69
-	}
70
-
71
-	/**
72
-	 * @return int
73
-	 */
74
-	public function getPriority() {
75
-		return $this->priority;
76
-	}
77
-
78
-	/**
79
-	 * @param string $href
80
-	 */
81
-	public function setHref($href) {
82
-		$this->href = $href;
83
-	}
84
-
85
-	/**
86
-	 * @return string
87
-	 */
88
-	public function getHref() {
89
-		return $this->href;
90
-	}
91
-
92
-	/**
93
-	 * @return array
94
-	 */
95
-	public function jsonSerialize() {
96
-		return [
97
-			'title' => $this->name,
98
-			'icon' => $this->icon,
99
-			'hyperlink' => $this->href,
100
-		];
101
-	}
31
+    /** @var string */
32
+    private $icon;
33
+
34
+    /** @var string */
35
+    private $name;
36
+
37
+    /** @var string */
38
+    private $href;
39
+
40
+    /** @var int */
41
+    private $priority = 10;
42
+
43
+    /**
44
+     * @param string $icon absolute URI to an icon
45
+     */
46
+    public function setIcon($icon) {
47
+        $this->icon = $icon;
48
+    }
49
+
50
+    /**
51
+     * @param string $name
52
+     */
53
+    public function setName($name) {
54
+        $this->name = $name;
55
+    }
56
+
57
+    /**
58
+     * @return string
59
+     */
60
+    public function getName() {
61
+        return $this->name;
62
+    }
63
+
64
+    /**
65
+     * @param int $priority
66
+     */
67
+    public function setPriority($priority) {
68
+        $this->priority = $priority;
69
+    }
70
+
71
+    /**
72
+     * @return int
73
+     */
74
+    public function getPriority() {
75
+        return $this->priority;
76
+    }
77
+
78
+    /**
79
+     * @param string $href
80
+     */
81
+    public function setHref($href) {
82
+        $this->href = $href;
83
+    }
84
+
85
+    /**
86
+     * @return string
87
+     */
88
+    public function getHref() {
89
+        return $this->href;
90
+    }
91
+
92
+    /**
93
+     * @return array
94
+     */
95
+    public function jsonSerialize() {
96
+        return [
97
+            'title' => $this->name,
98
+            'icon' => $this->icon,
99
+            'hyperlink' => $this->href,
100
+        ];
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/IAction.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -33,33 +33,33 @@
 block discarded – undo
33 33
  */
34 34
 interface IAction extends JsonSerializable {
35 35
 
36
-	/**
37
-	 * @param string $icon absolute URI to an icon
38
-	 * @since 12.0
39
-	 */
40
-	public function setIcon($icon);
36
+    /**
37
+     * @param string $icon absolute URI to an icon
38
+     * @since 12.0
39
+     */
40
+    public function setIcon($icon);
41 41
 
42
-	/**
43
-	 * @return string localized action name, e.g. 'Call'
44
-	 * @since 12.0
45
-	 */
46
-	public function getName();
42
+    /**
43
+     * @return string localized action name, e.g. 'Call'
44
+     * @since 12.0
45
+     */
46
+    public function getName();
47 47
 
48
-	/**
49
-	 * @param string $name localized action name, e.g. 'Call'
50
-	 * @since 12.0
51
-	 */
52
-	public function setName($name);
48
+    /**
49
+     * @param string $name localized action name, e.g. 'Call'
50
+     * @since 12.0
51
+     */
52
+    public function setName($name);
53 53
 
54
-	/**
55
-	 * @param int $priority priorize actions, high order ones are shown on top
56
-	 * @since 12.0
57
-	 */
58
-	public function setPriority($priority);
54
+    /**
55
+     * @param int $priority priorize actions, high order ones are shown on top
56
+     * @since 12.0
57
+     */
58
+    public function setPriority($priority);
59 59
 
60
-	/**
61
-	 * @return int priority to priorize actions, high order ones are shown on top
62
-	 * @since 12.0
63
-	 */
64
-	public function getPriority();
60
+    /**
61
+     * @return int priority to priorize actions, high order ones are shown on top
62
+     * @since 12.0
63
+     */
64
+    public function getPriority();
65 65
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/IActionFactory.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@
 block discarded – undo
28 28
  */
29 29
 interface IActionFactory {
30 30
 
31
-	/**
32
-	 * Construct and return a new link action for the contacts menu
33
-	 *
34
-	 * @since 12.0
35
-	 *
36
-	 * @param string $icon full path to the action's icon
37
-	 * @param string $name localized name of the action
38
-	 * @param string $href target URL
39
-	 * @return ILinkAction
40
-	 */
41
-	public function newLinkAction($icon, $name, $href);
31
+    /**
32
+     * Construct and return a new link action for the contacts menu
33
+     *
34
+     * @since 12.0
35
+     *
36
+     * @param string $icon full path to the action's icon
37
+     * @param string $name localized name of the action
38
+     * @param string $href target URL
39
+     * @return ILinkAction
40
+     */
41
+    public function newLinkAction($icon, $name, $href);
42 42
 
43
-	/**
44
-	 * Construct and return a new email action for the contacts menu
45
-	 *
46
-	 * @since 12.0
47
-	 *
48
-	 * @param string $icon full path to the action's icon
49
-	 * @param string $name localized name of the action
50
-	 * @param string $email target e-mail address
51
-	 * @return ILinkAction
52
-	 */
53
-	public function newEMailAction($icon, $name, $email);
43
+    /**
44
+     * Construct and return a new email action for the contacts menu
45
+     *
46
+     * @since 12.0
47
+     *
48
+     * @param string $icon full path to the action's icon
49
+     * @param string $name localized name of the action
50
+     * @param string $email target e-mail address
51
+     * @return ILinkAction
52
+     */
53
+    public function newEMailAction($icon, $name, $email);
54 54
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/ILinkAction.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
  */
30 30
 interface ILinkAction extends IAction {
31 31
 
32
-	/**
33
-	 * @since 12.0
34
-	 * @param string $href the target URL of the action
35
-	 */
36
-	public function setHref($href);
32
+    /**
33
+     * @since 12.0
34
+     * @param string $href the target URL of the action
35
+     */
36
+    public function setHref($href);
37 37
 
38
-	/**
39
-	 * @since 12.0
40
-	 * @return string
41
-	 */
42
-	public function getHref();
38
+    /**
39
+     * @since 12.0
40
+     * @return string
41
+     */
42
+    public function getHref();
43 43
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/IProvider.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@
 block discarded – undo
29 29
  */
30 30
 interface IProvider {
31 31
 
32
-	/**
33
-	 * @since 12.0
34
-	 * @param IEntry $entry
35
-	 */
36
-	public function process(IEntry $entry);
32
+    /**
33
+     * @since 12.0
34
+     * @param IEntry $entry
35
+     */
36
+    public function process(IEntry $entry);
37 37
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/Manager.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -30,69 +30,69 @@
 block discarded – undo
30 30
 
31 31
 class Manager {
32 32
 
33
-	/** @var ContactsStore */
34
-	private $store;
33
+    /** @var ContactsStore */
34
+    private $store;
35 35
 
36
-	/** @var ActionProviderStore */
37
-	private $actionProviderStore;
36
+    /** @var ActionProviderStore */
37
+    private $actionProviderStore;
38 38
 
39
-	/** @var IAppManager */
40
-	private $appManager;
39
+    /** @var IAppManager */
40
+    private $appManager;
41 41
 
42
-	/** @var IURLGenerator */
43
-	private $urlGenerator;
42
+    /** @var IURLGenerator */
43
+    private $urlGenerator;
44 44
 
45
-	/**
46
-	 * @param ContactsStore $store
47
-	 * @param ActionProviderStore $actionProviderStore
48
-	 * @param IAppManager $appManager
49
-	 */
50
-	public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager) {
51
-		$this->store = $store;
52
-		$this->actionProviderStore = $actionProviderStore;
53
-		$this->appManager = $appManager;
54
-	}
45
+    /**
46
+     * @param ContactsStore $store
47
+     * @param ActionProviderStore $actionProviderStore
48
+     * @param IAppManager $appManager
49
+     */
50
+    public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager) {
51
+        $this->store = $store;
52
+        $this->actionProviderStore = $actionProviderStore;
53
+        $this->appManager = $appManager;
54
+    }
55 55
 
56
-	/**
57
-	 * @param string $userId
58
-	 * @param string $filter
59
-	 * @return array
60
-	 */
61
-	public function getEntries($userId, $filter) {
62
-		$entries = $this->store->getContacts($filter);
56
+    /**
57
+     * @param string $userId
58
+     * @param string $filter
59
+     * @return array
60
+     */
61
+    public function getEntries($userId, $filter) {
62
+        $entries = $this->store->getContacts($filter);
63 63
 
64
-		$sortedEntries = $this->sortEntries($entries);
65
-		$topEntries = array_slice($sortedEntries, 0, 25);
66
-		$this->processEntries($topEntries);
64
+        $sortedEntries = $this->sortEntries($entries);
65
+        $topEntries = array_slice($sortedEntries, 0, 25);
66
+        $this->processEntries($topEntries);
67 67
 
68
-		$contactsEnabled = $this->appManager->isEnabledForUser('contacts', $userId);
69
-		return [
70
-			'contacts' => $topEntries,
71
-			'contactsAppEnabled' => $contactsEnabled,
72
-		];
73
-	}
68
+        $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $userId);
69
+        return [
70
+            'contacts' => $topEntries,
71
+            'contactsAppEnabled' => $contactsEnabled,
72
+        ];
73
+    }
74 74
 
75
-	/**
76
-	 * @param IEntry[] $entries
77
-	 * @return IEntry[]
78
-	 */
79
-	private function sortEntries(array $entries) {
80
-		usort($entries, function(IEntry $entryA, IEntry $entryB) {
81
-			return strcasecmp($entryA->getFullName(), $entryB->getFullName());
82
-		});
83
-		return $entries;
84
-	}
75
+    /**
76
+     * @param IEntry[] $entries
77
+     * @return IEntry[]
78
+     */
79
+    private function sortEntries(array $entries) {
80
+        usort($entries, function(IEntry $entryA, IEntry $entryB) {
81
+            return strcasecmp($entryA->getFullName(), $entryB->getFullName());
82
+        });
83
+        return $entries;
84
+    }
85 85
 
86
-	/**
87
-	 * @param IEntry[] $entries
88
-	 */
89
-	private function processEntries(array $entries) {
90
-		$providers = $this->actionProviderStore->getProviders();
91
-		foreach ($entries as $entry) {
92
-			foreach ($providers as $provider) {
93
-				$provider->process($entry);
94
-			}
95
-		}
96
-	}
86
+    /**
87
+     * @param IEntry[] $entries
88
+     */
89
+    private function processEntries(array $entries) {
90
+        $providers = $this->actionProviderStore->getProviders();
91
+        foreach ($entries as $entry) {
92
+            foreach ($providers as $provider) {
93
+                $provider->process($entry);
94
+            }
95
+        }
96
+    }
97 97
 
98 98
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/ActionProviderStore.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -32,51 +32,51 @@
 block discarded – undo
32 32
 
33 33
 class ActionProviderStore {
34 34
 
35
-	/** @var IServerContainer */
36
-	private $serverContainer;
35
+    /** @var IServerContainer */
36
+    private $serverContainer;
37 37
 
38
-	/** @var ILogger */
39
-	private $logger;
38
+    /** @var ILogger */
39
+    private $logger;
40 40
 
41
-	/**
42
-	 * @param IServerContainer $serverContainer
43
-	 */
44
-	public function __construct(IServerContainer $serverContainer, ILogger $logger) {
45
-		$this->serverContainer = $serverContainer;
46
-		$this->logger = $logger;
47
-	}
41
+    /**
42
+     * @param IServerContainer $serverContainer
43
+     */
44
+    public function __construct(IServerContainer $serverContainer, ILogger $logger) {
45
+        $this->serverContainer = $serverContainer;
46
+        $this->logger = $logger;
47
+    }
48 48
 
49
-	/**
50
-	 * @return IProvider[]
51
-	 * @throws Exception
52
-	 */
53
-	public function getProviders() {
54
-		// TODO: include apps
55
-		$providerClasses = $this->getServerProviderClasses();
56
-		$providers = [];
49
+    /**
50
+     * @return IProvider[]
51
+     * @throws Exception
52
+     */
53
+    public function getProviders() {
54
+        // TODO: include apps
55
+        $providerClasses = $this->getServerProviderClasses();
56
+        $providers = [];
57 57
 
58
-		foreach ($providerClasses as $class) {
59
-			try {
60
-				$providers[] = $this->serverContainer->query($class);
61
-			} catch (QueryException $ex) {
62
-				$this->logger->logException($ex, [
63
-					'message' => "Could not load contacts menu action provider $class",
64
-					'app' => 'core',
65
-				]);
66
-				throw new \Exception("Could not load contacts menu action provider");
67
-			}
68
-		}
58
+        foreach ($providerClasses as $class) {
59
+            try {
60
+                $providers[] = $this->serverContainer->query($class);
61
+            } catch (QueryException $ex) {
62
+                $this->logger->logException($ex, [
63
+                    'message' => "Could not load contacts menu action provider $class",
64
+                    'app' => 'core',
65
+                ]);
66
+                throw new \Exception("Could not load contacts menu action provider");
67
+            }
68
+        }
69 69
 
70
-		return $providers;
71
-	}
70
+        return $providers;
71
+    }
72 72
 
73
-	/**
74
-	 * @return string[]
75
-	 */
76
-	private function getServerProviderClasses() {
77
-		return [
78
-			EMailProvider::class,
79
-		];
80
-	}
73
+    /**
74
+     * @return string[]
75
+     */
76
+    private function getServerProviderClasses() {
77
+        return [
78
+            EMailProvider::class,
79
+        ];
80
+    }
81 81
 
82 82
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/ContactsStore.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -29,61 +29,61 @@
 block discarded – undo
29 29
 
30 30
 class ContactsStore {
31 31
 
32
-	/** @var IManager */
33
-	private $contactsManager;
34
-
35
-	/**
36
-	 * @param IManager $contactsManager
37
-	 */
38
-	public function __construct(IManager $contactsManager) {
39
-		$this->contactsManager = $contactsManager;
40
-	}
41
-
42
-	/**
43
-	 * @param string|null $filter
44
-	 * @return IEntry[]
45
-	 */
46
-	public function getContacts($filter) {
47
-		$allContacts = $this->contactsManager->search($filter ?: '', [
48
-			'FN',
49
-		]);
50
-
51
-		return array_map(function(array $contact) {
52
-			return $this->contactArrayToEntry($contact);
53
-		}, $allContacts);
54
-	}
55
-
56
-	/**
57
-	 * @param array $contact
58
-	 * @return Entry
59
-	 */
60
-	private function contactArrayToEntry(array $contact) {
61
-		$entry = new Entry();
62
-
63
-		if (isset($contact['id'])) {
64
-			$entry->setId($contact['id']);
65
-		}
66
-
67
-		if (isset($contact['FN'])) {
68
-			$entry->setFullName($contact['FN']);
69
-		}
70
-
71
-		$avatarPrefix = "VALUE=uri:";
72
-		if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) {
73
-			$entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix)));
74
-		}
75
-
76
-		if (isset($contact['EMAIL'])) {
77
-			foreach ($contact['EMAIL'] as $email) {
78
-				$entry->addEMailAddress($email);
79
-			}
80
-		}
81
-
82
-		// Attach all other properties to the entry too because some
83
-		// providers might make use of it.
84
-		$entry->setProperties($contact);
85
-
86
-		return $entry;
87
-	}
32
+    /** @var IManager */
33
+    private $contactsManager;
34
+
35
+    /**
36
+     * @param IManager $contactsManager
37
+     */
38
+    public function __construct(IManager $contactsManager) {
39
+        $this->contactsManager = $contactsManager;
40
+    }
41
+
42
+    /**
43
+     * @param string|null $filter
44
+     * @return IEntry[]
45
+     */
46
+    public function getContacts($filter) {
47
+        $allContacts = $this->contactsManager->search($filter ?: '', [
48
+            'FN',
49
+        ]);
50
+
51
+        return array_map(function(array $contact) {
52
+            return $this->contactArrayToEntry($contact);
53
+        }, $allContacts);
54
+    }
55
+
56
+    /**
57
+     * @param array $contact
58
+     * @return Entry
59
+     */
60
+    private function contactArrayToEntry(array $contact) {
61
+        $entry = new Entry();
62
+
63
+        if (isset($contact['id'])) {
64
+            $entry->setId($contact['id']);
65
+        }
66
+
67
+        if (isset($contact['FN'])) {
68
+            $entry->setFullName($contact['FN']);
69
+        }
70
+
71
+        $avatarPrefix = "VALUE=uri:";
72
+        if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) {
73
+            $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix)));
74
+        }
75
+
76
+        if (isset($contact['EMAIL'])) {
77
+            foreach ($contact['EMAIL'] as $email) {
78
+                $entry->addEMailAddress($email);
79
+            }
80
+        }
81
+
82
+        // Attach all other properties to the entry too because some
83
+        // providers might make use of it.
84
+        $entry->setProperties($contact);
85
+
86
+        return $entry;
87
+    }
88 88
 
89 89
 }
Please login to merge, or discard this patch.