diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2017-04-03 18:23:30 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2017-04-03 18:23:30 +0300 |
commit | 7df5447c251330227649ae6609e48d8b0dabe68e (patch) | |
tree | 85633c83f70dc8891424058dfaa02bd67edae206 /lib/ContactsMenu | |
parent | 3fd93f23f5f51eb381b257cfe1578da4c04850d1 (diff) |
Register contactsmenu provider via info.xml
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/ContactsMenu')
-rw-r--r-- | lib/ContactsMenu/Providers/DetailsProvider.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/lib/ContactsMenu/Providers/DetailsProvider.php b/lib/ContactsMenu/Providers/DetailsProvider.php new file mode 100644 index 00000000..3a451564 --- /dev/null +++ b/lib/ContactsMenu/Providers/DetailsProvider.php @@ -0,0 +1,71 @@ +<?php + +/** + * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Contacts\ContactsMenu\Providers; + +use OCP\Contacts\ContactsMenu\IActionFactory; +use OCP\Contacts\ContactsMenu\IEntry; +use OCP\Contacts\ContactsMenu\IProvider; +use OCP\IURLGenerator; + +/** + * @todo move to contacts app + */ +class DetailsProvider implements IProvider { + + /** @var IURLGenerator */ + private $urlGenerator; + + /** @var IActionFactory */ + private $actionFactory; + + /** + * @param IURLGenerator $urlGenerator + * @param IActionFactory $actionFactory + */ + public function __construct(IURLGenerator $urlGenerator, IActionFactory $actionFactory) { + $this->actionFactory = $actionFactory; + $this->urlGenerator = $urlGenerator; + } + + /** + * @param IEntry $entry + */ + public function process(IEntry $entry) { + $uid = $entry->getProperty('UID'); + + if (is_null($uid)) { + // Nothing to do + return; + } + + // TODO: unique contact URL to the contacts app + // TODO: l10n + $contactsUrl = $this->urlGenerator->getAbsoluteURL('/index.php/apps/contacts'); + $action = $this->actionFactory->newLinkAction('icon-info', 'Details', $contactsUrl); + $action->setPriority(0); + $entry->addAction($action); + } + +} |