EMailProvider.php 891 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\Contacts\ContactsMenu\Providers;
  7. use OCP\Contacts\ContactsMenu\IActionFactory;
  8. use OCP\Contacts\ContactsMenu\IEntry;
  9. use OCP\Contacts\ContactsMenu\IProvider;
  10. use OCP\IURLGenerator;
  11. class EMailProvider implements IProvider {
  12. public function __construct(
  13. private IActionFactory $actionFactory,
  14. private IURLGenerator $urlGenerator,
  15. ) {
  16. }
  17. public function process(IEntry $entry): void {
  18. $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
  19. foreach ($entry->getEMailAddresses() as $address) {
  20. if (empty($address)) {
  21. // Skip
  22. continue;
  23. }
  24. $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address, 'email');
  25. $entry->addAction($action);
  26. }
  27. }
  28. }