Skip to content

Commit

Permalink
Register contactsmenu provider via info.xml
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Apr 3, 2017
1 parent 3fd93f2 commit 7df5447
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
3 changes: 3 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
<nextcloud min-version="9" max-version="12" />
</dependencies>
<ocsid>168708</ocsid>
<contactsmenu>
<provider>OCA\Contacts\ContactsMenu\Providers\DetailsProvider</provider>
</contactsmenu>
</info>
71 changes: 71 additions & 0 deletions lib/ContactsMenu/Providers/DetailsProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* @copyright 2017 Christoph Wurst <[email protected]>
*
* @author 2017 Christoph Wurst <[email protected]>
*
* @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);
}

}

0 comments on commit 7df5447

Please sign in to comment.