当前位置: 首页>>代码示例>>PHP>>正文


PHP Routing\Router类代码示例

本文整理汇总了PHP中Cake\Routing\Router的典型用法代码示例。如果您正苦于以下问题:PHP Router类的具体用法?PHP Router怎么用?PHP Router使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Router类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 protected function init()
 {
     require_once ROOT . DS . 'vendor' . DS . 'hybridauth' . DS . 'hybridauth' . DS . 'hybridauth' . DS . 'Hybrid' . DS . 'Auth.php';
     //D:\xampp\htdocs\libu\vendor\hybridauth\hybridauth\hybridauth\Hybrid
     $config = array("base_url" => Router::url("/social_endpoint", true), "debug_mode" => $this->debug_mode, "debug_file" => $this->debug_file, "providers" => array("Google" => array("enabled" => true, "keys" => array("id" => "384547532967-of8s1pp85dl90dafblfao29ll2qjeglr.apps.googleusercontent.com", "secret" => "tbJRI1QoEwJ5fa8ZfLjitnne")), "Facebook" => array("enabled" => true, "keys" => array("id" => "719642394849027", "secret" => "e6f3739977461ff0339d71ad50490f6d"), "trustForwarded" => false)));
     $this->hybridauth = new \Hybrid_Auth($config);
 }
开发者ID:ngdinhbinh,项目名称:libu,代码行数:7,代码来源:HybridauthComponent.php

示例2: seeCurrentRouteIs

 /**
  * Asserts that current url matches route.
  *
  * @param array|string $route Route's array or name.
  * @param array $params Extra route parameters (i.e. prefix, _method, etc.)
  */
 public function seeCurrentRouteIs($route, $params = [])
 {
     if (!is_array($route)) {
         $route = ['_name' => $route];
     }
     $this->seeCurrentUrlEquals(Router::url($route + $params));
 }
开发者ID:cakephp,项目名称:codeception,代码行数:13,代码来源:RouterTrait.php

示例3: data_tables

 public function data_tables()
 {
     $current_developer = TableRegistry::get('Developers')->findById($this->request->session()->read('Developer.id'))->all()->first();
     $aColumns = ['report_id' => 'Reports.id', 'error_message' => 'Reports.error_message', 'error_name' => 'Reports.error_name', 'pma_version' => 'Reports.pma_version', 'exception_type' => 'Reports.exception_type', 'created_time' => 'Notifications.created'];
     $orderConditions = $this->OrderSearch->getOrder($aColumns);
     $searchConditions = $this->OrderSearch->getSearchConditions($aColumns);
     $aColumns['id'] = 'Notifications.id';
     $params = ['contain' => 'Reports', 'fields' => $aColumns, 'conditions' => ['AND' => [array('Notifications.developer_id ' => $current_developer['id']), $searchConditions]], 'order' => $orderConditions];
     //$current_developer = Sanitize::clean($current_developer);
     $pagedParams = $params;
     $pagedParams['limit'] = intval($this->request->query('iDisplayLength'));
     $pagedParams['offset'] = intval($this->request->query('iDisplayStart'));
     $rows = $this->Notifications->find('all', $pagedParams);
     //$rows = Sanitize::clean($rows);
     // Make the display rows array
     $dispRows = array();
     $tmp_row = array();
     foreach ($rows as $row) {
         $tmp_row[0] = '<input type="checkbox" name="notifs[]" value="' . $row['id'] . '"/>';
         $tmp_row[1] = '<a href="' . Router::url(array('controller' => 'reports', 'action' => 'view', $row['report_id'])) . '">' . $row['report_id'] . '</a>';
         $tmp_row[2] = $row['error_name'];
         $tmp_row[3] = $row['error_message'];
         $tmp_row[4] = $row['pma_version'];
         $tmp_row[5] = $row['exception_type'] ? 'php' : 'js';
         $tmp_row[6] = $row['created_time'];
         array_push($dispRows, $tmp_row);
     }
     $response = array('iTotalDisplayRecords' => count($dispRows), 'iTotalRecords' => $this->Notifications->find('all', $params)->count(), 'sEcho' => intval($this->request->query('sEcho')), 'aaData' => $dispRows);
     $this->autoRender = false;
     $this->response->body(json_encode($response));
     return $this->response;
 }
开发者ID:ujjwalwahi,项目名称:error-reporting-server,代码行数:32,代码来源:NotificationsController.php

示例4: testQueryStringAndCustomTime

 /**
  * test setting parameters in beforeDispatch method
  *
  * @return void
  */
 public function testQueryStringAndCustomTime()
 {
     $folder = CACHE . 'views' . DS;
     $file = $folder . 'posts-home-coffee-life-sleep-sissies-coffee-life-sleep-sissies.html';
     $content = '<!--cachetime:' . (time() + WEEK) . ';ext:html-->Foo bar';
     file_put_contents($file, $content);
     Router::reload();
     Router::connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
     Router::connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
     Router::connect('/:controller/:action/*');
     $_GET = ['coffee' => 'life', 'sleep' => 'sissies'];
     $filter = new CacheFilter();
     $request = new Request('posts/home/?coffee=life&sleep=sissies');
     $response = new Response();
     $event = new Event(__CLASS__, $this, compact('request', 'response'));
     $filter->beforeDispatch($event);
     $result = $response->body();
     $expected = '<!--created:';
     $this->assertTextStartsWith($expected, $result);
     $expected = '-->Foo bar';
     $this->assertTextEndsWith($expected, $result);
     $result = $response->type();
     $expected = 'text/html';
     $this->assertEquals($expected, $result);
     $result = $response->header();
     $this->assertNotEmpty($result['Expires']);
     // + 1 week
     unlink($file);
 }
开发者ID:jxav,项目名称:cakephp-cache,代码行数:34,代码来源:CacheFilterTest.php

示例5: defineElfinderBrowser

    public function defineElfinderBrowser($return = false)
    {
        $url = Router::url('/cakephp-tinymce-elfinder/Elfinders/elfinder');
        $clientOptions = Configure::read('TinymceElfinder.client_options');
        $title = Configure::read('TinymceElfinder.title');
        $str = '
		<script type="text/javascript">
		function elFinderBrowser (field_name, url, type, win) {
			  tinymce.activeEditor.windowManager.open({
			    file: "' . $url . '",
			    title: "' . $title . '",
			    width: ' . ($clientOptions['width'] + 20) . ',  
			    height: ' . ($clientOptions['height'] + 50) . ',
			    resizable: "' . $clientOptions['resizable'] . '"
			  }, {
			    setUrl: function (url) {
			      win.document.getElementById(field_name).value = url;
			    }
			  });
			  return false;
			}
		</script>';
        if ($return) {
            return $str;
        } else {
            echo $str;
        }
    }
开发者ID:hashmode,项目名称:cakephp-tinymce-elfinder,代码行数:28,代码来源:TinymceElfinderHelper.php

示例6: setUri

 public function setUri($uri)
 {
     if (is_array($uri)) {
         $uri = Router::url($uri);
     }
     return parent::setUri($uri);
 }
开发者ID:gourmet,项目名称:knp-menu,代码行数:7,代码来源:MenuItem.php

示例7: upload

 /**
  * Uploads a new file for the given FileField instance.
  *
  * @param string $name EAV attribute name
  * @throws \Cake\Network\Exception\NotFoundException When invalid slug is given,
  *  or when upload process could not be completed
  */
 public function upload($name)
 {
     $instance = $this->_getInstance($name);
     require_once Plugin::classPath('Field') . 'Lib/class.upload.php';
     $uploader = new \upload($this->request->data['Filedata']);
     if (!empty($instance->settings['extensions'])) {
         $exts = explode(',', $instance->settings['extensions']);
         $exts = array_map('trim', $exts);
         $exts = array_map('strtolower', $exts);
         if (!in_array(strtolower($uploader->file_src_name_ext), $exts)) {
             $this->_error(__d('field', 'Invalid file extension.'), 501);
         }
     }
     $response = '';
     $uploader->file_overwrite = false;
     $folder = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/");
     $url = normalizePath("/files/{$instance->settings['upload_folder']}/", '/');
     $uploader->process($folder);
     if ($uploader->processed) {
         $response = json_encode(['file_url' => Router::url($url . $uploader->file_dst_name, true), 'file_size' => FileToolbox::bytesToSize($uploader->file_src_size), 'file_name' => $uploader->file_dst_name, 'mime_icon' => FileToolbox::fileIcon($uploader->file_src_mime)]);
     } else {
         $this->_error(__d('field', 'File upload error, details: {0}', $uploader->error), 502);
     }
     $this->viewBuilder()->layout('ajax');
     $this->title(__d('field', 'Upload File'));
     $this->set(compact('response'));
 }
开发者ID:quickapps-plugins,项目名称:field,代码行数:34,代码来源:FileHandlerController.php

示例8: 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;
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:41,代码来源:UrlHelper.php

示例9: setUp

 /**
  * Setup method.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::plugin('DebugKit', function ($routes) {
         $routes->connect('/toolbar/clear_cache/*', ['plugin' => 'DebugKit', 'controller' => 'Toolbar', 'action' => 'clearCache']);
     });
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:12,代码来源:ToolbarControllerTest.php

示例10: main

 /**
  * @return void
  */
 public function main()
 {
     self::_loadRoutes();
     $formatter = "%15s  %-20s  %-20s  %-10s";
     $this->out(sprintf($formatter, 'Method', 'URI Pattern', 'Controller/Action', 'extensions'));
     foreach (Router::routes() as $route) {
         if (isset($route->defaults['_method'])) {
             if (is_array($route->defaults['_method'])) {
                 $outputMethod = implode(',', $route->defaults['_method']);
             } else {
                 $outputMethod = $route->defaults['_method'];
             }
         } else {
             $outputMethod = 'GET';
         }
         $uriPattern = $route->template;
         if (isset($route->options['_ext']) && $route->options['_ext']) {
             $ext = implode(',', $route->options['_ext']);
         } else {
             $ext = "none";
         }
         //そもそもControllerが定義されていないものに関しては表示しないようにしている。
         if (isset($route->defaults['controller'])) {
             $this->out(sprintf($formatter, $outputMethod, $uriPattern, $route->defaults['controller'] . '/' . $route->defaults['action'], $ext));
         }
     }
 }
开发者ID:webuilder240,项目名称:cake-console-routes,代码行数:30,代码来源:RoutesShell.php

示例11: sendMail

 public function sendMail()
 {
     $mailer = new Email();
     $mailer->transport('smtp');
     $email_to = 'xuan@bliss-interactive.com';
     $replyToEmail = "xuan@bliss-interactive.com";
     $replyToEmailName = 'Info';
     $fromEmail = "noreply@bliss-interactive.net";
     $fromEmailName = "Xuan";
     $emailSubject = "Demo mail";
     //$view_link = Router::url('/', true);
     $params_name = 'XuanNguyen';
     $view_link = Router::url(['language' => $this->language, 'controller' => 'frontend', 'action' => 'view_email', 'confirmation', $params_name], true);
     $sentMailSatus = array();
     if (!empty($email_to)) {
         //emailFormat text, html or both.
         $mailer->template('content', 'template')->emailFormat('html')->subject($emailSubject)->viewVars(['data' => ['language' => $this->language, 'mail_template' => 'confirmation', 'email_vars' => ['view_link' => $view_link, 'name' => $params_name]]])->from([$fromEmail => $fromEmailName])->replyTo([$replyToEmail => $replyToEmailName])->to($email_to);
         if ($mailer->send()) {
             $sentMailSatus = 1;
         } else {
             $sentMailSatus = 0;
         }
     }
     pr($sentMailSatus);
     exit;
 }
开发者ID:hongtien510,项目名称:cakephp-routing,代码行数:26,代码来源:TemplateCodeController.php

示例12: setUp

 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::reload();
     $View = new View(null);
     $this->Flash = new FlashHelper($View);
 }
开发者ID:alescx,项目名称:cakephp-tools,代码行数:10,代码来源:FlashHelperTest.php

示例13: tearDown

 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     unset($this->Table, $this->Behavior, $this->Email);
     Router::fullBaseUrl($this->fullBaseBackup);
     Email::dropTransport('test');
     parent::tearDown();
 }
开发者ID:drmonkeyninja,项目名称:users,代码行数:12,代码来源:SocialAccountBehaviorTest.php

示例14: build

 /**
  * Returns a URL based on provided parameters.
  *
  * ### Options:
  *
  * - `fullBase`: If true, the full base URL will be prepended to the result
  *
  * @param string|array|null $url Either a relative string url like `/products/view/23` or
  *    an array of URL parameters. Using an array for URLs will allow you to leverage
  *    the reverse routing features of CakePHP.
  * @param array $options Array of options
  * @return string Full translated URL with base path.
  */
 public function build($url = null, array $options = [])
 {
     $defaults = ['fullBase' => false];
     $options += $defaults;
     $url = Router::url($url, $options['fullBase']);
     return $url;
 }
开发者ID:dereuromark,项目名称:cakephp-tools,代码行数:20,代码来源:UrlComponent.php

示例15: redirect

 /**
  * {@inheritDoc}
  */
 public function redirect($url, $status = null)
 {
     if (Router::normalize($this->Auth->config('loginAction')) == Router::normalize($url)) {
         return $this->Api->response(ApiReturnCode::NOT_AUTHENTICATED);
     }
     return parent::redirect($url, $status);
 }
开发者ID:scherersoftware,项目名称:cake-api-baselayer,代码行数:10,代码来源:AppController.php


注:本文中的Cake\Routing\Router类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。