本文整理汇总了PHP中Router::fullBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::fullBaseUrl方法的具体用法?PHP Router::fullBaseUrl怎么用?PHP Router::fullBaseUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::fullBaseUrl方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBaseUrl
/**
* Tests that the base URL can be changed at runtime.
*
* @return void
*/
public function testBaseUrl()
{
$this->assertEquals(FULL_BASE_URL, Router::fullBaseUrl());
Router::fullBaseUrl('http://example.com');
$this->assertEquals('http://example.com/', Router::url('/', true));
$this->assertEquals('http://example.com', Configure::read('App.fullBaseUrl'));
Router::fullBaseUrl('https://example.com');
$this->assertEquals('https://example.com/', Router::url('/', true));
$this->assertEquals('https://example.com', Configure::read('App.fullBaseUrl'));
}
示例2: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
App::uses('Paypal', 'Paypal.Lib');
$this->Paypal = new Paypal(array('sandboxMode' => $this->getConfig['paypal_sandbox'], 'nvpUsername' => $this->getConfig['paypal_userName'], 'nvpPassword' => $this->getConfig['paypal_pass'], 'nvpSignature' => $this->getConfig['paypal_sign'], 'ipnReturnUrl' => Router::fullBaseUrl() . '/paypal_ipn/process'));
if (!$this->getConfig['shop']) {
$this->Session->setFlash(__('No tienes permiso para acceder a este apartado!'), 'flashMessages/error');
$this->redirect(array('controller' => 'articles', 'action' => 'viewList'));
}
}
示例3: testAssetUrl
/**
* test assetUrl application
*
* @return void
*/
public function testAssetUrl()
{
$this->Helper->webroot = '';
$result = $this->Helper->assetUrl(array('controller' => 'js', 'action' => 'post', 'ext' => 'js'), array('fullBase' => true));
$this->assertEquals(Router::fullBaseUrl() . '/js/post.js', $result);
$result = $this->Helper->assetUrl('foo.jpg', array('pathPrefix' => 'img/'));
$this->assertEquals('img/foo.jpg', $result);
$result = $this->Helper->assetUrl('foo.jpg', array('fullBase' => true));
$this->assertEquals(Router::fullBaseUrl() . '/foo.jpg', $result);
$result = $this->Helper->assetUrl('style', array('ext' => '.css'));
$this->assertEquals('style.css', $result);
$result = $this->Helper->assetUrl('dir/sub dir/my image', array('ext' => '.jpg'));
$this->assertEquals('dir/sub%20dir/my%20image.jpg', $result);
$result = $this->Helper->assetUrl('foo.jpg?one=two&three=four');
$this->assertEquals('foo.jpg?one=two&three=four', $result);
$result = $this->Helper->assetUrl('dir/big+tall/image', array('ext' => '.jpg'));
$this->assertEquals('dir/big%2Btall/image.jpg', $result);
}
示例4: requestAction
/**
* Calls a controller's method from any location. Can be used to connect controllers together
* or tie plugins into a main application. requestAction can be used to return rendered views
* or fetch the return value from controller actions.
*
* Under the hood this method uses Router::reverse() to convert the $url parameter into a string
* URL. You should use URL formats that are compatible with Router::reverse()
*
* #### Passing POST and GET data
*
* POST and GET data can be simulated in requestAction. Use `$extra['url']` for
* GET data. The `$extra['data']` parameter allows POST data simulation.
*
* @param string|array $url String or array-based URL. Unlike other URL arrays in CakePHP, this
* URL will not automatically handle passed and named arguments in the $url parameter.
* @param array $extra if array includes the key "return" it sets the AutoRender to true. Can
* also be used to submit GET/POST data, and named/passed arguments.
* @return mixed Boolean true or false on success/failure, or contents
* of rendered action if 'return' is set in $extra.
*/
public function requestAction($url, $extra = array())
{
if (empty($url)) {
return false;
}
if (($index = array_search('return', $extra)) !== false) {
$extra['return'] = 0;
$extra['autoRender'] = 1;
unset($extra[$index]);
}
$arrayUrl = is_array($url);
if ($arrayUrl && !isset($extra['url'])) {
$extra['url'] = array();
}
if ($arrayUrl && !isset($extra['data'])) {
$extra['data'] = array();
}
$extra += array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1);
$data = isset($extra['data']) ? $extra['data'] : null;
unset($extra['data']);
if (is_string($url) && strpos($url, Router::fullBaseUrl()) === 0) {
$url = Router::normalize(str_replace(Router::fullBaseUrl(), '', $url));
}
if (is_string($url)) {
$request = new CakeRequest($url);
} elseif (is_array($url)) {
$params = $url + array('pass' => array(), 'named' => array(), 'base' => false);
$params = $extra + $params;
$request = new CakeRequest(Router::reverse($params));
}
if (isset($data)) {
$request->data = $data;
}
$dispatcher = new Dispatcher();
$result = $dispatcher->dispatch($request, new CakeResponse(), $extra);
Router::popRequest();
return $result;
}
示例5: assetUrl
/**
* Generate URL for given asset file. Depending on options passed provides full URL with domain name.
* Also calls Helper::assetTimestamp() to add timestamp to local files
*
* @param string|array $path Path string or URL array
* @param array $options Options array. Possible keys:
* `fullBase` Return full URL with domain name
* `pathPrefix` Path prefix for relative URLs
* `ext` Asset extension to append
* `plugin` False value will prevent parsing path as a plugin
* @return string Generated URL
*/
public function assetUrl($path, $options = array())
{
if (is_array($path)) {
return $this->url($path, !empty($options['fullBase']));
}
if (strpos($path, '://') !== false) {
return $path;
}
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
list($plugin, $path) = $this->_View->pluginSplit($path, false);
}
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
$path = $options['pathPrefix'] . $path;
}
if (!empty($options['ext']) && strpos($path, '?') === false && substr($path, -strlen($options['ext'])) !== $options['ext']) {
$path .= $options['ext'];
}
if (preg_match('|^([a-z0-9]+:)?//|', $path)) {
return $path;
}
if (isset($plugin)) {
$path = Inflector::underscore($plugin) . '/' . $path;
}
$path = $this->_encodeUrl($this->assetTimestamp($this->webroot($path)));
if (!empty($options['fullBase'])) {
$path = rtrim(Router::fullBaseUrl(), '/') . '/' . ltrim($path, '/');
}
return $path;
}
示例6: testBaseUrlWithBasePath
/**
* Test that Router uses App.base to build URL's when there are no stored
* request objects.
*
* @return void
*/
public function testBaseUrlWithBasePath()
{
Configure::write('App.base', '/cakephp');
Router::fullBaseUrl('http://example.com');
$this->assertEquals('http://example.com/cakephp/tasks', Router::url('/tasks', true));
}
示例7: testLink
/**
* testLink method
*
* @return void
*/
public function testLink()
{
Router::connect('/:controller/:action/*');
$this->Html->request->webroot = '';
$result = $this->Html->link('/home');
$expected = array('a' => array('href' => '/home'), 'preg:/\\/home/', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link(array('action' => 'login', '<[You]>'));
$expected = array('a' => array('href' => '/login/%3C%5BYou%5D%3E'), 'preg:/\\/login\\/<\\[You\\]>/', '/a');
$this->assertTags($result, $expected);
Router::reload();
$result = $this->Html->link('Posts', array('controller' => 'posts', 'action' => 'index', 'full_base' => true));
$expected = array('a' => array('href' => Router::fullBaseUrl() . '/posts'), 'Posts', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Home', '/home', array('confirm' => 'Are you sure you want to do this?'));
$expected = array('a' => array('href' => '/home', 'onclick' => 'if (confirm("Are you sure you want to do this?")) { return true; } return false;'), 'Home', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Home', '/home', array('escape' => false, 'confirm' => 'Confirm\'s "nightmares"'));
$expected = array('a' => array('href' => '/home', 'onclick' => 'if (confirm("Confirm's \\"nightmares\\"")) { return true; } return false;'), 'Home', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Home', '/home', array('default' => false));
$expected = array('a' => array('href' => '/home', 'onclick' => 'event.returnValue = false; return false;'), 'Home', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Home', '/home', array('default' => false, 'onclick' => 'someFunction();'));
$expected = array('a' => array('href' => '/home', 'onclick' => 'someFunction(); event.returnValue = false; return false;'), 'Home', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#');
$expected = array('a' => array('href' => '#'), 'Next >', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('escape' => true));
$expected = array('a' => array('href' => '#'), 'Next >', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('escape' => 'utf-8'));
$expected = array('a' => array('href' => '#'), 'Next >', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('escape' => false));
$expected = array('a' => array('href' => '#'), 'Next >', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('title' => 'to escape … or not escape?', 'escape' => false));
$expected = array('a' => array('href' => '#', 'title' => 'to escape … or not escape?'), 'Next >', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('title' => 'to escape … or not escape?', 'escape' => true));
$expected = array('a' => array('href' => '#', 'title' => 'to escape &#8230; or not escape?'), 'Next >', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('title' => 'Next >', 'escapeTitle' => false));
$expected = array('a' => array('href' => '#', 'title' => 'Next >'), 'Next >', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Original size', array('controller' => 'images', 'action' => 'view', 3, '?' => array('height' => 100, 'width' => 200)));
$expected = array('a' => array('href' => '/images/view/3?height=100&width=200'), 'Original size', '/a');
$this->assertTags($result, $expected);
Configure::write('Asset.timestamp', false);
$result = $this->Html->link($this->Html->image('test.gif'), '#', array('escape' => false));
$expected = array('a' => array('href' => '#'), 'img' => array('src' => 'img/test.gif', 'alt' => ''), '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link($this->Html->image('test.gif'), '#', array('title' => 'hey "howdy"', 'escapeTitle' => false));
$expected = array('a' => array('href' => '#', 'title' => 'hey "howdy"'), 'img' => array('src' => 'img/test.gif', 'alt' => ''), '/a');
$this->assertTags($result, $expected);
$result = $this->Html->image('test.gif', array('url' => '#'));
$expected = array('a' => array('href' => '#'), 'img' => array('src' => 'img/test.gif', 'alt' => ''), '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link($this->Html->image('../favicon.ico'), '#', array('escape' => false));
$expected = array('a' => array('href' => '#'), 'img' => array('src' => 'img/../favicon.ico', 'alt' => ''), '/a');
$this->assertTags($result, $expected);
$result = $this->Html->image('../favicon.ico', array('url' => '#'));
$expected = array('a' => array('href' => '#'), 'img' => array('src' => 'img/../favicon.ico', 'alt' => ''), '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('http://www.example.org?param1=value1¶m2=value2');
$expected = array('a' => array('href' => 'http://www.example.org?param1=value1&param2=value2'), 'http://www.example.org?param1=value1&param2=value2', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('alert', 'javascript:alert(\'cakephp\');');
$expected = array('a' => array('href' => 'javascript:alert('cakephp');'), 'alert', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('write me', 'mailto:example@cakephp.org');
$expected = array('a' => array('href' => 'mailto:example@cakephp.org'), 'write me', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('call me on 0123465-798', 'tel:0123465-798');
$expected = array('a' => array('href' => 'tel:0123465-798'), 'call me on 0123465-798', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('text me on 0123465-798', 'sms:0123465-798');
$expected = array('a' => array('href' => 'sms:0123465-798'), 'text me on 0123465-798', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('say hello to 0123465-798', 'sms:0123465-798?body=hello there');
$expected = array('a' => array('href' => 'sms:0123465-798?body=hello there'), 'say hello to 0123465-798', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('say hello to 0123465-798', 'sms:0123465-798?body=hello "cakephp"');
$expected = array('a' => array('href' => 'sms:0123465-798?body=hello "cakephp"'), 'say hello to 0123465-798', '/a');
$this->assertTags($result, $expected);
}
示例8: setPaymentOptions
private function setPaymentOptions($goTo = null)
{
$opt = array('description' => 'Compra en la tienda Foxy Freire', 'currency' => 'EUR', 'return' => Router::fullBaseUrl() . '/shop/doPayment', 'cancel' => Router::fullBaseUrl() . '/shop/paymentCanceled');
return $opt;
}
示例9: url
/**
* Get the URL for a given asset name.
*
* Takes an build filename, and returns the URL
* to that build file.
*
* @param string $file The build file that you want a URL for.
* @param array $options Options for URL generation.
* @return string The generated URL.
* @throws Exception when the build file does not exist.
*/
public function url($file = null, $full = false)
{
$config = $this->config();
if (!$config->exists($file)) {
throw new Exception('Cannot get URL for build file that does not exist.');
}
$options = $full;
if (!is_array($full)) {
$options = array('full' => $full);
}
$options += array('full' => false);
$type = $config->getExt($file);
$baseUrl = $config->get($type . '.baseUrl');
$path = $config->get($type . '.cachePath');
$devMode = Configure::read('debug') > 0;
// CDN routes.
if ($baseUrl && !$devMode) {
return $baseUrl . $this->_getBuildName($file);
}
if (!$devMode) {
$path = str_replace(WWW_ROOT, '/', $path);
$path = rtrim($path, '/') . '/';
$route = $path . $this->_getBuildName($file);
}
if ($devMode || $config->general('alwaysEnableController')) {
$baseUrl = str_replace(WWW_ROOT, '/', $path);
$route = $this->_getRoute($file, $baseUrl);
}
if (DS === '\\') {
$route = str_replace(DS, '/', $route);
}
if ($options['full']) {
$base = method_exists('Router', 'fullBaseUrl') ? Router::fullBaseUrl() : FULL_BASE_URL;
return $base . $route;
}
return $route;
}
示例10: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
Router::fullBaseUrl('http://www.example.com/test');
parent::setUp();
$this->Collection = new ComponentCollection();
$this->Mollie = new MollieComponent($this->Collection, $this->settings);
$this->Mollie->Http = new StubHttpSocket();
}
示例11: urlProjectFull
/**
* Captura a URL do projeto
* - protocol://project_server/project_name
* - http://192.168.56.101/project_name/
* - http://localhost/project_name/
*
* @return string url
*/
public static function urlProjectFull()
{
$urlServer = Router::fullBaseUrl();
$projectServerPath = Router::getPaths();
return $urlServer . $projectServerPath['base'];
}
示例12: getDocumentsUrl
/**
* Returns documents url
* @param string $curl
* @return string
*/
public function getDocumentsUrl($curl)
{
return Router::fullBaseUrl() . $curl;
}