‪TYPO3CMS  11.5
ExtensionPathSoftReferenceParser.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 
24 {
25  private const ‪REGEXP = '/([^[:alnum:]]+)(EXT:[[:alnum:]_]+\\/[^[:space:]"\',]*)/';
26  protected string ‪$parserKey = '';
27  protected array ‪$parameters = [];
28 
29  public function ‪parse(string $table, string $field, int $uid, string $content, string $structurePath = ''): ‪SoftReferenceParserResult
30  {
31  $elements = [];
32  // Files starting with EXT:
33  $parts = preg_split(self::REGEXP, ' ' . $content . ' ', 10000, PREG_SPLIT_DELIM_CAPTURE) ?: [];
34  foreach ($parts as $idx => $value) {
35  if ($idx % 3 === 2) {
36  $elements[$idx] = [];
37  $elements[$idx]['matchString'] = $value;
38  }
39  }
40 
42  substr(implode('', $parts), 1, -1),
43  $elements
44  );
45  }
46 
50  public function ‪findRef(string $table, string $field, int $uid, string $content, string $spKey, array $spParams, string $structurePath = '')
51  {
52  return $this->‪parse($table, $field, $uid, $content, $structurePath)->toNullableArray();
53  }
54 
59  public function ‪setParserKey(string ‪$parserKey, array ‪$parameters): void
60  {
61  $this->parserKey = ‪$parserKey;
62  $this->parameters = ‪$parameters;
63  }
64 
65  public function ‪getParserKey(): string
66  {
67  return ‪$this->parserKey;
68  }
69 }
‪TYPO3\CMS\Core\DataHandling\SoftReference\SoftReferenceParserResult\create
‪static create(string $content, array $elements)
Definition: SoftReferenceParserResult.php:48
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\findRef
‪findRef(string $table, string $field, int $uid, string $content, string $spKey, array $spParams, string $structurePath='')
Definition: ExtensionPathSoftReferenceParser.php:50
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\setParserKey
‪setParserKey(string $parserKey, array $parameters)
Definition: ExtensionPathSoftReferenceParser.php:59
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\REGEXP
‪const REGEXP
Definition: ExtensionPathSoftReferenceParser.php:25
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\parse
‪parse(string $table, string $field, int $uid, string $content, string $structurePath='')
Definition: ExtensionPathSoftReferenceParser.php:29
‪TYPO3\CMS\Core\DataHandling\SoftReference\SoftReferenceParserInterface
Definition: SoftReferenceParserInterface.php:31
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\$parameters
‪array $parameters
Definition: ExtensionPathSoftReferenceParser.php:27
‪TYPO3\CMS\Core\DataHandling\SoftReference
Definition: AbstractSoftReferenceParser.php:18
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser
Definition: ExtensionPathSoftReferenceParser.php:24
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\$parserKey
‪string $parserKey
Definition: ExtensionPathSoftReferenceParser.php:26
‪TYPO3\CMS\Core\DataHandling\SoftReference\SoftReferenceParserResult
Definition: SoftReferenceParserResult.php:43
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\getParserKey
‪getParserKey()
Definition: ExtensionPathSoftReferenceParser.php:65