-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register contactsmenu provider via info.xml
Signed-off-by: Christoph Wurst <[email protected]>
- Loading branch information
1 parent
3fd93f2
commit 7df5447
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |