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


PHP Utility\Unicode类代码示例

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


在下文中一共展示了Unicode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = 'simpletest@example.com';
     $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


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