PluginProbe ʕ •ᴥ•ʔ
Search Regex / trunk
Search Regex vtrunk
3.4.4 3.4.3 trunk 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 2.0 2.0.1 2.1 2.2 2.2.1 2.3 2.3.1 2.3.2 2.3.3 2.4 2.4.1 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1 3.1.1 3.1.2 3.2 3.3 3.3.0 3.3.1 3.4 3.4.1 3.4.2
search-regex / includes / action / type / class-global-replace.php
search-regex / includes / action / type Last commit date
class-delete.php 7 months ago class-export.php 1 month ago class-global-replace.php 7 months ago class-modify.php 7 months ago class-nothing.php 7 months ago class-run.php 1 month ago
class-global-replace.php
49 lines
1 <?php
2
3 namespace SearchRegex\Action\Type;
4
5 use SearchRegex\Schema;
6
7 /**
8 * Global replace. This emulates the previous searchregex
9 */
10 class Global_Replace extends Modify {
11 /**
12 * Constructor
13 *
14 * @param array<string, mixed>|string $options Options.
15 * @param Schema\Schema $schema Schema.
16 */
17 public function __construct( $options, Schema\Schema $schema ) {
18 /** @var array<int, array<string, mixed>> $converted */
19 $converted = [];
20
21 if ( is_array( $options ) ) {
22 foreach ( $schema->get_sources() as $source ) {
23 foreach ( $source->get_global_columns() as $column ) {
24 $converted[] = [
25 'column' => $column->get_column(),
26 'source' => $source->get_type(),
27 'operation' => 'replace',
28 'searchValue' => $options['search'],
29 'replaceValue' => $options['replacement'],
30 'searchFlags' => $options['flags'],
31 ];
32 }
33 }
34 }
35
36 parent::__construct( $converted, $schema );
37 }
38
39 /**
40 * @return array<string, mixed>
41 */
42 public function to_json() {
43 return [
44 'action' => 'replace',
45 'actionOption' => [],
46 ];
47 }
48 }
49