current() public static method

You may modify or remove some of the GET parameters, or add additional query parameters through the $params parameter. In particular, if you specify a parameter to be null, then this parameter will be removed from the existing GET parameters; all other parameters specified in $params will be merged with the existing GET parameters. For example, php assume $_GET = ['id' => 123, 'src' => 'google'], current route is "post/view" /index.php?r=post%2Fview&id=123&src=google echo Url::current(); /index.php?r=post%2Fview&id=123 echo Url::current(['src' => null]); /index.php?r=post%2Fview&id=100&src=google echo Url::current(['id' => 100]); Note that if you're replacing array parameters with [] at the end you should specify $params as nested arrays. For a PostSearchForm model where parameter names are PostSearchForm[id] and PostSearchForm[src] the syntax would be the following: php index.php?r=post%2Findex&PostSearchForm%5Bid%5D=100&PostSearchForm%5Bsrc%5D=google echo Url::current([ $postSearch->formName() => ['id' => 100, 'src' => 'google'], ]);
Since: 2.0.3
public static current ( array $params = [], boolean | string $scheme = false ) : string
$params array an associative array of parameters that will be merged with the current GET parameters. If a parameter value is null, the corresponding GET parameter will be removed.
$scheme boolean | string the URI scheme to use in the generated URL: - `false` (default): generating a relative URL. - `true`: returning an absolute base URL whose scheme is the same as that in [[\yii\web\UrlManager::$hostInfo]]. - string: generating an absolute URL with the specified scheme (either `http`, `https` or empty string for protocol-relative URL).
return string the generated URL
コード例 #1
0
 protected function renderMenu()
 {
     $html = [];
     $html[] = '<div class="list-group">';
     foreach ($this->items as $item) {
         if (BaseUrl::current() == $item['url']) {
             $html[] = $this->renderActiveItem($item);
         } else {
             $html[] = $this->renderItem($item);
         }
     }
     $html[] = '</div>';
     return implode($html);
 }
コード例 #2
0
ファイル: visualizar.php プロジェクト: brunofunny/agob
}
?>

            <div class="form-group">
                <label>Status</label>
                <p><span class="event <?php 
echo Yii::$app->AgobUtils->cssStatus($model->status, $model->d_ter);
?>
"></span><?php 
echo Yii::$app->params['status'][$model->status];
?>
</p>
            </div>

            <form action="<?php 
echo \yii\helpers\BaseUrl::current();
?>
" method="POST">
                <?php 
if (Yii::$app->user->can('Administrador')) {
    ?>
                    <div class="form-group">
                        <label>Observação</label>
                        <textarea name="Eventos[status_observacao]" class="form-control" rows="5"><?php 
    echo $model->status_observacao;
    ?>
</textarea>
                    </div>
                    <?php 
    if (Yii::$app->user->can('Administrador')) {
        ?>
コード例 #3
0
ファイル: paginate.php プロジェクト: romasar86/yiilearning
    echo BaseUrl::to(['contacts/edit', 'id' => $contact['idContact']]);
    ?>
">
                    <button class="view">view</button>
                </a>
                <a class="editLink" href="<?php 
    echo BaseUrl::to(['contacts/edit', 'id' => $contact['idContact']]);
    ?>
">
                    <button class="edit">edit</button>
                </a>
            </td>
            <td class="lastCol" >
                <?php 
    $href = BaseUrl::to(['contacts/delete', 'id' => $contact['idContact']]);
    $hrefPage = BaseUrl::current(['page' => $page, 'orderBy' => $orderBy, 'dir' => $dirOpposite, 'sortChange' => $sortChange]);
    $onclickDelete = "name='" . $contact['lastName'] . ' ' . $contact['firstName'] . "' " . "href='" . $href . "'" . "hrefPage='" . $hrefPage . "'" . "row='" . $i . "'";
    ?>
                <button class="delete" <?php 
    echo $onclickDelete;
    ?>
>X</button>
            </td>
        </tr>
        <?php 
    $num++;
}
?>
    <tr class="lastRow">
        <td class="bottomLeft number"></td>
        <td class="lastName"></td>