fullBaseUrl() 공개 정적인 메소드

## Note: If you change the configuration value App.fullBaseUrl during runtime and expect the router to produce links using the new setting, you are required to call this method passing such value again.
public static fullBaseUrl ( string $base = null ) : string
$base string the prefix for URLs generated containing the domain. For example: ``http://example.com``
리턴 string
예제 #1
0
 /**
  * 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
0
 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'));
     }
 }
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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\\/&lt;\\[You\\]&gt;/', '/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(&quot;Are you sure you want to do this?&quot;)) { 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(&quot;Confirm&#039;s \\&quot;nightmares\\&quot;&quot;)) { 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 &gt;', '/a');
     $this->assertTags($result, $expected);
     $result = $this->Html->link('Next >', '#', array('escape' => true));
     $expected = array('a' => array('href' => '#'), 'Next &gt;', '/a');
     $this->assertTags($result, $expected);
     $result = $this->Html->link('Next >', '#', array('escape' => 'utf-8'));
     $expected = array('a' => array('href' => '#'), 'Next &gt;', '/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 &#8230; or not escape?', 'escape' => false));
     $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' => 'to escape &#8230; or not escape?', 'escape' => true));
     $expected = array('a' => array('href' => '#', 'title' => 'to escape &amp;#8230; or not escape?'), 'Next &gt;', '/a');
     $this->assertTags($result, $expected);
     $result = $this->Html->link('Next >', '#', array('title' => 'Next >', 'escapeTitle' => false));
     $expected = array('a' => array('href' => '#', 'title' => 'Next &gt;'), '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&amp;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 &quot;howdy&quot;'), '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&param2=value2');
     $expected = array('a' => array('href' => 'http://www.example.org?param1=value1&amp;param2=value2'), 'http://www.example.org?param1=value1&amp;param2=value2', '/a');
     $this->assertTags($result, $expected);
     $result = $this->Html->link('alert', 'javascript:alert(\'cakephp\');');
     $expected = array('a' => array('href' => 'javascript:alert(&#039;cakephp&#039;);'), '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 &quot;cakephp&quot;'), 'say hello to 0123465-798', '/a');
     $this->assertTags($result, $expected);
 }
예제 #8
0
 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;
 }
 /**
  * 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
0
 /**
  * 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();
 }
 /**
  * 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'];
 }
 /**
  * Returns documents url
  * @param  string $curl
  * @return string
  */
 public function getDocumentsUrl($curl)
 {
     return Router::fullBaseUrl() . $curl;
 }