‪TYPO3CMS  10.4
TelephoneLinkHandler.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ServerRequestInterface;
23 
29 {
35  protected ‪$linkParts = [];
36 
42  protected ‪$updateSupported = false;
43 
47  public function ‪__construct()
48  {
49  parent::__construct();
50  // remove unsupported link attributes
51  foreach (['target', 'rel'] as $attribute) {
52  $position = array_search($attribute, $this->linkAttributes, true);
53  if ($position !== false) {
54  unset($this->linkAttributes[$position]);
55  }
56  }
57  }
58 
68  public function ‪canHandleLink(array ‪$linkParts): bool
69  {
70  if (isset(‪$linkParts['url']['telephone'])) {
71  $this->linkParts = ‪$linkParts;
72  return true;
73  }
74  return false;
75  }
76 
82  public function ‪formatCurrentUrl(): string
83  {
84  return $this->linkParts['url']['telephone'];
85  }
86 
94  public function ‪render(ServerRequestInterface $request): string
95  {
96  GeneralUtility::makeInstance(PageRenderer::class)->loadRequireJsModule('TYPO3/CMS/Recordlist/TelephoneLinkHandler');
97 
98  $this->view->assign('telephone', !empty($this->linkParts) ? $this->linkParts['url']['telephone'] : '');
99  return $this->view->render('Telephone');
100  }
101 
105  public function ‪getBodyTagAttributes(): array
106  {
107  return [];
108  }
109 }
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46