eZ\Publish\Core\Persistence\TransformationProcessor\PcreCompiler::compile PHP Method

compile() public method

The returned array contains a set of regular expressions and their replacement callbacks. The regular expressions can then be applied to strings to executed the transformations.
public compile ( array $ast ) : array
$ast array
return array
    public function compile(array $ast)
    {
        $transformations = array();
        foreach ($ast as $section => $rules) {
            foreach ($rules as $rule) {
                $transformations[$section][] = $this->compileRule($rule);
            }
        }
        return $transformations;
    }

Usage Example

 public function testCompileModuloTranspose()
 {
     $parser = new Persistence\TransformationProcessor\DefinitionBased\Parser(self::getInstallationDir());
     $compiler = new Persistence\TransformationProcessor\PcreCompiler(new Persistence\Utf8Converter());
     $rules = $compiler->compile($parser->parseString("transpose_modulo_test:\n" . "U+00e0 - U+00e6 % 02 - 01"));
     $this->assertSame('ßááããååçè', $this->applyTransformations($rules, 'àáâãäåæçè'));
 }