finalize() public method

Finishes template parsing.
public finalize ( )
コード例 #1
0
    public function finalize()
    {
        $compiler = $this->getCompiler();
        $properties = $compiler->getProperties();
        $blocks = isset($properties['blocks']) ? $properties['blocks'] : [];
        $blockTypes = isset($properties['blockTypes']) ? $properties['blockTypes'] : [];
        list($prolog) = parent::finalize();
        if (isset($compiler->getProperties()['blocks'])) {
            foreach ($compiler->getProperties()['blocks'] as $key => $val) {
                $blocks[$key] = $val;
            }
        }
        if (isset($compiler->getProperties()['blockTypes'])) {
            foreach ($compiler->getProperties()['blockTypes'] as $key => $val) {
                $blockTypes[$key] = $val;
            }
        }
        $compiler->addProperty('blocks', $blocks);
        $compiler->addProperty('blockTypes', $blockTypes);
        if (!$this->redefinedBlocks) {
            return [$prolog];
        }
        $compiler = $this->getCompiler();
        $compiler->addProperty('redefinedBlocks', $this->redefinedBlocks);
        return [$prolog . '
			$blocksToPrepend = [];
			foreach ($this->redefinedBlocks as $redefinedBlock) {
				foreach ($this->blockQueue[$redefinedBlock] as $i => $callback) {
					if ($callback[0] === $this) {
						$blocksToPrepend[] = [$redefinedBlock, $i];
					}
				}
			}
			foreach ($blocksToPrepend as $blockToPrepend) {
				$cb = $this->blockQueue[$blockToPrepend[0]][$blockToPrepend[1]];
				unset($this->blockQueue[$blockToPrepend[0]][$blockToPrepend[1]]);
				array_unshift($this->blockQueue[$blockToPrepend[0]], $cb);
			}
			'];
    }