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


PHP UrlHelper::setAllowedProtocols方法代码示例

本文整理汇总了PHP中Drupal\Component\Utility\UrlHelper::setAllowedProtocols方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper::setAllowedProtocols方法的具体用法?PHP UrlHelper::setAllowedProtocols怎么用?PHP UrlHelper::setAllowedProtocols使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Component\Utility\UrlHelper的用法示例。


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

示例1: __construct

 /**
  *  Constructs a new unroutedUrlAssembler object.
  *
  * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
  *   A request stack object.
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config
  *    The config factory.
  * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor
  *   The output path processor.
  */
 public function __construct(RequestStack $request_stack, ConfigFactoryInterface $config, OutboundPathProcessorInterface $path_processor)
 {
     $allowed_protocols = $config->get('system.filter')->get('protocols') ?: ['http', 'https'];
     UrlHelper::setAllowedProtocols($allowed_protocols);
     $this->requestStack = $request_stack;
     $this->pathProcessor = $path_processor;
 }
开发者ID:brstde,项目名称:gap1,代码行数:17,代码来源:UnroutedUrlAssembler.php

示例2: __construct

 /**
  * Constructs a new generator object.
  *
  * @param \Drupal\Core\Routing\RouteProviderInterface $provider
  *   The route provider to be searched for routes.
  * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor
  *   The path processor to convert the system path to one suitable for urls.
  * @param \Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface $route_processor
  *   The route processor.
  * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
  *   A request stack object.
  * @param string[] $filter_protocols
  *   (optional) An array of protocols allowed for URL generation.
  */
 public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, RequestStack $request_stack, array $filter_protocols = ['http', 'https'])
 {
     $this->provider = $provider;
     $this->context = new RequestContext();
     $this->pathProcessor = $path_processor;
     $this->routeProcessor = $route_processor;
     UrlHelper::setAllowedProtocols($filter_protocols);
     $this->requestStack = $request_stack;
 }
开发者ID:jthoresen,项目名称:PladsenDrupal,代码行数:23,代码来源:UrlGenerator.php

示例3: __construct

 /**
  *  Constructs a new generator object.
  *
  * @param \Drupal\Core\Routing\RouteProviderInterface $provider
  *   The route provider to be searched for routes.
  * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor
  *   The path processor to convert the system path to one suitable for urls.
  * @param \Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface $route_processor
  *   The route processor.
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config
  *    The config factory.
  * @param \Psr\Log\LoggerInterface $logger
  *   An optional logger for recording errors.
  * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
  *   A request stack object.
  */
 public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, ConfigFactoryInterface $config, LoggerInterface $logger = NULL, RequestStack $request_stack)
 {
     parent::__construct($provider, $logger);
     $this->pathProcessor = $path_processor;
     $this->routeProcessor = $route_processor;
     $allowed_protocols = $config->get('system.filter')->get('protocols') ?: array('http', 'https');
     UrlHelper::setAllowedProtocols($allowed_protocols);
     $this->requestStack = $request_stack;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:25,代码来源:UrlGenerator.php

示例4: testValidate

 /**
  * @covers ::validate
  * @dataProvider providerValidate
  */
 public function testValidate($value, $valid)
 {
     $context = $this->getMock('Symfony\\Component\\Validator\\ExecutionContextInterface');
     if ($valid) {
         $context->expects($this->never())->method('addViolation');
     } else {
         $context->expects($this->once())->method('addViolation');
     }
     // Setup some more allowed protocols.
     UrlHelper::setAllowedProtocols(['http', 'https', 'magnet']);
     $constraint = new LinkExternalProtocolsConstraint();
     $validator = new LinkExternalProtocolsConstraintValidator();
     $validator->initialize($context);
     $validator->validate($value, $constraint);
 }
开发者ID:dev981,项目名称:gaptest,代码行数:19,代码来源:LinkExternalProtocolsConstraintValidatorTest.php

示例5: __construct

 /**
  * Constructs a new unroutedUrlAssembler object.
  *
  * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
  *   A request stack object.
  * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor
  *   The output path processor.
  * @param string[] $filter_protocols
  *   (optional) An array of protocols allowed for URL generation.
  */
 public function __construct(RequestStack $request_stack, OutboundPathProcessorInterface $path_processor, array $filter_protocols = ['http', 'https'])
 {
     UrlHelper::setAllowedProtocols($filter_protocols);
     $this->requestStack = $request_stack;
     $this->pathProcessor = $path_processor;
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:16,代码来源:UnroutedUrlAssembler.php

示例6: preHandle

 /**
  * {@inheritdoc}
  */
 public function preHandle(Request $request)
 {
     $this->loadLegacyIncludes();
     // Load all enabled modules.
     $this->container->get('module_handler')->loadAll();
     // Register stream wrappers.
     $this->container->get('stream_wrapper_manager')->register();
     // Initialize legacy request globals.
     $this->initializeRequestGlobals($request);
     // Put the request on the stack.
     $this->container->get('request_stack')->push($request);
     // Set the allowed protocols once we have the config available.
     $allowed_protocols = $this->container->get('config.factory')->get('system.filter')->get('protocols');
     if (!isset($allowed_protocols)) {
         // \Drupal\Component\Utility\UrlHelper::filterBadProtocol() is called by
         // the installer and update.php, in which case the configuration may not
         // exist (yet). Provide a minimal default set of allowed protocols for
         // these cases.
         $allowed_protocols = array('http', 'https');
     }
     UrlHelper::setAllowedProtocols($allowed_protocols);
     // Override of Symfony's mime type guesser singleton.
     MimeTypeGuesser::registerWithSymfonyGuesser($this->container);
     $this->prepared = TRUE;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:28,代码来源:DrupalKernel.php

示例7: preHandle

 /**
  * {@inheritdoc}
  */
 public function preHandle(Request $request)
 {
     $this->loadLegacyIncludes();
     // Load all enabled modules.
     $this->container->get('module_handler')->loadAll();
     // Register stream wrappers.
     $this->container->get('stream_wrapper_manager')->register();
     // Initialize legacy request globals.
     $this->initializeRequestGlobals($request);
     // Put the request on the stack.
     $this->container->get('request_stack')->push($request);
     // Set the allowed protocols.
     UrlHelper::setAllowedProtocols($this->container->getParameter('filter_protocols'));
     // Override of Symfony's MIME type guesser singleton.
     MimeTypeGuesser::registerWithSymfonyGuesser($this->container);
     $this->prepared = TRUE;
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:20,代码来源:DrupalKernel.php

示例8: testStripDangerousProtocols

 /**
  * Tests dangerous url protocol filtering.
  *
  * @dataProvider providerTestStripDangerousProtocols
  * @covers ::setAllowedProtocols
  * @covers ::stripDangerousProtocols
  *
  * @param string $uri
  *    Protocol URI.
  * @param string $expected
  *    Expected escaped value.
  * @param array $protocols
  *    Protocols to allow.
  */
 public function testStripDangerousProtocols($uri, $expected, $protocols)
 {
     UrlHelper::setAllowedProtocols($protocols);
     $stripped = UrlHelper::stripDangerousProtocols($uri);
     $this->assertEquals($expected, $stripped);
 }
开发者ID:scratch,项目名称:gai,代码行数:20,代码来源:UrlHelperTest.php

示例9: preHandle

 /**
  * {@inheritdoc}
  */
 public function preHandle(Request $request)
 {
     // Load all enabled modules.
     $this->container->get('module_handler')->loadAll();
     // Initialize legacy request globals.
     $this->initializeRequestGlobals($request);
     // Initialize cookie globals.
     $this->initializeCookieGlobals($request);
     // Put the request on the stack.
     $this->container->get('request_stack')->push($request);
     // Set the allowed protocols once we have the config available.
     $allowed_protocols = $this->container->get('config.factory')->get('system.filter')->get('protocols');
     if (!isset($allowed_protocols)) {
         // \Drupal\Component\Utility\UrlHelper::filterBadProtocol() is called by
         // the installer and update.php, in which case the configuration may not
         // exist (yet). Provide a minimal default set of allowed protocols for
         // these cases.
         $allowed_protocols = array('http', 'https');
     }
     UrlHelper::setAllowedProtocols($allowed_protocols);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:24,代码来源:DrupalKernel.php

示例10: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $allowed_protocols = array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal', 'rtsp');
     UrlHelper::setAllowedProtocols($allowed_protocols);
 }
开发者ID:brstde,项目名称:gap1,代码行数:9,代码来源:XssTest.php

示例11: testFormat

  /**
   * Tests string formatting with SafeMarkup::format().
   *
   * @dataProvider providerFormat
   * @covers ::format
   *
   * @param string $string
   *   The string to run through SafeMarkup::format().
   * @param string[] $args
   *   The arguments to pass into SafeMarkup::format().
   * @param string $expected
   *   The expected result from calling the function.
   * @param string $message
   *   The message to display as output to the test.
   * @param bool $expected_is_safe
   *   Whether the result is expected to be safe for HTML display.
   */
  public function testFormat($string, array $args, $expected, $message, $expected_is_safe) {
    UrlHelper::setAllowedProtocols(['http', 'https', 'mailto']);

    $result = SafeMarkup::format($string, $args);
    $this->assertEquals($expected, $result, $message);
    $this->assertEquals($expected_is_safe, SafeMarkup::isSafe($result), 'SafeMarkup::format correctly sets the result as safe or not safe.');

    foreach ($args as $arg) {
      $this->assertSame($arg instanceof SafeMarkupTestMarkup, SafeMarkup::isSafe($arg));
    }
  }
开发者ID:komejo,项目名称:article-test,代码行数:28,代码来源:SafeMarkupTest.php

示例12: __construct

 /**
  *  Constructs a new generator object.
  *
  * @param \Drupal\Core\Routing\RouteProviderInterface $provider
  *   The route provider to be searched for routes.
  * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor
  *   The path processor to convert the system path to one suitable for urls.
  * @param \Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface $route_processor
  *   The route processor.
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config
  *    The config factory.
  * @param \Drupal\Core\Site\Settings $settings
  *    The read only settings.
  * @param \Psr\Log\LoggerInterface $logger
  *   An optional logger for recording errors.
  * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
  *   A request stack object.
  */
 public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, ConfigFactoryInterface $config, Settings $settings, LoggerInterface $logger = NULL, RequestStack $request_stack)
 {
     parent::__construct($provider, $logger);
     $this->pathProcessor = $path_processor;
     $this->routeProcessor = $route_processor;
     $this->mixedModeSessions = $settings->get('mixed_mode_sessions', FALSE);
     $allowed_protocols = $config->get('system.filter')->get('protocols') ?: array('http', 'https');
     UrlHelper::setAllowedProtocols($allowed_protocols);
     $this->requestStack = $request_stack;
     $this->updateFromRequest();
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:29,代码来源:UrlGenerator.php


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