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


PHP Unicode::check方法代码示例

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


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

示例1: bootEnvironment

 /**
  * Setup a consistent PHP environment.
  *
  * This method sets PHP environment options we want to be sure are set
  * correctly for security or just saneness.
  */
 public static function bootEnvironment()
 {
     if (static::$isEnvironmentInitialized) {
         return;
     }
     // Enforce E_STRICT, but allow users to set levels not part of E_STRICT.
     error_reporting(E_STRICT | E_ALL);
     // Override PHP settings required for Drupal to work properly.
     // sites/default/default.settings.php contains more runtime settings.
     // The .htaccess file contains settings that cannot be changed at runtime.
     // Use session cookies, not transparent sessions that puts the session id in
     // the query string.
     ini_set('session.use_cookies', '1');
     ini_set('session.use_only_cookies', '1');
     ini_set('session.use_trans_sid', '0');
     // Don't send HTTP headers using PHP's session handler.
     // Send an empty string to disable the cache limiter.
     ini_set('session.cache_limiter', '');
     // Use httponly session cookies.
     ini_set('session.cookie_httponly', '1');
     // Set sane locale settings, to ensure consistent string, dates, times and
     // numbers handling.
     setlocale(LC_ALL, 'C');
     // Detect string handling method.
     Unicode::check();
     // Indicate that code is operating in a test child site.
     if (!defined('DRUPAL_TEST_IN_CHILD_SITE')) {
         if ($test_prefix = drupal_valid_test_ua()) {
             // Only code that interfaces directly with tests should rely on this
             // constant; e.g., the error/exception handler conditionally adds further
             // error information into HTTP response headers that are consumed by
             // Simpletest's internal browser.
             define('DRUPAL_TEST_IN_CHILD_SITE', TRUE);
             // Log fatal errors to the test site directory.
             ini_set('log_errors', 1);
             ini_set('error_log', DRUPAL_ROOT . '/sites/simpletest/' . substr($test_prefix, 10) . '/error.log');
         } else {
             // Ensure that no other code defines this.
             define('DRUPAL_TEST_IN_CHILD_SITE', FALSE);
         }
     }
     // Set the Drupal custom error handler.
     set_error_handler('_drupal_error_handler');
     set_exception_handler('_drupal_exception_handler');
     static::$isEnvironmentInitialized = TRUE;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:52,代码来源:DrupalKernel.php

示例2: setUp

 /**
  * {@inheritdoc}
  *
  * @covers ::check
  */
 public function setUp()
 {
     // Initialize unicode component.
     Unicode::check();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:10,代码来源:UnicodeTest.php

示例3: setUp

 /**
  * {@inheritdoc}
  *
  * @covers ::check
  */
 protected function setUp()
 {
     // Initialize unicode component.
     Unicode::check();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:UnicodeTest.php

示例4: testTruncate

 /**
  * Tests Unicode::truncate().
  *
  * @dataProvider providerTruncate
  */
 public function testTruncate($text, $max_length, $expected, $wordsafe = FALSE, $add_ellipsis = FALSE)
 {
     Unicode::check();
     $this->assertEquals($expected, Unicode::truncate($text, $max_length, $wordsafe, $add_ellipsis));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:UnicodeTest.php

示例5: bootEnvironment

 /**
  * Setup a consistent PHP environment.
  *
  * This method sets PHP environment options we want to be sure are set
  * correctly for security or just saneness.
  *
  * @param string $app_root
  *   (optional) The path to the application root as a string. If not supplied,
  *   the application root will be computed.
  */
 public static function bootEnvironment($app_root = NULL)
 {
     if (static::$isEnvironmentInitialized) {
         return;
     }
     // Determine the application root if it's not supplied.
     if ($app_root === NULL) {
         $app_root = static::guessApplicationRoot();
     }
     // Include our bootstrap file.
     require_once $app_root . '/core/includes/bootstrap.inc';
     // Enforce E_STRICT, but allow users to set levels not part of E_STRICT.
     error_reporting(E_STRICT | E_ALL);
     // Override PHP settings required for Drupal to work properly.
     // sites/default/default.settings.php contains more runtime settings.
     // The .htaccess file contains settings that cannot be changed at runtime.
     // Use session cookies, not transparent sessions that puts the session id in
     // the query string.
     ini_set('session.use_cookies', '1');
     ini_set('session.use_only_cookies', '1');
     ini_set('session.use_trans_sid', '0');
     // Don't send HTTP headers using PHP's session handler.
     // Send an empty string to disable the cache limiter.
     ini_set('session.cache_limiter', '');
     // Use httponly session cookies.
     ini_set('session.cookie_httponly', '1');
     // Set sane locale settings, to ensure consistent string, dates, times and
     // numbers handling.
     setlocale(LC_ALL, 'C');
     // Detect string handling method.
     Unicode::check();
     // Indicate that code is operating in a test child site.
     if (!defined('DRUPAL_TEST_IN_CHILD_SITE')) {
         if ($test_prefix = drupal_valid_test_ua()) {
             $test_db = new TestDatabase($test_prefix);
             // Only code that interfaces directly with tests should rely on this
             // constant; e.g., the error/exception handler conditionally adds further
             // error information into HTTP response headers that are consumed by
             // Simpletest's internal browser.
             define('DRUPAL_TEST_IN_CHILD_SITE', TRUE);
             // Web tests are to be conducted with runtime assertions active.
             assert_options(ASSERT_ACTIVE, TRUE);
             // Now synchronize PHP 5 and 7's handling of assertions as much as
             // possible.
             Handle::register();
             // Log fatal errors to the test site directory.
             ini_set('log_errors', 1);
             ini_set('error_log', $app_root . '/' . $test_db->getTestSitePath() . '/error.log');
             // Ensure that a rewritten settings.php is used if opcache is on.
             ini_set('opcache.validate_timestamps', 'on');
             ini_set('opcache.revalidate_freq', 0);
         } else {
             // Ensure that no other code defines this.
             define('DRUPAL_TEST_IN_CHILD_SITE', FALSE);
         }
     }
     // Set the Drupal custom error handler.
     set_error_handler('_drupal_error_handler');
     set_exception_handler('_drupal_exception_handler');
     static::$isEnvironmentInitialized = TRUE;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:71,代码来源:DrupalKernel.php

示例6: testTokenViewMode

 /**
  * Test tokens on node with the token view mode overriding default formatters.
  */
 public function testTokenViewMode()
 {
     $value = 'A really long string that should be trimmed by the special formatter on token view we are going to have.';
     // The formatter we are going to use will eventually call Unicode::strlen.
     // This expects that the Unicode has already been explicitly checked, which
     // happens in DrupalKernel. But since that doesn't run in kernel tests, we
     // explicitly call this here.
     Unicode::check();
     // Create a node with a value in the text field and test its token.
     $entity = Node::create(['title' => 'Test node title', 'type' => 'article', 'test_field' => ['value' => $value, 'format' => $this->testFormat->id()]]);
     $entity->save();
     $this->assertTokens('node', ['node' => $entity], ['test_field' => Markup::create($value)]);
     // Now, create a token view mode which sets a different format for
     // test_field. When replacing tokens, this formatter should be picked over
     // the default formatter for the field type.
     // @see field_tokens().
     $view_mode = EntityViewMode::create(['id' => 'node.token', 'targetEntityType' => 'node']);
     $view_mode->save();
     $entity_display = entity_get_display('node', 'article', 'token');
     $entity_display->setComponent('test_field', ['type' => 'text_trimmed', 'settings' => ['trim_length' => 50]]);
     $entity_display->save();
     $this->assertTokens('node', ['node' => $entity], ['test_field' => Markup::create(substr($value, 0, 50))]);
 }
开发者ID:Wylbur,项目名称:gj,代码行数:26,代码来源:FieldTest.php


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