lithium\net\http\Route::_write PHP Метод

_write() защищенный Метод

Writes a set of URL options to this route's template string.
protected _write ( array $options, array $defaults ) : string
$options array The options to write to this route, with defaults pre-merged.
$defaults array The default template options for this route (contains hard-coded default values).
Результат string Returns the route template string with option values inserted.
    protected function _write($options, $defaults)
    {
        $template = $this->_template;
        $trimmed = true;
        $options += array('args' => '');
        foreach (array_reverse($this->_keys, true) as $key) {
            $value =& $options[$key];
            $pattern = isset($this->_subPatterns[$key]) ? ":{$this->_subPatterns[$key]}" : '';
            $rpl = "{:{$key}{$pattern}}";
            $len = strlen($rpl) * -1;
            if ($trimmed && isset($defaults[$key]) && $value == $defaults[$key]) {
                if (substr($template, $len) == $rpl) {
                    $template = rtrim(substr($template, 0, $len), '/');
                    continue;
                }
            }
            if ($value === null) {
                $template = str_replace("/{$rpl}", '', $template);
                continue;
            }
            if ($key !== 'args') {
                $trimmed = false;
            }
            $template = str_replace($rpl, $value, $template);
        }
        return $template ?: '/';
    }