• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Utility\Unicode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testRecreateEntity

 public function testRecreateEntity()
 {
     $type_name = Unicode::strtolower($this->randomMachineName(16));
     $content_type = entity_create('node_type', array('type' => $type_name, 'name' => 'Node type one'));
     $content_type->save();
     node_add_body_field($content_type);
     /** @var \Drupal\Core\Config\StorageInterface $active */
     $active = $this->container->get('config.storage');
     /** @var \Drupal\Core\Config\StorageInterface $sync */
     $sync = $this->container->get('config.storage.sync');
     $config_name = $content_type->getEntityType()->getConfigPrefix() . '.' . $content_type->id();
     $this->copyConfig($active, $sync);
     // Delete the content type. This will also delete a field storage, a field,
     // an entity view display and an entity form display.
     $content_type->delete();
     $this->assertFalse($active->exists($config_name), 'Content type\'s old name does not exist active store.');
     // Recreate with the same type - this will have a different UUID.
     $content_type = entity_create('node_type', array('type' => $type_name, 'name' => 'Node type two'));
     $content_type->save();
     node_add_body_field($content_type);
     $this->configImporter->reset();
     // A node type, a field, an entity view display and an entity form display
     // will be recreated.
     $creates = $this->configImporter->getUnprocessedConfiguration('create');
     $deletes = $this->configImporter->getUnprocessedConfiguration('delete');
     $this->assertEqual(5, count($creates), 'There are 5 configuration items to create.');
     $this->assertEqual(5, count($deletes), 'There are 5 configuration items to delete.');
     $this->assertEqual(0, count($this->configImporter->getUnprocessedConfiguration('update')), 'There are no configuration items to update.');
     $this->assertIdentical($creates, array_reverse($deletes), 'Deletes and creates contain the same configuration names in opposite orders due to dependencies.');
     $this->configImporter->import();
     // Verify that there is nothing more to import.
     $this->assertFalse($this->configImporter->reset()->hasUnprocessedConfigurationChanges());
     $content_type = NodeType::load($type_name);
     $this->assertEqual('Node type one', $content_type->label());
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:35,代码来源:ConfigImportRecreateTest.php


示例2: assignPackages

 /**
  * {@inheritdoc}
  */
 public function assignPackages($force = FALSE)
 {
     $current_bundle = $this->assigner->getBundle();
     $settings = $current_bundle->getAssignmentSettings($this->getPluginId());
     $config_base_types = $settings['types']['config'];
     $config_types = $this->featuresManager->listConfigTypes();
     $config_collection = $this->featuresManager->getConfigCollection();
     foreach ($config_collection as $item_name => $item) {
         if (in_array($item->getType(), $config_base_types)) {
             if (is_null($this->featuresManager->findPackage($item->getShortName())) && !$item->getPackage()) {
                 $description = $this->t('Provides @label @type and related configuration.', array('@label' => $item->getLabel(), '@type' => Unicode::strtolower($config_types[$item->getType()])));
                 if (isset($item->getData()['description'])) {
                     $description .= ' ' . $item->getData()['description'];
                 }
                 $this->featuresManager->initPackage($item->getShortName(), $item->getLabel(), $description, 'module', $current_bundle);
                 // Update list with the package we just added.
                 try {
                     $this->featuresManager->assignConfigPackage($item->getShortName(), [$item_name]);
                 } catch (\Exception $exception) {
                     \Drupal::logger('features')->error($exception->getMessage());
                 }
                 $this->featuresManager->assignConfigDependents([$item_name]);
             }
         }
     }
     $entity_types = $this->entityManager->getDefinitions();
     $content_base_types = $settings['types']['content'];
     foreach ($content_base_types as $entity_type_id) {
         if (!isset($packages[$entity_type_id]) && isset($entity_types[$entity_type_id])) {
             $label = $entity_types[$entity_type_id]->getLabel();
             $description = $this->t('Provide @label related configuration.', array('@label' => $label));
             $this->featuresManager->initPackage($entity_type_id, $label, $description, 'module', $current_bundle);
         }
     }
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:38,代码来源:FeaturesAssignmentBaseType.php


示例3: testDateFormatsMachineNameAllowedValues

 /**
  * Tests that date formats cannot be created with invalid machine names.
  */
 public function testDateFormatsMachineNameAllowedValues()
 {
     // Try to create a date format with a not allowed character to test the date
     // format specific machine name replace pattern.
     $edit = array('label' => 'Something Not Allowed', 'id' => 'something.bad', 'date_format_pattern' => 'Y-m-d');
     $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
     $this->assertText(t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'), 'It is not possible to create a date format with the machine name that has any character other than lowercase letters, digits or underscore.');
     // Try to create a date format with the reserved machine name "custom".
     $edit = array('label' => 'Custom', 'id' => 'custom', 'date_format_pattern' => 'Y-m-d');
     $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
     $this->assertText(t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'), 'It is not possible to create a date format with the machine name "custom".');
     // Try to create a date format with a machine name, "fallback", that
     // already exists.
     $edit = array('label' => 'Fallback', 'id' => 'fallback', 'date_format_pattern' => 'j/m/Y');
     $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
     $this->assertText(t('The machine-readable name is already in use. It must be unique.'), 'It is not possible to create a date format with the machine name "fallback". It is a built-in format that already exists.');
     // Create a date format with a machine name distinct from the previous two.
     $id = Unicode::strtolower($this->randomMachineName(16));
     $edit = array('label' => $this->randomMachineName(16), 'id' => $id, 'date_format_pattern' => 'd/m/Y');
     $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
     $this->assertText(t('Custom date format added.'), 'It is possible to create a date format with a new machine name.');
     // Try to create a date format with same machine name as the previous one.
     $edit = array('label' => $this->randomMachineName(16), 'id' => $id, 'date_format_pattern' => 'd-m-Y');
     $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
     $this->assertText(t('The machine-readable name is already in use. It must be unique.'), 'It is not possible to create a new date format with an existing machine name.');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:29,代码来源:DateFormatsMachineNameTest.php


示例4: testContactStorage

 /**
  * Tests configuration options and the site-wide contact form.
  */
 public function testContactStorage()
 {
     // Create and login administrative user.
     $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer users', 'administer account settings', 'administer contact_message fields'));
     $this->drupalLogin($admin_user);
     // Create first valid contact form.
     $mail = '[email protected]';
     $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE, ['send_a_pony' => 1]);
     $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label)));
     // Ensure that anonymous can submit site-wide contact form.
     user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
     $this->drupalLogout();
     $this->drupalGet('contact');
     $this->assertText(t('Your email address'));
     $this->assertNoText(t('Form'));
     $this->submitContact($name = $this->randomMachineName(16), $mail, $subject = $this->randomMachineName(16), $id, $message = $this->randomMachineName(64));
     $this->assertText(t('Your message has been sent.'));
     $messages = Message::loadMultiple();
     /** @var \Drupal\contact\Entity\Message $message */
     $message = reset($messages);
     $this->assertEqual($message->getContactForm()->id(), $id);
     $this->assertTrue($message->getContactForm()->getThirdPartySetting('contact_storage_test', 'send_a_pony', FALSE));
     $this->assertEqual($message->getSenderName(), $name);
     $this->assertEqual($message->getSubject(), $subject);
     $this->assertEqual($message->getSenderMail(), $mail);
     $config = $this->config("contact.form.{$id}");
     $this->assertEqual($config->get('id'), $id);
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:31,代码来源:ContactStorageTest.php


示例5: testVocabularyDefaultLanguageForTerms

 /**
  * Tests term language settings for vocabulary terms are saved and updated.
  */
 function testVocabularyDefaultLanguageForTerms()
 {
     // Add a new vocabulary and check that the default language settings are for
     // the terms are saved.
     $edit = array('name' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'default_language[langcode]' => 'bb', 'default_language[language_alterable]' => TRUE);
     $vid = $edit['vid'];
     $this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
     // Check that the vocabulary was actually created.
     $this->drupalGet('admin/structure/taxonomy/manage/' . $edit['vid']);
     $this->assertResponse(200, 'The vocabulary has been created.');
     // Check that the language settings were saved.
     $language_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $edit['vid']);
     $this->assertEqual($language_settings->getDefaultLangcode(), 'bb', 'The langcode was saved.');
     $this->assertTrue($language_settings->isLanguageAlterable(), 'The visibility setting was saved.');
     // Check that the correct options are selected in the interface.
     $this->assertOptionSelected('edit-default-language-langcode', 'bb', 'The correct default language for the terms of this vocabulary is selected.');
     $this->assertFieldChecked('edit-default-language-language-alterable', 'Show language selection option is checked.');
     // Edit the vocabulary and check that the new settings are updated.
     $edit = array('default_language[langcode]' => 'aa', 'default_language[language_alterable]' => FALSE);
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
     // And check again the settings and also the interface.
     $language_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vid);
     $this->assertEqual($language_settings->getDefaultLangcode(), 'aa', 'The langcode was saved.');
     $this->assertFalse($language_settings->isLanguageAlterable(), 'The visibility setting was saved.');
     $this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
     $this->assertOptionSelected('edit-default-language-langcode', 'aa', 'The correct default language for the terms of this vocabulary is selected.');
     $this->assertNoFieldChecked('edit-default-language-language-alterable', 'Show language selection option is not checked.');
     // Check that language settings are changed after editing vocabulary.
     $edit = array('name' => $this->randomMachineName(), 'default_language[langcode]' => 'authors_default', 'default_language[language_alterable]' => FALSE);
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $vid, $edit, t('Save'));
     // Check that we have the new settings.
     $new_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vid);
     $this->assertEqual($new_settings->getDefaultLangcode(), 'authors_default', 'The langcode was saved.');
     $this->assertFalse($new_settings->isLanguageAlterable(), 'The new visibility setting was saved.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:38,代码来源:VocabularyLanguageTest.php


示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('taxonomy_term');
     // We want an entity reference field. It needs a vocabulary, terms, a field
     // storage and a field. First, create the vocabulary.
     $vocabulary = entity_create('taxonomy_vocabulary', array('vid' => Unicode::strtolower($this->randomMachineName())));
     $vocabulary->save();
     // Second, create the field.
     entity_test_create_bundle('test_bundle');
     $this->fieldName = strtolower($this->randomMachineName());
     $handler_settings = array('target_bundles' => array($vocabulary->id() => $vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('entity_test', 'test_bundle', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings);
     // Create two terms and also two accounts.
     for ($i = 0; $i <= 1; $i++) {
         $term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'vid' => $vocabulary->id()));
         $term->save();
         $this->terms[] = $term;
         $this->accounts[] = $this->createUser();
     }
     // Create three entity_test entities, the 0th entity will point to the
     // 0th account and 0th term, the 1st and 2nd entity will point to the
     // 1st account and 1st term.
     for ($i = 0; $i <= 2; $i++) {
         $entity = entity_create('entity_test', array('type' => 'test_bundle'));
         $entity->name->value = $this->randomMachineName();
         $index = $i ? 1 : 0;
         $entity->user_id->target_id = $this->accounts[$index]->id();
         $entity->{$this->fieldName}->target_id = $this->terms[$index]->id();
         $entity->save();
         $this->entities[] = $entity;
     }
     $this->factory = \Drupal::service('entity.query');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:34,代码来源:EntityQueryRelationshipTest.php


示例7: testRenameValidation

 /**
  * Tests configuration renaming validation.
  */
 public function testRenameValidation()
 {
     // Create a test entity.
     $test_entity_id = $this->randomMachineName();
     $test_entity = entity_create('config_test', array('id' => $test_entity_id, 'label' => $this->randomMachineName()));
     $test_entity->save();
     $uuid = $test_entity->uuid();
     // Stage the test entity and then delete it from the active storage.
     $active = $this->container->get('config.storage');
     $sync = $this->container->get('config.storage.sync');
     $this->copyConfig($active, $sync);
     $test_entity->delete();
     // Create a content type with a matching UUID in the active storage.
     $content_type = entity_create('node_type', array('type' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), 'uuid' => $uuid));
     $content_type->save();
     // Confirm that the staged configuration is detected as a rename since the
     // UUIDs match.
     $this->configImporter->reset();
     $expected = array('node.type.' . $content_type->id() . '::config_test.dynamic.' . $test_entity_id);
     $renames = $this->configImporter->getUnprocessedConfiguration('rename');
     $this->assertIdentical($expected, $renames);
     // Try to import the configuration. We expect an exception to be thrown
     // because the staged entity is of a different type.
     try {
         $this->configImporter->import();
         $this->fail('Expected ConfigImporterException thrown when a renamed configuration entity does not match the existing entity type.');
     } catch (ConfigImporterException $e) {
         $this->pass('Expected ConfigImporterException thrown when a renamed configuration entity does not match the existing entity type.');
         $expected = array(SafeMarkup::format('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', array('@old_type' => 'node_type', '@new_type' => 'config_test', '@old_name' => 'node.type.' . $content_type->id(), '@new_name' => 'config_test.dynamic.' . $test_entity_id)));
         $this->assertEqual($expected, $this->configImporter->getErrors());
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:35,代码来源:ConfigImportRenameValidationTest.php


示例8: testPathauto

  /**
   * Test Pathauto cleanup in File (Field) Paths.
   */
  public function testPathauto() {
    // Create a File field.
    $field_name = Unicode::strtolower($this->randomMachineName());

    $third_party_settings['filefield_paths']['file_path']['value'] = 'node/[node:title]';
    $third_party_settings['filefield_paths']['file_path']['options']['pathauto'] = TRUE;
    $third_party_settings['filefield_paths']['file_name']['value'] = '[node:title].[file:ffp-extension-original]';
    $third_party_settings['filefield_paths']['file_name']['options']['pathauto'] = TRUE;

    $this->createFileField($field_name, 'node', $this->contentType, [], [], $third_party_settings);

    // Create a node with a test file.
    /** @var \Drupal\file\Entity\File $test_file */
    $test_file = $this->getTestFile('text');
    $edit['title[0][value]'] = $this->randomString() . ' ' . $this->randomString();

    $edit['files[' . $field_name . '_0]'] = \Drupal::service('file_system')
      ->realpath($test_file->getFileUri());
    $this->drupalPostForm("node/add/{$this->contentType}", $edit, $this->t('Save and publish'));

    // Ensure that file path/name have been processed correctly by Pathauto.
    /** @var \Drupal\node\Entity\Node $node */
    $node = Node::load(1);

    $parts = explode('/', $node->getTitle());
    foreach ($parts as &$part) {
      $part = \Drupal::service('pathauto.alias_cleaner')->cleanString($part);
    }
    $title = implode('/', $parts);

    $this->assertEqual($node->{$field_name}[0]->entity->getFileUri(), "public://node/{$title}/{$title}.txt", $this->t('File path/name has been processed correctly by Pathauto'));
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:35,代码来源:FileFieldPathsPathautoTest.php


示例9: testServerAndIndexCreation

  /**
   * Tests the creation of a server and an index.
   */
  public function testServerAndIndexCreation() {
    // Test whether a newly created server appears on the overview page.
    $server = $this->getTestServer();

    $this->drupalGet($this->overviewPageUrl);

    $this->assertText($server->label(), 'Server present on overview page.');
    $this->assertRaw($server->get('description'), 'Description is present');
    $this->assertFieldByXPath('//tr[contains(@class,"' . Html::cleanCssIdentifier($server->getEntityTypeId() . '-' . $server->id()) . '") and contains(@class, "search-api-list-enabled")]', NULL, 'Server is in proper table');

    // Test whether a newly created index appears on the overview page.
    $index = $this->getTestIndex();

    $this->drupalGet($this->overviewPageUrl);

    $this->assertText($index->label(), 'Index present on overview page.');
    $this->assertRaw($index->get('description'), 'Index description is present');
    $this->assertFieldByXPath('//tr[contains(@class,"' . Html::cleanCssIdentifier($index->getEntityTypeId() . '-' . $index->id()) . '") and contains(@class, "search-api-list-enabled")]', NULL, 'Index is in proper table');

    // Test that an entity without bundles can be used as data source.
    // @todo Why is this here? This hasn't got anything to do with the overview.
    $edit = array(
      'name' => $this->randomMachineName(),
      'id' => Unicode::strtolower($this->randomMachineName()),
      'datasources[]' => 'entity:user',
    );
    $this->drupalPostForm('admin/config/search/search-api/add-index', $edit, $this->t('Save'));
    $this->assertText($this->t('The index was successfully saved.'));
    $this->assertText($edit['name']);
  }
开发者ID:jkyto,项目名称:agolf,代码行数:33,代码来源:OverviewPageTest.php


示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('taxonomy_term');
     // We want a taxonomy term reference field. It needs a vocabulary, terms,
     // a field storage and a field. First, create the vocabulary.
     $vocabulary = entity_create('taxonomy_vocabulary', array('vid' => Unicode::strtolower($this->randomMachineName())));
     $vocabulary->save();
     // Second, create the field.
     $this->fieldName = strtolower($this->randomMachineName());
     entity_create('field_storage_config', array('field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array(array('vocabulary' => $vocabulary->id())))))->save();
     entity_test_create_bundle('test_bundle');
     // Third, create the instance.
     entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => $this->fieldName, 'bundle' => 'test_bundle'))->save();
     // Create two terms and also two accounts.
     for ($i = 0; $i <= 1; $i++) {
         $term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'vid' => $vocabulary->id()));
         $term->save();
         $this->terms[] = $term;
         $this->accounts[] = $this->createUser();
     }
     // Create three entity_test entities, the 0th entity will point to the
     // 0th account and 0th term, the 1st and 2nd entity will point to the
     // 1st account and 1st term.
     for ($i = 0; $i <= 2; $i++) {
         $entity = entity_create('entity_test', array('type' => 'test_bundle'));
         $entity->name->value = $this->randomMachineName();
         $index = $i ? 1 : 0;
         $entity->user_id->target_id = $this->accounts[$index]->id();
         $entity->{$this->fieldName}->target_id = $this->terms[$index]->id();
         $entity->save();
         $this->entities[] = $entity;
     }
     $this->factory = \Drupal::service('entity.query');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:35,代码来源:EntityQueryRelationshipTest.php


示例11: proposeRdfEntity

 /**
  * Provides propose forms for various RDF entities.
  *
  * This is used for the propose form of collections and solutions.
  *
  * @param \Drupal\rdf_entity\RdfEntityTypeInterface $rdf_type
  *   The RDF bundle entity for which to generate the propose form.
  *
  * @return array
  *   A render array for the propose form.
  *
  * @throws \Exception
  *   Thrown when an attempt is made to propose an rdf_entity that is not a
  *   solution or a collection.
  */
 public function proposeRdfEntity(RdfEntityTypeInterface $rdf_type)
 {
     $rdf_entity = $this->entityTypeManager()->getStorage('rdf_entity')->create(array('rid' => $rdf_type->id()));
     $form = $this->entityFormBuilder()->getForm($rdf_entity, 'propose');
     $form['#title'] = $this->t('Propose @type', ['@type' => Unicode::strtolower($rdf_type->label())]);
     return $form;
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:22,代码来源:JoinupController.php


示例12: testTransliteration

  /**
   * Test Transliteration cleanup in File (Field) Paths.
   */
  public function testTransliteration() {
    // Create a File field.
    $field_name = Unicode::strtolower($this->randomMachineName());

    $third_party_settings['filefield_paths']['file_path']['value'] = 'node/[node:title]';
    $third_party_settings['filefield_paths']['file_path']['options']['transliterate'] = TRUE;
    $third_party_settings['filefield_paths']['file_name']['value'] = '[node:title].[file:ffp-extension-original]';
    $third_party_settings['filefield_paths']['file_name']['options']['transliterate'] = TRUE;

    $this->createFileField($field_name, 'node', $this->contentType, [], [], $third_party_settings);

    // Create a node with a test file.
    /** @var \Drupal\file\Entity\File $test_file */
    $test_file = $this->getTestFile('text');
    $edit['title[0][value]'] = 'тест';

    $edit['files[' . $field_name . '_0]'] = \Drupal::service('file_system')
      ->realpath($test_file->getFileUri());
    $this->drupalPostForm("node/add/{$this->contentType}", $edit, $this->t('Save and publish'));

    // Get created Node ID.
    $matches = [];
    preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches);
    $nid = $matches[1];

    // Ensure that file path/name have been processed correctly by
    // Transliteration.
    $node = Node::load($nid);
    $this->assertEqual($node->{$field_name}[0]->entity->getFileUri(), "public://node/test/test.txt", $this->t('File path/name has been processed correctly by Transliteration'));
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:33,代码来源:FileFieldPathsTransliterationTest.php


示例13: preprocessIndexValue

 /**
  * {@inheritdoc}
  */
 public function preprocessIndexValue($value, $type = 'text')
 {
     if ($type == 'text') {
         return $value;
     }
     return Unicode::strtolower($this->transliterator->transliterate($value));
 }
开发者ID:curveagency,项目名称:intranet,代码行数:10,代码来源:GenericDatabase.php


示例14: listItems

 /**
  * Lists the feed items belonging to a feed.
  */
 public function listItems(FeedInterface $feeds_feed, Request $request)
 {
     $processor = $feeds_feed->getType()->getProcessor();
     $header = ['title' => $this->t('Label'), 'imported' => $this->t('Imported'), 'guid' => ['data' => $this->t('GUID'), 'class' => [RESPONSIVE_PRIORITY_LOW]], 'url' => ['data' => $this->t('URL'), 'class' => [RESPONSIVE_PRIORITY_LOW]]];
     $build = [];
     $build['table'] = ['#type' => 'table', '#header' => $header, '#rows' => [], '#empty' => $this->t('There are no items yet.')];
     // @todo Allow processors to create their own entity listings.
     if (!$processor instanceof EntityProcessorInterface) {
         return $build;
     }
     $entity_ids = \Drupal::entityQuery($processor->entityType())->condition('feeds_item.target_id', $feeds_feed->id())->pager(50)->sort('feeds_item.imported', 'DESC')->execute();
     $storage = $this->entityManager()->getStorage($processor->entityType());
     foreach ($storage->loadMultiple($entity_ids) as $entity) {
         $ago = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $entity->get('feeds_item')->imported);
         $row = [];
         // Entity link.
         $row[] = ['data' => $entity->link(Unicode::truncate($entity->label(), 75, TRUE, TRUE)), 'title' => $entity->label()];
         // Imported ago.
         $row[] = $this->t('@time ago', ['@time' => $ago]);
         // Item GUID.
         $row[] = ['data' => SafeMarkup::checkPlain(Unicode::truncate($entity->get('feeds_item')->guid, 30, FALSE, TRUE)), 'title' => $entity->get('feeds_item')->guid];
         // Item URL.
         $row[] = ['data' => SafeMarkup::checkPlain(Unicode::truncate($entity->get('feeds_item')->url, 30, FALSE, TRUE)), 'title' => $entity->get('feeds_item')->url];
         $build['table']['#rows'][] = $row;
     }
     $build['pager'] = ['#type' => 'pager'];
     $build['#title'] = $this->t('%title items', ['%title' => $feeds_feed->label()]);
     return $build;
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:32,代码来源:ItemListController.php


示例15: array

 /**
  * Helper function for testTextfieldWidgets().
  */
 function _testTextfieldWidgets($field_type, $widget_type)
 {
     // Create a field.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $field_storage = FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => $field_type));
     $field_storage->save();
     FieldConfig::create(['field_storage' => $field_storage, 'bundle' => 'entity_test', 'label' => $this->randomMachineName() . '_label'])->save();
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => $widget_type, 'settings' => array('placeholder' => 'A placeholder on ' . $widget_type)))->save();
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name)->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
     $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed');
     $this->assertRaw(format_string('placeholder="A placeholder on @widget_type"', array('@widget_type' => $widget_type)));
     // Submit with some value.
     $value = $this->randomMachineName();
     $edit = array("{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created');
     // Display the entity.
     $entity = EntityTest::load($id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
     $this->assertText($value, 'Filtered tags are not displayed');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:31,代码来源:StringFieldTest.php


示例16: testBlockExampleBasic

 /**
  * Tests block_example functionality.
  */
 public function testBlockExampleBasic()
 {
     // Login the admin user.
     $this->drupalLogin($this->webUser);
     $theme_name = \Drupal::config('system.theme')->get('default');
     // Verify the blocks are listed to be added.
     $this->drupalGet('admin/structure/block/list/' . $theme_name);
     $this->assertRaw(t('Title of first block (example_configurable_text)'), 'Block configurable-string found.');
     $this->assertRaw(t('Example: empty block'), 'Block empty-block found.');
     $this->assertRaw(t('Example: uppercase this please'), 'Block uppercase found.');
     // Define and place blocks.
     $settings_configurable = array('label' => t('Title of first block (example_configurable_text)'), 'id' => 'block_example_example_configurable_text', 'theme' => $theme_name);
     $this->drupalPlaceBlock('example_configurable_text', $settings_configurable);
     $settings_uppercase = array('label' => t('Configurable block to be uppercased'), 'id' => 'block_example_example_uppercased', 'theme' => $theme_name);
     $this->drupalPlaceBlock('example_uppercase', $settings_uppercase);
     $settings_empty = array('label' => t('Example: empty block'), 'id' => 'block_example_example_empty', 'theme' => $theme_name);
     $this->drupalPlaceBlock('example_empty', $settings_empty);
     // Verify that blocks are there. Empty block will not be shown, because it
     // is empty.
     $this->drupalGet('/');
     $this->assertRaw($settings_configurable['label'], 'Block configurable test not found.');
     $this->assertNoRaw($settings_uppercase['label'], 'Block uppercase with normal label not found.');
     $this->assertRaw(Unicode::strtoupper($settings_uppercase['label']), 'Block uppercase with uppercased label found.');
     $this->assertNoRaw($settings_empty['label'], 'Block empty not found.');
     // Change content of configurable text block.
     $edit = array('settings[block_example_string_text]' => $this->randomMachineName());
     $this->drupalPostForm('admin/structure/block/manage/' . $settings_configurable['id'], $edit, t('Save block'));
     // Verify that new content is shown.
     $this->drupalGet('/');
     $this->assertRaw($edit['settings[block_example_string_text]'], 'Content of configurable text block successfully verified.');
 }
开发者ID:njcameron,项目名称:ncmd,代码行数:34,代码来源:BlockExampleTest.php


示例17: testEmailField

 /**
  * Tests email field.
  */
 function testEmailField()
 {
     // Create a field with settings to validate.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $this->fieldStorage = FieldStorageConfig::create(array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'email'));
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => 'entity_test']);
     $this->field->save();
     // Create a form display for the default form mode.
     entity_get_form_display('entity_test', 'entity_test', 'default')->setComponent($field_name, array('type' => 'email_default', 'settings' => array('placeholder' => '[email protected]')))->save();
     // Create a display for the full view mode.
     entity_get_display('entity_test', 'entity_test', 'full')->setComponent($field_name, array('type' => 'email_mailto'))->save();
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget found.');
     $this->assertRaw('placeholder="[email protected]"');
     // Submit a valid email address and ensure it is accepted.
     $value = '[email protected]';
     $edit = array("{$field_name}[0][value]" => $value);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     preg_match('|entity_test/manage/(\\d+)|', $this->url, $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
     $this->assertRaw($value);
     // Verify that a mailto link is displayed.
     $entity = EntityTest::load($id);
     $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
     $content = $display->build($entity);
     $this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
     $this->assertLinkByHref('mailto:[email protected]');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:34,代码来源:EmailFieldTest.php


示例18: testTokenizer

 /**
  * Verifies that strings of CJK characters are tokenized.
  *
  * The search_simplify() function does special things with numbers, symbols,
  * and punctuation. So we only test that CJK characters that are not in these
  * character classes are tokenized properly. See PREG_CLASS_CKJ for more
  * information.
  */
 function testTokenizer()
 {
     // Set the minimum word size to 1 (to split all CJK characters) and make
     // sure CJK tokenizing is turned on.
     $this->config('search.settings')->set('index.minimum_word_size', 1)->set('index.overlap_cjk', TRUE)->save();
     $this->refreshVariables();
     // Create a string of CJK characters from various character ranges in
     // the Unicode tables.
     // Beginnings of the character ranges.
     $starts = array('CJK unified' => 0x4e00, 'CJK Ext A' => 0x3400, 'CJK Compat' => 0xf900, 'Hangul Jamo' => 0x1100, 'Hangul Ext A' => 0xa960, 'Hangul Ext B' => 0xd7b0, 'Hangul Compat' => 0x3131, 'Half non-punct 1' => 0xff21, 'Half non-punct 2' => 0xff41, 'Half non-punct 3' => 0xff66, 'Hangul Syllables' => 0xac00, 'Hiragana' => 0x3040, 'Katakana' => 0x30a1, 'Katakana Ext' => 0x31f0, 'CJK Reserve 1' => 0x20000, 'CJK Reserve 2' => 0x30000, 'Bomofo' => 0x3100, 'Bomofo Ext' => 0x31a0, 'Lisu' => 0xa4d0, 'Yi' => 0xa000);
     // Ends of the character ranges.
     $ends = array('CJK unified' => 0x9fcf, 'CJK Ext A' => 0x4dbf, 'CJK Compat' => 0xfaff, 'Hangul Jamo' => 0x11ff, 'Hangul Ext A' => 0xa97f, 'Hangul Ext B' => 0xd7ff, 'Hangul Compat' => 0x318e, 'Half non-punct 1' => 0xff3a, 'Half non-punct 2' => 0xff5a, 'Half non-punct 3' => 0xffdc, 'Hangul Syllables' => 0xd7af, 'Hiragana' => 0x309f, 'Katakana' => 0x30ff, 'Katakana Ext' => 0x31ff, 'CJK Reserve 1' => 0x2fffd, 'CJK Reserve 2' => 0x3fffd, 'Bomofo' => 0x312f, 'Bomofo Ext' => 0x31b7, 'Lisu' => 0xa4fd, 'Yi' => 0xa48f);
     // Generate characters consisting of starts, midpoints, and ends.
     $chars = array();
     $charcodes = array();
     foreach ($starts as $key => $value) {
         $charcodes[] = $starts[$key];
         $chars[] = $this->code2utf($starts[$key]);
         $mid = round(0.5 * ($starts[$key] + $ends[$key]));
         $charcodes[] = $mid;
         $chars[] = $this->code2utf($mid);
         $charcodes[] = $ends[$key];
         $chars[] = $this->code2utf($ends[$key]);
     }
     // Merge into a string and tokenize.
     $string = implode('', $chars);
     $out = trim(search_simplify($string));
     $expected = Unicode::strtolower(implode(' ', $chars));
     // Verify that the output matches what we expect.
     $this->assertEqual($out, $expected, 'CJK tokenizer worked on all supplied CJK characters');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:39,代码来源:SearchTokenizerTest.php


示例19: handleAutocomplete

 /**
  * Autocomplete the label of an entity.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request object that contains the typed tags.
  * @param string $target_type
  *   The ID of the target entity type.
  * @param string $selection_handler
  *   The plugin ID of the entity reference selection handler.
  * @param string $selection_settings_key
  *   The hashed key of the key/value entry that holds the selection handler
  *   settings.
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  *   The matched entity labels as a JSON response.
  *
  * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
  *   Thrown if the selection settings key is not found in the key/value store
  *   or if it does not match the stored data.
  */
 public function handleAutocomplete(Request $request, $target_type, $selection_handler, $selection_settin 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Utility\UrlHelper类代码示例发布时间:2022-05-23
下一篇:
PHP Utility\String类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap