Redaxscript\Parser::init PHP Method

init() public method

init the class
Since: 2.4.0
public init ( string $content = null, array $optionArray = null )
$content string content to be parsed
$optionArray array options of the parser
    public function init($content = null, $optionArray = null)
    {
        $this->_output = $content;
        if (is_array($optionArray)) {
            $this->_optionArray = array_merge($this->_optionArray, $optionArray);
        }
        /* process tags */
        foreach ($this->_tagArray as $key => $value) {
            $this->_tagArray[$key]['position'] = strpos($this->_output, '<' . $key . '>');
            /* call related method */
            if ($this->_tagArray[$key]['position'] > -1) {
                $method = $value['method'];
                $this->_output = $this->{$method}($this->_output);
            }
        }
    }

Usage Example

Beispiel #1
0
 /**
  * testParser
  *
  * @since 2.1.0
  *
  * @param array $registry
  * @param string $input
  * @param string $route
  * @param string $expect
  *
  * @dataProvider providerParser
  */
 public function testParser($registry = array(), $input = null, $route = null, $expect = null)
 {
     /* setup */
     $this->_registry->init($registry);
     $parser = new Parser($this->_registry, $this->_language);
     $parser->init($input, $route, array('className' => array('break' => 'link-read-more', 'code' => 'box-code')));
     /* actual */
     $actual = $parser->getOutput();
     /* compare */
     $this->assertEquals($expect, $actual);
 }
All Usage Examples Of Redaxscript\Parser::init