‪TYPO3CMS  ‪main
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 
51  public function ‪setParserKey(string ‪$parserKey, array ‪$parameters): void
52  {
53  $this->parserKey = ‪$parserKey;
54  $this->parameters = ‪$parameters;
55  }
56 
57  public function ‪getParserKey(): string
58  {
59  return ‪$this->parserKey;
60  }
61 }
‪TYPO3\CMS\Core\DataHandling\SoftReference\SoftReferenceParserResult\create
‪static create(string $content, array $elements)
Definition: SoftReferenceParserResult.php:48
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\setParserKey
‪setParserKey(string $parserKey, array $parameters)
Definition: ExtensionPathSoftReferenceParser.php:51
‪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\Webhooks\Message\$uid
‪identifier readonly int $uid
Definition: PageModificationMessage.php:35
‪TYPO3\CMS\Core\DataHandling\SoftReference\ExtensionPathSoftReferenceParser\getParserKey
‪getParserKey()
Definition: ExtensionPathSoftReferenceParser.php:57