Stash::_serialize_stash_tag_pairs PHP Метод

_serialize_stash_tag_pairs() приватный Метод

Retrieve {stash:var}{/stash:var} tag pairs and serialize
private _serialize_stash_tag_pairs ( ) : void
Результат void
    private function _serialize_stash_tag_pairs()
    {
        $match = $this->EE->TMPL->fetch_param('match', NULL);
        // regular expression to each list item against
        $against = $this->EE->TMPL->fetch_param('against', NULL);
        // array key to test $match against
        //  get the stash var pairs values
        $stash_vars = array();
        foreach ($this->EE->TMPL->var_pair as $key => $val) {
            // valid variable pair?
            if (strncmp($key, 'stash:', 6) == 0) {
                // but does the pair exist for this row of the list?
                $starts_at = strpos($this->EE->TMPL->tagdata, LD . $key . RD) + strlen(LD . $key . RD);
                $ends_at = strpos($this->EE->TMPL->tagdata, LD . "/" . $key . RD, $starts_at);
                if (FALSE !== $starts_at && FALSE !== $ends_at) {
                    // extract value between the pair
                    $tag_value = substr($this->EE->TMPL->tagdata, $starts_at, $ends_at - $starts_at);
                    // don't save a string containing just white space, but be careful to preserve zeros
                    if ($this->not_empty($tag_value) || $tag_value === '0') {
                        $stash_vars[substr($key, 6)] = $tag_value;
                    } else {
                        // default key value: use a placeholder to represent a null/empty value
                        $stash_vars[substr($key, 6)] = $this->_list_null;
                    }
                } else {
                    // no tag pair found in this row - use a placeholder to represent a null/empty value
                    $stash_vars[substr($key, 6)] = $this->_list_null;
                }
            }
        }
        // match/against: optionally match against the value of one of the list keys, rather than the whole serialized variable
        if (!is_null($match) && preg_match('/^#(.*)#$/', $match) && !is_null($against) && isset($stash_vars[$against])) {
            if (!$this->_matches($match, $stash_vars[$against])) {
                // match not found, end here
                $this->EE->TMPL->tagdata = '';
                return;
            }
            // disable match/against when setting the variable
            #unset($this->EE->TMPL->tagparams['match']);
            #unset($this->EE->TMPL->tagparams['against']);
        }
        // flatten the array into a string
        $this->EE->TMPL->tagdata = $this->_list_row_implode($stash_vars);
    }