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


PHP Unicode::ucfirst方法代码示例

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


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

示例1: testMissingModules

 /**
  * Attempts to enable a module with a missing dependency.
  */
 function testMissingModules()
 {
     // Test that the system_dependencies_test module is marked
     // as missing a dependency.
     $this->drupalGet('admin/modules');
     $this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst('_missing_dependency'))), 'A module with missing dependencies is marked as such.');
     $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_dependencies_test][enable]"]');
     $this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:12,代码来源:DependencyTest.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('acquia_connector.settings');
     $identifier = $config->get('identifier');
     $key = $config->get('key');
     $client = \Drupal::service('acquia_connector.client');
     $error = NULL;
     try {
         $data = $client->nspiCall('/agent-migrate-api/subscription/migration/environments', array('identifier' => $identifier), $key);
     } catch (ConnectorException $e) {
         if ($e->isCustomized()) {
             acquia_connector_report_restapi_error($e->getCustomMessage('code'), $e->getCustomMessage());
             return $this->redirect('acquia_connector.settings');
         }
         $error = $this->t('Server error, please submit again.');
     }
     if (!empty($data['result'])) {
         // Response is in $data['result'].
         $result = $data['result'];
         if (!empty($result['is_error'])) {
             $error = $this->t('Server error, unable to retrieve environments for migration');
         } elseif (!empty($result['body']['error'])) {
             $error = $result['body']['error'];
         } elseif (empty($result['body']['environments'])) {
             $error = $this->t('Server error, unable to retrieve environments for migration');
         }
     }
     if ($error) {
         drupal_set_message($error, 'error');
         return $this->redirect('acquia_connector.settings');
     }
     foreach ($result['body']['environments'] as $stage => $env) {
         $result['body']['environments'][$stage]['secret'] = base64_decode($env['secret']);
     }
     $form['envs'] = array('#type' => 'value', '#value' => $result['body']['environments']);
     $envs = array();
     foreach (array_keys($result['body']['environments']) as $env) {
         $envs[$env] = Unicode::ucfirst($env);
     }
     if (count($result['body']['environments']) > 1) {
         $form['environment'] = array('#type' => 'select', '#title' => $this->t('Select environment for migration'), '#options' => $envs, '#description' => $this->t('Select which environment your site should be migrated to. Only environments that are running trunk or branch can be overwritten by migration. Environments running a tag are not included.'));
     } else {
         $form['environment'] = array('#markup' => $this->t('Available environment for migration: %env', array('%env' => array_pop($envs))));
     }
     $form['migrate_files'] = array('#type' => 'checkbox', '#title' => $this->t('Migrate files directory'), '#description' => $this->t('Include files directory and all files in migration. If you are experiencing migration errors it is recommended you do not send the files directory.'), '#default_value' => $config->get('migrate.files'));
     $form['reduce_db_size'] = array('#type' => 'checkbox', '#title' => $this->t('Reduce database export size'), '#description' => $this->t('Reduce the database export size by excluding the data from cache, session, and watchdog tables. If you are experiencing migration errors this is recommended. Table structure will still be exported.'), '#default_value' => 0);
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Migrate'));
     $form['actions']['cancel'] = array('#type' => 'submit', '#value' => $this->t('Cancel'), '#submit' => ['::submitMigrateCancel']);
     return $form;
 }
开发者ID:alexku,项目名称:travisintegrationtest,代码行数:54,代码来源:MigrateForm.php

示例3: testUi

  /**
   * Test File (Field) Paths Pathauto UI.
   */
  public function testUi() {
    // Create a File field.
    $field_name = Unicode::strtolower($this->randomMachineName());
    $this->createFileField($field_name, 'node', $this->contentType);

    // Ensure File (Field) Paths Pathauto settings are present and available.
    $this->drupalGet("admin/structure/types/manage/{$this->contentType}/fields/node.{$this->contentType}.{$field_name}");
    foreach (['path', 'name'] as $field) {
      $this->assertField("third_party_settings[filefield_paths][file_{$field}][options][pathauto]", t('Pathauto checkbox is present in File @field settings.', ['@field' => Unicode::ucfirst($field)]));

      $element = $this->xpath('//input[@name=:name]/@disabled', [':name' => "third_party_settings[filefield_paths][file_{$field}][options][pathauto]"]);
      $this->assert(empty($element), t('Pathauto checkbox is not disabled in File @field settings.', ['@field' => Unicode::ucfirst($field)]));
    }
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:17,代码来源:FileFieldPathsPathautoTest.php

示例4: buildOptionsForm

 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     // Use view mode of display settings.
     if ($this->entityType == 'node' && \Drupal::moduleHandler()->moduleExists('ds_switch_view_mode')) {
         $form['switch_fieldset'] = array('#type' => 'details', '#title' => t('Use view mode of display settings'), '#open' => $this->options['switch_fieldset']['switch']);
         $form['switch_fieldset']['switch'] = array('#type' => 'checkbox', '#title' => t('Use view mode of display settings'), '#default_value' => $this->options['switch_fieldset']['switch'], '#description' => t('Use the alternative view mode selected in the display settings tab.'));
     }
     // Alternating view modes.
     $form['alternating_fieldset'] = array('#type' => 'details', '#title' => t('Alternating view mode'), '#open' => $this->options['alternating_fieldset']['alternating']);
     $form['alternating_fieldset']['alternating'] = array('#type' => 'checkbox', '#title' => t('Use the changing view mode selector'), '#default_value' => $this->options['alternating_fieldset']['alternating']);
     $form['alternating_fieldset']['allpages'] = array('#type' => 'checkbox', '#title' => t('Use this configuration on every page. Otherwhise the default view mode is used as soon you browse away from the first page of this view.'), '#default_value' => isset($this->options['alternating_fieldset']['allpages']) ? $this->options['alternating_fieldset']['allpages'] : FALSE);
     $pager = $this->view->display_handler->getPlugin('pager');
     $limit = $pager->getItemsPerPage();
     if ($limit == 0 || $limit > 20) {
         $form['alternating_fieldset']['disabled'] = array('#markup' => t('This option is disabled because you have unlimited items or listing more than 20 items.'));
         $form['alternating_fieldset']['alternating']['#disabled'] = TRUE;
         $form['alternating_fieldset']['allpages']['#disabled'] = TRUE;
     } else {
         $i = 1;
         $a = 0;
         while ($limit != 0) {
             $form['alternating_fieldset']['item_' . $a] = ['#title' => t('Item @nr', array('@nr' => $i)), '#type' => 'select', '#default_value' => isset($this->options['alternating_fieldset']['item_' . $a]) ? $this->options['alternating_fieldset']['item_' . $a] : 'teaser', '#options' => \Drupal::service('entity_display.repository')->getViewModeOptions($this->entityTypeId)];
             $limit--;
             $a++;
             $i++;
         }
     }
     // Grouping rows
     $sorts = $this->view->display_handler->getOption('sorts');
     $groupable = !empty($sorts) && $this->options['grouping_fieldset']['group'];
     $form['grouping_fieldset'] = array('#type' => 'details', '#title' => t('Group data'), '#open' => $groupable);
     $form['grouping_fieldset']['group'] = array('#type' => 'checkbox', '#title' => t('Group data on a field. The value of this field will be displayed too.'), '#default_value' => $groupable);
     if (!empty($sorts)) {
         $sort_options = array();
         foreach ($sorts as $sort) {
             $sort_name = Unicode::ucfirst($sort['field']);
             $sort_options[$sort['table'] . '|' . $sort['field']] = $sort_name;
         }
         $form['grouping_fieldset']['group_field'] = array('#type' => 'select', '#options' => $sort_options, '#default_value' => isset($this->options['grouping_fieldset']['group_field']) ? $this->options['grouping_fieldset']['group_field'] : '');
         $form['grouping_fieldset']['group_field_function'] = array('#type' => 'textfield', '#title' => 'Heading function', '#description' => Html::escape(t('The value of the field can be in a very raw format (eg, date created). Enter a custom function which you can use to format that value. The value and the object will be passed into that function eg. custom_function($raw_value, $object);')), '#default_value' => isset($this->options['grouping_fieldset']['group_field_function']) ? $this->options['grouping_fieldset']['group_field_function'] : '');
     } else {
         $form['grouping_fieldset']['group']['#disabled'] = TRUE;
         $form['grouping_fieldset']['group']['#description'] = t('Grouping is disabled because you do not have any sort fields.');
     }
     // Advanced function.
     $form['advanced_fieldset'] = array('#type' => 'details', '#title' => t('Advanced view mode'), '#open' => $this->options['advanced_fieldset']['advanced']);
     $form['advanced_fieldset']['advanced'] = array('#type' => 'checkbox', '#title' => t('Use the advanced view mode selector'), '#description' => t('This gives you the opportunity to have full control of a list for really advanced features.<br /> There is no UI for this, you need to create a hook named like this: hook_ds_views_row_render_entity($entity, $view_mode).', array('@VIEWSNAME' => $this->view->storage->id())), '#default_value' => $this->options['advanced_fieldset']['advanced']);
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:52,代码来源:EntityRow.php

示例5: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumbs = parent::build($route_match);
     $request = \Drupal::request();
     $path = trim($this->context->getPathInfo(), '/');
     $path_elements = explode('/', $path);
     $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
     if ($route && !\Drupal::service('router.admin_context')->isAdminRoute()) {
         $title = \Drupal::service('title_resolver')->getTitle($request, $route);
         if (!isset($title)) {
             // Fallback to using the raw path component as the title if the
             // route is missing a _title or _title_callback attribute.
             $title = str_replace(array('-', '_'), ' ', Unicode::ucfirst(end($path_elements)));
         }
         $breadcrumbs->addLink(Link::createFromRoute($title, '<none>'));
     }
     return $breadcrumbs;
 }
开发者ID:Greg-Boggs,项目名称:current_page_crumb,代码行数:21,代码来源:BreadcrumbBuilder.php

示例6: addDefaultCommentField

 /**
  * Adds the default comment field to an entity.
  *
  * Attaches a comment field named 'comment' to the given entity type and
  * bundle. Largely replicates the default behavior in Drupal 7 and earlier.
  *
  * @param string $entity_type
  *   The entity type to attach the default comment field to.
  * @param string $bundle
  *   The bundle to attach the default comment field to.
  * @param string $field_name
  *   (optional) Field name to use for the comment field. Defaults to
  *     'comment'.
  * @param int $default_value
  *   (optional) Default value, one of CommentItemInterface::HIDDEN,
  *   CommentItemInterface::OPEN, CommentItemInterface::CLOSED. Defaults to
  *   CommentItemInterface::OPEN.
  * @param string $comment_type_id
  *   (optional) ID of comment type to use. Defaults to 'comment'.
  */
 public function addDefaultCommentField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN, $comment_type_id = 'comment')
 {
     $entity_manager = \Drupal::entityManager();
     // Create the comment type if needed.
     $comment_type_storage = $entity_manager->getStorage('comment_type');
     if ($comment_type = $comment_type_storage->load($comment_type_id)) {
         if ($comment_type->getTargetEntityTypeId() !== $entity_type) {
             throw new \InvalidArgumentException(String::format('The given comment type id %id can only be used with the %entity_type entity type', array('%id' => $comment_type_id, '%entity_type' => $entity_type)));
         }
     } else {
         $comment_type_storage->create(array('id' => $comment_type_id, 'label' => Unicode::ucfirst($comment_type_id), 'target_entity_type_id' => $entity_type, 'description' => 'Default comment field'))->save();
     }
     // Add a body field to the comment type.
     \Drupal::service('comment.manager')->addBodyField($comment_type_id);
     // Add a comment field to the host entity type. Create the field storage if
     // needed.
     if (!array_key_exists($field_name, $entity_manager->getFieldStorageDefinitions($entity_type))) {
         $entity_manager->getStorage('field_storage_config')->create(array('entity_type' => $entity_type, 'field_name' => $field_name, 'type' => 'comment', 'translatable' => TRUE, 'settings' => array('comment_type' => $comment_type_id)))->save();
     }
     // Create the field if needed, and configure its form and view displays.
     if (!array_key_exists($field_name, $entity_manager->getFieldDefinitions($entity_type, $bundle))) {
         $entity_manager->getStorage('field_config')->create(array('label' => 'Comments', 'description' => '', 'field_name' => $field_name, 'entity_type' => $entity_type, 'bundle' => $bundle, 'required' => 1, 'default_value' => array(array('status' => $default_value, 'cid' => 0, 'last_comment_name' => '', 'last_comment_timestamp' => 0, 'last_comment_uid' => 0))))->save();
         // Entity form displays: assign widget settings for the 'default' form
         // mode, and hide the field in all other form modes.
         entity_get_form_display($entity_type, $bundle, 'default')->setComponent($field_name, array('type' => 'comment_default', 'weight' => 20))->save();
         foreach ($entity_manager->getFormModes($entity_type) as $id => $form_mode) {
             $display = entity_get_form_display($entity_type, $bundle, $id);
             // Only update existing displays.
             if ($display && !$display->isNew()) {
                 $display->removeComponent($field_name)->save();
             }
         }
         // Entity view displays: assign widget settings for the 'default' view
         // mode, and hide the field in all other view modes.
         entity_get_display($entity_type, $bundle, 'default')->setComponent($field_name, array('label' => 'above', 'type' => 'comment_default', 'weight' => 20))->save();
         foreach ($entity_manager->getViewModes($entity_type) as $id => $view_mode) {
             $display = entity_get_display($entity_type, $bundle, $id);
             // Only update existing displays.
             if ($display && !$display->isNew()) {
                 $display->removeComponent($field_name)->save();
             }
         }
     }
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:64,代码来源:CommentTestTrait.php

示例7: caseTransform

 /**
  * Transform a string by a certain method.
  *
  * @param $string
  *    The input you want to transform.
  * @param $option
  *    How do you want to transform it, possible values:
  *      - upper: Uppercase the string.
  *      - lower: lowercase the string.
  *      - ucfirst: Make the first char uppercase.
  *      - ucwords: Make each word in the string uppercase.
  *
  * @return string
  *    The transformed string.
  */
 protected function caseTransform($string, $option)
 {
     switch ($option) {
         default:
             return $string;
         case 'upper':
             return Unicode::strtoupper($string);
         case 'lower':
             return Unicode::strtolower($string);
         case 'ucfirst':
             return Unicode::ucfirst($string);
         case 'ucwords':
             return Unicode::ucwords($string);
     }
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:30,代码来源:HandlerBase.php

示例8: buildRow

 /**
  * Builds a table row for the system modules page.
  *
  * @param array $modules
  *   The list existing modules.
  * @param \Drupal\Core\Extension\Extension $module
  *   The module for which to build the form row.
  * @param $distribution
  *
  * @return array
  *   The form row for the given module.
  */
 protected function buildRow(array $modules, Extension $module, $distribution)
 {
     // Set the basic properties.
     $row['#required'] = array();
     $row['#requires'] = array();
     $row['#required_by'] = array();
     $row['name']['#markup'] = $module->info['name'];
     $row['description']['#markup'] = $this->t($module->info['description']);
     $row['version']['#markup'] = $module->info['version'];
     // Generate link for module's help page, if there is one.
     $row['links']['help'] = array();
     if ($this->moduleHandler->moduleExists('help') && $module->status && in_array($module->getName(), $this->moduleHandler->getImplementations('help'))) {
         if ($this->moduleHandler->invoke($module->getName(), 'help', array('help.page.' . $module->getName(), $this->routeMatch))) {
             $row['links']['help'] = array('#type' => 'link', '#title' => $this->t('Help'), '#url' => Url::fromRoute('help.page', ['name' => $module->getName()]), '#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => $this->t('Help'))));
         }
     }
     // Generate link for module's permission, if the user has access to it.
     $row['links']['permissions'] = array();
     if ($module->status && \Drupal::currentUser()->hasPermission('administer permissions') && in_array($module->getName(), $this->moduleHandler->getImplementations('permission'))) {
         $row['links']['permissions'] = array('#type' => 'link', '#title' => $this->t('Permissions'), '#url' => Url::fromRoute('user.admin_permissions'), '#options' => array('fragment' => 'module-' . $module->getName(), 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => $this->t('Configure permissions'))));
     }
     // Generate link for module's configuration page, if it has one.
     $row['links']['configure'] = array();
     if ($module->status && isset($module->info['configure'])) {
         $route_parameters = isset($module->info['configure_parameters']) ? $module->info['configure_parameters'] : array();
         if ($this->accessManager->checkNamedRoute($module->info['configure'], $route_parameters, $this->currentUser)) {
             $links = $this->menuLinkManager->loadLinksByRoute($module->info['configure']);
             /** @var \Drupal\Core\Menu\MenuLinkInterface $link */
             $link = reset($links);
             // Most configure links have a corresponding menu link, though some just
             // have a route.
             if ($link) {
                 $description = $link->getDescription();
             } else {
                 $request = new Request();
                 $request->attributes->set('_route_name', $module->info['configure']);
                 $route_object = $this->routeProvider->getRouteByName($module->info['configure']);
                 $request->attributes->set('_route', $route_object);
                 $request->attributes->add($route_parameters);
                 $description = $this->titleResolver->getTitle($request, $route_object);
             }
             $row['links']['configure'] = array('#type' => 'link', '#title' => $this->t('Configure'), '#url' => Url::fromRoute($module->info['configure'], $route_parameters), '#options' => array('attributes' => array('class' => array('module-link', 'module-link-configure'), 'title' => $description)));
         }
     }
     // Present a checkbox for installing and indicating the status of a module.
     $row['enable'] = array('#type' => 'checkbox', '#title' => $this->t('Install'), '#default_value' => (bool) $module->status, '#disabled' => (bool) $module->status);
     // Disable the checkbox for required modules.
     if (!empty($module->info['required'])) {
         // Used when displaying modules that are required by the installation profile
         $row['enable']['#disabled'] = TRUE;
         $row['#required_by'][] = $distribution . (!empty($module->info['explanation']) ? ' (' . $module->info['explanation'] . ')' : '');
     }
     // Check the compatibilities.
     $compatible = TRUE;
     // Initialize an empty array of reasons why the module is incompatible. Add
     // each reason as a separate element of the array.
     $reasons = array();
     // Check the core compatibility.
     if ($module->info['core'] != \Drupal::CORE_COMPATIBILITY) {
         $compatible = FALSE;
         $reasons[] = $this->t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => \Drupal::CORE_COMPATIBILITY));
     }
     // Ensure this module is compatible with the currently installed version of PHP.
     if (version_compare(phpversion(), $module->info['php']) < 0) {
         $compatible = FALSE;
         $required = $module->info['php'] . (substr_count($module->info['php'], '.') < 2 ? '.*' : '');
         $reasons[] = $this->t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $required, '!php_version' => phpversion()));
     }
     // If this module is not compatible, disable the checkbox.
     if (!$compatible) {
         $status = implode(' ', $reasons);
         $row['enable']['#disabled'] = TRUE;
         $row['description']['#markup'] = $status;
         $row['#attributes']['class'][] = 'incompatible';
     }
     // If this module requires other modules, add them to the array.
     foreach ($module->requires as $dependency => $version) {
         if (!isset($modules[$dependency])) {
             $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst($dependency)));
             $row['enable']['#disabled'] = TRUE;
         } elseif (empty($modules[$dependency]->hidden)) {
             $name = $modules[$dependency]->info['name'];
             // Disable the module's checkbox if it is incompatible with the
             // dependency's version.
             if ($incompatible_version = drupal_check_incompatibility($version, str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version']))) {
                 $row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> version @version)', array('@module' => $name . $incompatible_version, '@version' => $modules[$dependency]->info['version']));
                 $row['enable']['#disabled'] = TRUE;
             } elseif ($modules[$dependency]->info['core'] != \Drupal::CORE_COMPATIBILITY) {
//.........这里部分代码省略.........
开发者ID:brstde,项目名称:gap1,代码行数:101,代码来源:ModulesListForm.php

示例9: addDefaultField

 /**
  * {@inheritdoc}
  */
 public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN, $comment_type_id = 'comment')
 {
     $comment_type_storage = $this->entityManager->getStorage('comment_type');
     if ($comment_type = $comment_type_storage->load($comment_type_id)) {
         if ($comment_type->getTargetEntityTypeId() !== $entity_type) {
             throw new \InvalidArgumentException(String::format('The given comment type id %id can only be used with the %entity_type entity type', array('%id' => $comment_type_id, '%entity_type' => $entity_type)));
         }
     } else {
         // Silently create the comment-type for the calling code.
         $comment_type_storage->create(array('id' => $comment_type_id, 'label' => Unicode::ucfirst($comment_type_id), 'target_entity_type_id' => $entity_type, 'description' => 'Default comment field'))->save();
     }
     // Make sure the field doesn't already exist.
     if (!FieldStorageConfig::loadByName($entity_type, $field_name)) {
         // Add a default comment field for existing node comments.
         $field_storage = $this->entityManager->getStorage('field_storage_config')->create(array('entity_type' => $entity_type, 'field_name' => $field_name, 'type' => 'comment', 'translatable' => TRUE, 'settings' => array('comment_type' => $comment_type_id)));
         // Create the field.
         $field_storage->save();
     }
     // Make sure the instance doesn't already exist.
     if (!array_key_exists($field_name, $this->entityManager->getFieldDefinitions($entity_type, $bundle))) {
         $field = $this->entityManager->getStorage('field_config')->create(array('label' => 'Comments', 'description' => '', 'field_name' => $field_name, 'entity_type' => $entity_type, 'bundle' => $bundle, 'required' => 1, 'default_value' => array(array('status' => $default_value, 'cid' => 0, 'last_comment_name' => '', 'last_comment_timestamp' => 0, 'last_comment_uid' => 0))));
         $field->save();
         // Assign widget settings for the 'default' form mode.
         entity_get_form_display($entity_type, $bundle, 'default')->setComponent($field_name, array('type' => 'comment_default', 'weight' => 20))->save();
         // The comment field should be hidden in all other form displays.
         foreach ($this->entityManager->getFormModes($entity_type) as $id => $form_mode) {
             $display = entity_get_form_display($entity_type, $bundle, $id);
             // Only update existing displays.
             if ($display && !$display->isNew()) {
                 $display->removeComponent($field_name)->save();
             }
         }
         // Set default to display comment list.
         entity_get_display($entity_type, $bundle, 'default')->setComponent($field_name, array('label' => 'above', 'type' => 'comment_default', 'weight' => 20))->save();
         // The comment field should be hidden in all other view displays.
         foreach ($this->entityManager->getViewModes($entity_type) as $id => $view_mode) {
             $display = entity_get_display($entity_type, $bundle, $id);
             // Only update existing displays.
             if ($display && !$display->isNew()) {
                 $display->removeComponent($field_name)->save();
             }
         }
     }
     $this->addBodyField($comment_type_id);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:48,代码来源:CommentManager.php

示例10: initProcessors

 /**
  * Initializes the local cache for language path processors.
  *
  * @param string $scope
  *   The scope of the processors: "inbound" or "outbound".
  */
 protected function initProcessors($scope)
 {
     $interface = '\\Drupal\\Core\\PathProcessor\\' . Unicode::ucfirst($scope) . 'PathProcessorInterface';
     $this->processors[$scope] = array();
     foreach ($this->languageManager->getLanguageTypes() as $type) {
         foreach ($this->negotiator->getNegotiationMethods($type) as $method_id => $method) {
             if (!isset($this->processors[$scope][$method_id])) {
                 $reflector = new \ReflectionClass($method['class']);
                 if ($reflector->implementsInterface($interface)) {
                     $this->processors[$scope][$method_id] = $this->negotiator->getNegotiationMethodInstance($method_id);
                 }
             }
         }
     }
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:21,代码来源:PathProcessorLanguage.php

示例11: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $links = array();
     // General path-based breadcrumbs. Use the actual request path, prior to
     // resolving path aliases, so the breadcrumb can be defined by simply
     // creating a hierarchy of path aliases.
     $path = trim($this->context->getPathInfo(), '/');
     $path_elements = explode('/', $path);
     $exclude = array();
     // Don't show a link to the front-page path.
     $front = $this->config->get('page.front');
     $exclude[$front] = TRUE;
     // /user is just a redirect, so skip it.
     // @todo Find a better way to deal with /user.
     $exclude['user'] = TRUE;
     while (count($path_elements) > 1) {
         array_pop($path_elements);
         // Copy the path elements for up-casting.
         $route_request = $this->getRequestForPath(implode('/', $path_elements), $exclude);
         if ($route_request) {
             $access = $this->accessManager->checkRequest($route_request, $this->currentUser);
             if ($access) {
                 $title = $this->titleResolver->getTitle($route_request, $route_request->attributes->get(RouteObjectInterface::ROUTE_OBJECT));
             }
             if ($access) {
                 if (!isset($title)) {
                     // Fallback to using the raw path component as the title if the
                     // route is missing a _title or _title_callback attribute.
                     $title = str_replace(array('-', '_'), ' ', Unicode::ucfirst(end($path_elements)));
                 }
                 $links[] = Link::createFromRoute($title, $route_request->attributes->get(RouteObjectInterface::ROUTE_NAME), $route_request->attributes->get('_raw_variables')->all());
             }
         }
     }
     if ($path && $path != $front) {
         // Add the Home link, except for the front page.
         $links[] = Link::createFromRoute($this->t('Home'), '<front>');
     }
     return array_reverse($links);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:43,代码来源:PathBasedBreadcrumbBuilder.php

示例12: mayo_form_system_theme_settings_alter

/**
 * Implements hook_form_system_theme_settings_alter().
 *
 * Custom theme settings
 */
function mayo_form_system_theme_settings_alter(&$form, FormStateInterface $form_state)
{
    global $base_url;
    //Change collapsible fieldsets (now details) to default #open => FALSE.
    $form['theme_settings']['#open'] = FALSE;
    $form['logo']['#open'] = FALSE;
    $form['favicon']['#open'] = FALSE;
    // Add various settings into drupalSettings for the live preview.
    $uri = theme_get_setting('logo.path', 'mayo');
    if (!empty($uri)) {
        $file_url = file_create_url($uri);
        $file_url = str_ireplace($base_url, '', $file_url);
    } else {
        $file_url = '/' . drupal_get_path('theme', 'mayo') . '/logo.svg';
    }
    $js = array('logo_path' => $file_url, 'header_bg_file' => theme_get_setting('header_bg_file', 'mayo'), 'header_bg_alignment' => theme_get_setting('header_bg_alignment', 'mayo'), 'header_watermark' => theme_get_setting('header_watermark', 'mayo'), 'header_border_width' => theme_get_setting('header_border_width', 'mayo'), 'layout_style' => theme_get_setting('layout_style', 'mayo'), 'base_vmargin' => theme_get_setting('base_vmargin', 'mayo'));
    $form['#attached']['drupalSettings']['color'] = $js;
    // Get our plugin system functions.
    require_once drupal_get_path('theme', 'mayo') . '/inc/plugins.inc';
    // We need some getters.
    require_once drupal_get_path('theme', 'mayo') . '/inc/get.inc';
    $path_to_mayo = drupal_get_path('theme', 'mayo');
    // General "alters" use a form id. Settings should not be set here. The only
    // thing useful about this is if you need to alter the form for the running
    // theme and *not* the theme setting.
    // @see http://drupal.org/node/943212
    if (isset($form_id)) {
        return;
    }
    // Get an array of device groups with option values
    $device_group_options = page_layouts_device_group_options('mayo');
    // Unit options
    $unit_options = array('%' => '%', 'px' => 'px', 'em' => 'em');
    // Assign $options for each device group
    foreach ($device_group_options as $device_group => $options) {
        // About here we need to call a custom sort function, this is what we got for now
        sort($options, SORT_STRING);
        foreach ($options as $option) {
            if ($device_group === 'bigscreen') {
                $bigscreen_options[$option] = \Drupal\Component\Utility\Unicode::ucfirst(str_replace('_', ' ', $option));
                // human readable option names for accessibility
            }
            if ($device_group === 'tablet_landscape') {
                $tablet_landscape_options[$option] = \Drupal\Component\Utility\Unicode::ucfirst(str_replace('_', ' ', $option));
            }
            if ($device_group === 'tablet_portrait') {
                $tablet_portrait_options[$option] = \Drupal\Component\Utility\Unicode::ucfirst(str_replace('_', ' ', $option));
            }
            if ($device_group === 'smalltouch_landscape') {
                $smalltouch_landscape_options[$option] = \Drupal\Component\Utility\Unicode::ucfirst(str_replace('_', ' ', $option));
            }
        }
    }
    /* --------------- Font settings -------------- */
    $form['font'] = array('#type' => 'details', '#title' => t('Font settings'), '#open' => FALSE);
    $form['font']['base_font_size'] = array('#type' => 'select', '#title' => t('Base font size'), '#default_value' => theme_get_setting('base_font_size'), '#options' => array('75%' => '75% (=12px)', '81.25%' => '81.25% (=13px)', '87.5%' => '87.5% (=14px)', '93.75%' => '93.75% (=15px)', '100%' => '100% (=16px)', '112.5%' => '112.5% (=18px)'), '#description' => t('To support text size enlargement/reduction, percent ratio based on the browser\'s regular font size (which is mostly 16px) is used.'));
    $form['font']['base_font_family'] = array('#type' => 'select', '#title' => t('Base font family'), '#default_value' => theme_get_setting('base_font_family'), '#options' => array(0 => t('Serif: Georgia, Palatino Linotype, Book Antiqua, URW Palladio L, Baskerville, serif'), 1 => t('Sans-Serif: Verdana, Geneva, Arial, Bitstream Vera Sans, DejaVu Sans, sans-serif'), 2 => t('Custom')), '#description' => t('Font used for most part of the contents.'));
    $form['font']['base_custom_font_family'] = array('#type' => 'textfield', '#title' => t('Custom base font family'), '#default_value' => theme_get_setting('base_custom_font_family'), '#size' => 80, '#description' => t('Enter the base font-family you want to use. No need to start with <b>font-family:</b> and end with <b>;</b>. Just enter comma separated font names.'), '#prefix' => '<div id="base-custom-font-family-wrapper">', '#suffix' => '</div>');
    $form['font']['heading_font_family'] = array('#type' => 'select', '#title' => t('Heading font family (except for the site name and slogan)'), '#default_value' => theme_get_setting('heading_font_family'), '#options' => array(0 => t('Serif: Georgia, Palatino Linotype, Book Antiqua, URW Palladio L, Baskerville, serif'), 1 => t('Sans-Serif: Verdana, Geneva, Arial, Bitstream Vera Sans, DejaVu Sans, sans-serif'), 2 => t('Custom')), '#description' => t('Font used for the headings (h1, h2, h3, h4, h5). Font used for the site name and slogan can not be changed here. If you want to change it, please manually edit style.css in the theme\'s css subdirectory.'));
    $form['font']['heading_custom_font_family'] = array('#type' => 'textfield', '#title' => t('Custom heading font family'), '#default_value' => theme_get_setting('heading_custom_font_family'), '#size' => 80, '#description' => t('Enter the font-family you want to use for the headings. No need to start with <b>font-family:</b> and end with <b>;</b>. Just enter comma separated font names.'), '#prefix' => '<div id="heading-custom-font-family-wrapper">', '#suffix' => '</div>');
    /* --------------- Layout settings -------------- */
    $form['layout'] = array('#type' => 'details', '#title' => t('Layout settings'), '#collapsed' => TRUE, '#collapsible' => TRUE);
    $form['layout']['base_vmargin'] = array('#type' => 'textfield', '#title' => t('Base vertical (top/bottom) margin'), '#default_value' => theme_get_setting('base_vmargin'), '#size' => 12, '#maxlength' => 8, '#description' => t('Specify the base vertical (top/bottom) margin which is vertical spaces between page edge and browser screen in px.'), '#prefix' => '<img src="' . Url::fromUri('base:' . drupal_get_path('theme', 'mayo') . '/images/base-layout.png')->toString() . '" /><br />');
    $form['layout']['page_margin'] = array('#type' => 'textfield', '#title' => t('Page margin'), '#default_value' => theme_get_setting('page_margin'), '#size' => 12, '#maxlength' => 8, '#description' => t('Specify the page margin which is spaces between page edge and contents in px.'));
    $form['layout']['layout_style'] = array('#type' => 'radios', '#title' => t('Layout style'), '#default_value' => theme_get_setting('layout_style'), '#options' => array(1 => t('1. Apply page margin to all (header, footer and main contents).'), 2 => t('2. Apply page margin to main contents only.')), '#description' => '<img src="' . Url::fromUri('base:' . drupal_get_path('theme', 'mayo') . '/images/page-layout.png')->toString() . '" /><br />' . t('When the layout 2 is selected, or header background image is selected, header borders are not drawn to make it look better.'));
    /* --------------- Responsive sidebar layout settings -------------- */
    /* -----------Big screen as in desktop pc monitor------------- */
    $form['layout']['bigscreen'] = array('#type' => 'details', '#title' => t('Big Screen Sidebar layout'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#attributes' => array('class' => array('mayo-layout-form')));
    // Big screen Layout
    $form['layout']['bigscreen']['bigscreen-layout-wrapper'] = array('#type' => 'details', '#title' => t('Choose sidebar layout'));
    // Options
    $form['layout']['bigscreen']['bigscreen-layout-wrapper']['bigscreen_layout'] = array('#type' => 'radios', '#title' => t('<strong>Choose sidebar positions</strong>'), '#default_value' => str_replace('-', '_', theme_get_setting('bigscreen_layout')), '#options' => $bigscreen_options);
    // Sidebars
    $form['layout']['bigscreen']['bigscreen-sidebar-wrapper'] = array('#type' => 'details', '#title' => t('Set sidebar widths'), '#description' => t('<strong>Set the width of each sidebar</strong>'), '#collapsible' => FALSE);
    // Units
    $form['layout']['bigscreen']['bigscreen-sidebar-wrapper']['bigscreen_sidebar_unit'] = array('#type' => 'select', '#title' => t('Unit'), '#default_value' => theme_get_setting('bigscreen_sidebar_unit'), '#options' => $unit_options);
    // Sidebar first
    $form['layout']['bigscreen']['bigscreen-sidebar-wrapper']['bigscreen_sidebar_first'] = array('#type' => 'textfield', '#title' => t('First sidebar'), '#default_value' => Html::escape(theme_get_setting('bigscreen_sidebar_first')), '#size' => 4, '#maxlenght' => 4, '#states' => array('required' => array(array('input[name="bigscreen_layout"]' => array('value' => 'three_col_grail')), array('input[name="bigscreen_layout"]' => array('value' => 'two_sidebars_left')), array('input[name="bigscreen_layout"]' => array('value' => 'two_sidebars_right')))));
    // Sidebar second
    $form['layout']['bigscreen']['bigscreen-sidebar-wrapper']['bigscreen_sidebar_second'] = array('#type' => 'textfield', '#title' => t('Second sidebar'), '#default_value' => Html::escape(theme_get_setting('bigscreen_sidebar_second')), '#size' => 4, '#maxlenght' => 4, '#states' => array('required' => array(array('input[name="bigscreen_layout"]' => array('value' => 'three_col_grail')), array('input[name="bigscreen_layout"]' => array('value' => 'two_sidebars_left')), array('input[name="bigscreen_layout"]' => array('value' => 'two_sidebars_right')))));
    // Page width
    $form['layout']['bigscreen']['bigscreen-width-wrapper'] = array('#type' => 'details', '#title' => t('Set the page width'), '#description' => t('<strong>Set the page width</strong>'));
    // Unit
    $form['layout']['bigscreen']['bigscreen-width-wrapper']['bigscreen_page_unit'] = array('#type' => 'select', '#title' => t('Unit'), '#default_value' => theme_get_setting('bigscreen_page_unit'), '#options' => $unit_options);
    // Width
    $form['layout']['bigscreen']['bigscreen-width-wrapper']['bigscreen_page_width'] = array('#type' => 'textfield', '#title' => t('Page width'), '#default_value' => Html::escape(theme_get_setting('bigscreen_page_width')), '#size' => 4, '#maxlenght' => 4, '#required' => TRUE);
    // Media queries
    $form['layout']['bigscreen']['media-queries-wrapper'] = array('#type' => 'details', '#title' => t('Standard Screen Media Queries'), '#weight' => 1, '#attributes' => array('class' => array('at-media-queries')));
    // Media query
    $form['layout']['bigscreen']['media-queries-wrapper']['bigscreen_media_query'] = array('#type' => 'textfield', '#title' => t('Media query for this layout'), '#default_value' => Html::escape(theme_get_setting('bigscreen_media_query')), '#description' => t('Do not include @media, it\'s included automatically.'), '#size' => 100, '#required' => TRUE);
    /* ****************************************************************************
     *
     * Tablet
     *
     * ************************************************************************** */
//.........这里部分代码省略.........
开发者ID:ludichrislyts,项目名称:Drupal8,代码行数:101,代码来源:theme-settings.php

示例13: testUcfirst

 /**
  * Tests multibyte ucfirst.
  *
  * @dataProvider providerUcfirst
  * @covers ::ucfirst
  */
 public function testUcfirst($text, $expected)
 {
     $this->assertEquals($expected, Unicode::ucfirst($text));
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:10,代码来源:UnicodeTest.php

示例14: applyModifiers

 protected function applyModifiers($string, $modifiers)
 {
     if (!is_null($string) || strlen($string)) {
         if ($modifiers) {
             $original_string = $string;
             $prefix = '';
             $suffix = '';
             if (preg_match('/^(<span[^>]*>)(.*)(<\\/span>)$/i', $string, $matches)) {
                 $prefix = $matches[1];
                 $string = $matches[2];
                 $suffix = $matches[3];
             }
             for ($j = 0; $j < strlen($modifiers); $j++) {
                 switch ($modifiers[$j]) {
                     case 'L':
                         $string = Unicode::strtolower($string);
                         break;
                     case 'U':
                         $string = Unicode::strtoupper($string);
                         break;
                     case 'F':
                         $string = Unicode::ucfirst($string);
                         break;
                     case 'G':
                         if (!empty($string)) {
                             $parts = explode(' ', $string);
                             $string = array();
                             foreach ($parts as $part) {
                                 $string[] = Unicode::ucfirst($part);
                             }
                             $string = implode(' ', $string);
                         }
                         break;
                     case 'T':
                         $string = trim($string);
                         break;
                     case 'S':
                         $string = SafeMarkup::checkPlain($string);
                         break;
                 }
             }
             $string = $prefix . $string . $suffix;
         }
     }
     return $string;
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:46,代码来源:NameFormatParser.php

示例15: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb = new Breadcrumb();
     $links = array();
     // General path-based breadcrumbs. Use the actual request path, prior to
     // resolving path aliases, so the breadcrumb can be defined by simply
     // creating a hierarchy of path aliases.
     $path = trim($this->context->getPathInfo(), '/');
     $path_elements = explode('/', $path);
     $exclude = array();
     // Don't show a link to the front-page path.
     $front = $this->config->get('page.front');
     $exclude[$front] = TRUE;
     // /user is just a redirect, so skip it.
     // @todo Find a better way to deal with /user.
     $exclude['/user'] = TRUE;
     // Because this breadcrumb builder is entirely path-based, vary by the
     // 'url.path' cache context.
     $breadcrumb->addCacheContexts(['url.path']);
     while (count($path_elements) > 1) {
         array_pop($path_elements);
         // Copy the path elements for up-casting.
         $route_request = $this->getRequestForPath('/' . implode('/', $path_elements), $exclude);
         if ($route_request) {
             $route_match = RouteMatch::createFromRequest($route_request);
             $access = $this->accessManager->check($route_match, $this->currentUser, NULL, TRUE);
             // The set of breadcrumb links depends on the access result, so merge
             // the access result's cacheability metadata.
             $breadcrumb = $breadcrumb->addCacheableDependency($access);
             if ($access->isAllowed()) {
                 $title = $this->titleResolver->getTitle($route_request, $route_match->getRouteObject());
                 if (!isset($title)) {
                     // Fallback to using the raw path component as the title if the
                     // route is missing a _title or _title_callback attribute.
                     $title = str_replace(array('-', '_'), ' ', Unicode::ucfirst(end($path_elements)));
                 }
                 $url = Url::fromRouteMatch($route_match);
                 $links[] = new Link($title, $url);
             }
         }
     }
     if ($path && '/' . $path != $front) {
         // Add the Home link, except for the front page.
         $links[] = Link::createFromRoute($this->t('Home'), '<front>');
     }
     return $breadcrumb->setLinks(array_reverse($links));
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:50,代码来源:PathBasedBreadcrumbBuilder.php


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