* Replace date variables embedded in data source text, such as file paths. * * @param string $text * @return string */
(string $text)
| 136 | * @return string |
| 137 | */ |
| 138 | public function replaceDatasourceText(string $text): string { |
| 139 | return preg_replace_callback( |
| 140 | '/%[^%]+%(?:\([^)]*\))?/', |
| 141 | function (array $match): string { |
| 142 | $parsed = $this->parseFilter($match[0]); |
| 143 | if (!$parsed || is_array($parsed['value'])) { |
| 144 | return $match[0]; |
| 145 | } |
| 146 | |
| 147 | return date($this->parseFormat($match[0]), $parsed['value']); |
| 148 | }, |
| 149 | $text |
| 150 | ); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * replace variables in filters and apply format |