public function actionIndex() { Yii::$app->session->removeAll(); if (YII_ENV_DEV && YII_DEBUG) { $process = new PaymentProcess(['amount' => 200, 'orderId' => 'Order-' . uniqid(), 'currency' => 'CHF', 'successLink' => Url::toRoute(['/payment/test/test-success'], true), 'errorLink' => Url::toRoute(['/payment/test/test-error'], true), 'abortLink' => Url::toRoute(['/payment/test/test-abort'], true), 'transactionConfig' => []]); Yii::$app->session->set('storeTransactionId', $process->getId()); return $process->dispatch($this); } }
public function testBaseHelper() { $a = Url::toManager('urlmodule/bar/index'); $this->assertEquals($a, Url::to(['/urlmodule/bar/index'])); $this->assertEquals($a, Url::toRoute('/urlmodule/bar/index')); $b = Url::toManager('urlmodule/default/index'); $this->assertEquals($b, Url::to(['/urlmodule/default/index'])); $this->assertEquals($b, Url::toRoute('/urlmodule/default/index')); $c = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar']); $this->assertEquals($c, Url::to(['/news/default/detail', 'id' => 1, 'title' => 'foo-bar'])); $this->assertEquals($c, Url::toRoute(['/news/default/detail', 'id' => 1, 'title' => 'foo-bar'])); }
/** * Prepare a temp file to * @todo added very basic csv support, must be stored as class, just a temp solution * @return array */ public function actionExport() { $tempData = null; // first row $header = []; $i = 0; foreach ($this->model->find()->all() as $key => $value) { $row = []; $attrs = $value->getAttributes(); foreach ($value->extraFields() as $field) { $attrs[$field] = $value->{$field}; } foreach ($attrs as $k => $v) { if (is_object($v)) { if ($v instanceof Arrayable) { $v = $v->toArray(); } else { continue; } } if ($i === 0) { $header[] = $this->model->getAttributeLabel($k); } if (is_array($v)) { $tv = []; foreach ($v as $kk => $vv) { if (is_object($vv)) { if ($vv instanceof Arrayable) { $tv[] = implode(" | ", $vv->toArray()); } else { continue; } } elseif (is_array($vv)) { $tv[] = implode(" | ", $vv); } else { $tv[] = $vv; } } $v = implode(" - ", $tv); } $row[] = '"' . str_replace('"', '\\"', $v) . '"'; } if ($i === 0) { $tempData .= implode(",", $header) . "\n"; } $tempData .= implode(",", $row) . "\n"; $i++; } $key = uniqid('ngre', true); $store = FileHelper::writeFile('@runtime/' . $key . '.tmp', $tempData); if ($store) { Yii::$app->session->set('tempNgRestFileName', Inflector::slug($this->model->tableName())); Yii::$app->session->set('tempNgRestKey', $key); return ['url' => Url::toRoute(['/admin/ngrest/export-download', 'key' => base64_encode($key)])]; } throw new ErrorException("Unable to write the temporary file for the csv export. Make sure the runtime folder is writeable."); }
/** * Delivers the url for nice urls /file/id/hash/hello-world.jpg * * @return string */ public function getSourceStatic() { return Url::toRoute(['/admin/file/download', 'id' => $this->getId(), 'hash' => $this->getHashName(), 'fileName' => $this->getName()], true); }
public function testModuleContextOtherModuleAbsoluteUrls() { Yii::$app->request->baseUrl = ''; Yii::$app->request->scriptUrl = ''; Yii::$app->urlManager->contextNavItemId = 11; $this->assertEquals('http://localhost/en/admin/login', Url::toManager('admin/login/index', [], true)); $this->assertEquals('http://localhost/en/admin/login', Url::to(['/admin/login/index'], true)); $this->assertEquals('http://localhost/en/admin/login', Url::toRoute(['/admin/login/index'], true)); $this->assertEquals('http://localhost/en/admin/login', Url::toInternal(['/admin/login/index'], true)); Yii::$app->urlManager->contextNavItemId = 1; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar'], true); $this->assertEquals('http://localhost/1/foo-bar', $url); Yii::$app->urlManager->contextNavItemId = 2; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar'], true); $this->assertEquals('http://localhost/en/page-1/1/foo-bar', $url); Yii::$app->urlManager->contextNavItemId = 2; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar', 'pa' => 'ram'], true); $this->assertEquals('http://localhost/en/page-1/1/foo-bar?pa=ram', $url); Yii::$app->urlManager->contextNavItemId = 1; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'page-2-news-title', 'news' => 'page'], true); $this->assertEquals('http://localhost/1/page-2-news-title?news=page', $url); }
?> <span class="luya-cms-toolbar__badge luya-cms-toolbar__margin-left"> Modul: <strong><?php echo $menu->current->moduleName; ?> </strong> </span> <?php } ?> </div> </div> <div class="luya-cms-toolbar__button"> <a target="_blank" href="<?php echo Url::toRoute(['/admin/default/index', '#' => '/template/cmsadmin~2Fdefault~2Findex/update/' . $menu->current->navId], true); ?> "> <i alt="<?php echo Module::t('tb_edit_alt'); ?> " title="<?php echo Module::t('tb_edit_alt'); ?> " class="material-icons">mode_edit</i> </a> </div> <div class="luya-cms-toolbar__button"> <a class="luya-cms-toolbar__container-toggler" href="javascript:void(0);" onclick="toggleDetails(this, 'luya-cms-toolbar-seo-container')"> <?php