1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
locatorcodestemplate.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
8
9final class LocatorCodesTemplate implements Template
10{
11 public function __construct(
12 private readonly string $code,
13 private readonly string $module,
14 private readonly array $services,
15 private readonly bool $withTag = false,
16 )
17 {
18
19 }
20
21 public function getContent(): string
22 {
23 $names = $this->getNamesString();
24
25 $codes = $this->getCodesString();
26
27 $startTag = $this->withTag ? "<?php\n\nnamespace PHPSTORM_META\n{" : '';
28 $endTag = $this->withTag ?'}' : '';
29
30 $startRegion = $this->withTag ? "#region autogenerated services for module {$this->module}\n\n" : '';
31 $endRegion = $this->withTag ? "\n\n#endregion\n" : '';
32
33 return <<<PHP
34{$startTag}
35{$startRegion}
36 registerArgumentsSet(
37 '{$this->code}',
38 {$names}
39 );
40
41 expectedArguments(\Bitrix\Main\DI\ServiceLocator::get(), 0, argumentsSet('{$this->code}'));
42
43 override(
45 map([
46 {$codes}
47 ]),
48 );
49{$endRegion}
50{$endTag}
51PHP;
52 }
53
54 private function getNamesString(): string
55 {
56 $separator = $this->withTag ? "',\n\t\t\t'" : "',\n\t\t'";
57
58 return "\t'" . implode($separator, array_keys($this->services)) . "',";
59 }
60
61 private function getCodesString(): string
62 {
63 $map = $this->services;
64 array_walk($map, static function(string &$value, string $key): void {
65 $value = "'{$key}' => {$value},";
66 });
67 $map = array_values($map);
68
69 $separator = $this->withTag ? "\n\t\t\t\t" : "\n\t\t\t";
70
71 return "\t" . implode($separator, $map);
72 }
73}
get(string $id)
Определения servicelocator.php:126
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
$map
Определения config.php:5
$value
Определения Param.php:39
if(empty($signedUserToken)) $key
Определения quickway.php:257