本文整理汇总了PHP中Cake\Routing\Router::fullBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::fullBaseUrl方法的具体用法?PHP Router::fullBaseUrl怎么用?PHP Router::fullBaseUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Routing\Router
的用法示例。
在下文中一共展示了Router::fullBaseUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
unset($this->Table, $this->Behavior, $this->Email);
Router::fullBaseUrl($this->fullBaseBackup);
Email::dropTransport('test');
parent::tearDown();
}
示例2: 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, array $options = [])
{
if (is_array($path)) {
return $this->build($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;
}
示例3: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->Users);
Router::fullBaseUrl($this->fullBaseBackup);
Email::drop('default');
Email::dropTransport('test');
Email::config('default', $this->configEmail);
parent::tearDown();
}
示例4: setUp
/**
* setUp
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->EmailSender = $this->getMockBuilder('CakeDC\\Users\\Email\\EmailSender')->setMethods(['_getEmailInstance', 'getMailer'])->getMock();
$this->UserMailer = $this->getMockBuilder('CakeDC\\Users\\Mailer\\UserMailer')->setMethods(['send'])->getMock();
$this->fullBaseBackup = Router::fullBaseUrl();
Router::fullBaseUrl('http://users.test');
Email::configTransport('test', ['className' => 'Debug']);
}
示例5: _getList
/**
* Replace array keys in macros key.
*
* @param array $list
* @return array
*/
protected function _getList(array $list = [])
{
$result = [];
$list['base_url'] = Router::fullBaseUrl();
foreach ($list as $key => $value) {
$key = '{' . $key . '}';
$result[$key] = $value;
}
return $result;
}
示例6: testSetGet
/**
* @return void
*/
public function testSetGet()
{
$macros = new Macros();
$this->assertSame(['base_url' => Router::fullBaseUrl()], $macros->get());
$macros->set('test_1', 'Test 1')->set('test_2', 'Test 2')->set('test_3', 'Test 3');
$this->assertSame(['test_3' => 'Test 3', 'test_2' => 'Test 2', 'test_1' => 'Test 1', 'base_url' => Router::fullBaseUrl()], $macros->get());
$this->assertSame('Test 3', $macros->get('test_3'));
$entity = new Entity(['status' => 'Publish']);
$macros = new Macros($entity);
$this->assertSame(['base_url' => 'http://localhost', 'status' => 'Publish'], $macros->get());
}
示例7: afterForgot
public function afterForgot($event, $user)
{
$email = new Email('default');
$email->viewVars(['user' => $user, 'resetUrl' => Router::fullBaseUrl() . Router::url(['prefix' => false, 'plugin' => 'Users', 'controller' => 'Users', 'action' => 'reset', $user['email'], $user['request_key']]), 'baseUrl' => Router::fullBaseUrl(), 'loginUrl' => Router::fullBaseUrl() . '/login']);
$email->from(Configure::read('Users.email.from'));
$email->subject(Configure::read('Users.email.afterForgot.subject'));
$email->emailFormat('both');
$email->transport(Configure::read('Users.email.transport'));
$email->template('Users.afterForgot', 'Users.default');
$email->to($user['email']);
$email->send();
}
示例8: read
public function read($path)
{
$dir = new Folder($path);
$read = $dir->read();
$result = [];
foreach ($read[0] as $folder) {
$info = new Folder($path . DS . $folder);
$reference = Router::fullBaseUrl() . '/' . $this->toRelative($path . '/' . $folder);
$data = ['name' => $folder, 'type' => 'folder', 'path' => $path . DS . $folder, 'reference' => $reference, 'extension' => 'folder', 'size' => $info->dirsize()];
$result[] = $data;
}
foreach ($read[1] as $file) {
$info = new File($path . DS . $file, false);
$reference = Router::fullBaseUrl() . '/' . $this->toRelative($path . '/' . $file);
$data = ['name' => $info->info()['basename'], 'type' => 'file', 'path' => $path, 'reference' => $reference, 'extension' => $info->info()['extension'], 'size' => $info->info()['filesize']];
$result[] = $data;
}
return $result;
}
示例9: getUser
/**
* {@inheritDoc}
*/
public function getUser(Request $request)
{
$auth = $request->header('Authorization');
if (empty($auth) && function_exists('apache_request_headers')) {
$headers = apache_request_headers();
$auth = empty($headers['Authorization']) ? null : $headers['Authorization'];
}
if (empty($auth)) {
return false;
}
if (strpos($auth, ' ') === false) {
return false;
}
list($authType, $authString) = explode(' ', $auth, 2);
$authParams = explode(',', $authString);
if (count($authParams) < 3) {
return false;
}
switch (strtolower($authType)) {
case 'url-encoded-api-key':
$postFields = ['messageDigest' => $authParams[1], 'timestamp' => $authParams[2], 'message' => Router::fullBaseUrl() . $request->here()];
break;
case 'nonce-encoded-api-key':
case 'nonce-encoded-wssession-key':
$postFields = ['nonceKey' => $authParams[1], 'messageDigest' => $authParams[2]];
break;
default:
//unknown auth type
return false;
}
$postFields['wsId'] = $authParams[0];
$result = $this->client()->post("https://ws.byu.edu/authentication/services/rest/v1/provider/{$authType}/validate", $postFields);
if (!$result || !$result->isOk()) {
return false;
}
$response = json_decode($result->body(), true);
if (empty($response['netId'])) {
return false;
}
$response['username'] = $response['netId'];
return $response;
}
示例10: assetUrl
/**
* Generates URL for given asset file.
*
* @param array|string $path
* @param array $options
* @return array|null|string
*/
public function assetUrl($path, array $options = [])
{
if (is_array($path)) {
return $this->build($path, !empty($options['fullBase']));
}
if (empty(FS::ext($path))) {
$path .= '.' . $options['ext'];
}
$Path = $this->_View->getPath();
$relative = $Path->isVirtual($path) ? $Path->get($path) : $Path->get('root:' . $path);
if (strpos($path, '://') !== false) {
return $path;
}
if ($relative !== null) {
$path = $Path->url($this->_encodeUrl($this->assetTimestamp($relative)), false);
if (!empty($options['fullBase'])) {
$path = rtrim(Router::fullBaseUrl(), '/') . '/' . ltrim($path, '/');
}
return $path;
}
return null;
}
示例11: testImage
/**
* test image()
*
* @return void
*/
public function testImage()
{
$result = $this->Helper->image('foo.jpg');
$this->assertEquals('img/foo.jpg', $result);
$result = $this->Helper->image('foo.jpg', ['fullBase' => true]);
$this->assertEquals(Router::fullBaseUrl() . '/img/foo.jpg', $result);
$result = $this->Helper->image('dir/sub dir/my image.jpg');
$this->assertEquals('img/dir/sub%20dir/my%20image.jpg', $result);
$result = $this->Helper->image('foo.jpg?one=two&three=four');
$this->assertEquals('img/foo.jpg?one=two&three=four', $result);
$result = $this->Helper->image('dir/big+tall/image.jpg');
$this->assertEquals('img/dir/big%2Btall/image.jpg', $result);
$result = $this->Helper->image('cid:foo.jpg');
$this->assertEquals('cid:foo.jpg', $result);
$result = $this->Helper->image('CID:foo.jpg');
$this->assertEquals('CID:foo.jpg', $result);
}
示例12: testAssetUrl
/**
* test assetUrl application
*
* @return void
*/
public function testAssetUrl()
{
Router::connect('/:controller/:action/*');
$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);
}
示例13: testSetCanonical
/**
* Set Canonical based on configuration array
*/
public function testSetCanonical()
{
$expected = ['canonical' => Router::fullBaseUrl() . '/articles/view?slug=test-title-one', 'active' => true];
$actual = $this->Articles->setCanonical($this->defaultEntity, '/articles/view?slug=test-title-one', $this->defaultConfig['urls'][0]);
$this->assertEquals($expected, $actual);
$actual = $this->Articles->setCanonical($this->defaultEntity, '/articles/view?slug=test-title-one', []);
$this->assertFalse($actual);
}
示例14: 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 bool|array $full Whether or not the URL should have the full base path.
* @return string The generated URL.
* @throws RuntimeException when the build file does not exist.
*/
public function url($file = null, $full = false)
{
$collection = $this->collection();
if (!$collection->contains($file)) {
throw new RuntimeException('Cannot get URL for build file that does not exist.');
}
$options = $full;
if (!is_array($full)) {
$options = ['full' => $full];
}
$options += ['full' => false];
$target = $collection->get($file);
$type = $target->ext();
$config = $this->assetConfig();
$baseUrl = $config->get($type . '.baseUrl');
$devMode = Configure::read('debug');
// CDN routes.
if ($baseUrl && !$devMode) {
return $baseUrl . $this->_getBuildName($target);
}
$root = str_replace('\\', '/', WWW_ROOT);
$path = str_replace('\\', '/', $target->outputDir());
$path = str_replace($root, '/', $path);
if (!$devMode) {
$path = rtrim($path, '/') . '/';
$route = $path . $this->_getBuildName($target);
}
if ($devMode || $config->general('alwaysEnableController')) {
$route = $this->_getRoute($target, $path);
}
if (DS === '\\') {
$route = str_replace(DS, '/', $route);
}
if ($options['full']) {
$base = Router::fullBaseUrl();
return $base . $route;
}
return $route;
}
示例15: getUrl
/**
* Get the url for the given page.
*
* @param int $page
*
* @return string
*/
public function getUrl($page)
{
$url = Router::parse(Router::url());
$url['page'] = $page;
return Router::fullBaseUrl() . Router::url($url);
}