← All changes
|
includes/frontend/dynamic-content/argument-parser.php
+4
-2
2.9.1
→
2.14.0
View file →
| @@ -9,12 +9,14 @@ | ||
| 9 | 9 | protected array $args; |
| 10 | 10 | protected array $interpreters; |
| 11 | 11 | protected string $arg_str; |
| 12 | 12 | protected bool $is_richtext; |
| 13 | - public function __construct( string $arg_str, bool $is_richtext, array $interpreters ) { | |
| 13 | + protected $context; | |
| 14 | + public function __construct( string $arg_str, bool $is_richtext, array $interpreters, array $context = [] ) { | |
| 14 | 15 | $this->arg_str = $arg_str; |
| 15 | 16 | $this->is_richtext = $is_richtext; |
| 16 | 17 | $this->interpreters = $interpreters; |
| 18 | + $this->context = $context; | |
| 17 | 19 | } |
| 18 | 20 | public function interpret() : ?Interpreters\Abstracts\Interpreter { |
| 19 | 21 | $setting = explode( '|', $this->arg_str ); |
| 20 | 22 | $action_name = $setting[0]; |
| @@ -21,9 +23,9 @@ | ||
| 21 | 23 | array_shift( $setting ); |
| 22 | 24 | |
| 23 | 25 | if ( ! empty( $class = $this->interpreters[ $action_name ] ?? '' ) && |
| 24 | 26 | class_exists( $class ) && |
| 25 | - ( $ins = new $class( $action_name, $setting, $this->is_richtext ) ) instanceof Interpreters\Abstracts\Interpreter | |
| 27 | + ( $ins = new $class( $action_name, $setting, $this->is_richtext, $this->context ) ) instanceof Interpreters\Abstracts\Interpreter | |
| 26 | 28 | ) { |
| 27 | 29 | return $ins; |
| 28 | 30 | } |
| 29 | 31 | return null; |