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

PHP filter_formats函数代码示例

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

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



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

示例1: testTextFormatCrud

 /**
  * Tests CRUD operations for text formats and filters.
  */
 function testTextFormatCrud()
 {
     // Add a text format with minimum data only.
     $format = FilterFormat::create(array('format' => 'empty_format', 'name' => 'Empty format'));
     $format->save();
     $this->verifyTextFormat($format);
     // Add another text format specifying all possible properties.
     $format = FilterFormat::create(array('format' => 'custom_format', 'name' => 'Custom format'));
     $format->setFilterConfig('filter_url', array('status' => 1, 'settings' => array('filter_url_length' => 30)));
     $format->save();
     $this->verifyTextFormat($format);
     // Alter some text format properties and save again.
     $format->set('name', 'Altered format');
     $format->setFilterConfig('filter_url', array('status' => 0));
     $format->setFilterConfig('filter_autop', array('status' => 1));
     $format->save();
     $this->verifyTextFormat($format);
     // Add a filter_test_replace  filter and save again.
     $format->setFilterConfig('filter_test_replace', array('status' => 1));
     $format->save();
     $this->verifyTextFormat($format);
     // Disable the text format.
     $format->disable()->save();
     $formats = filter_formats();
     $this->assertTrue(!isset($formats[$format->id()]), 'filter_formats: Disabled text format no longer exists.');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:29,代码来源:FilterCrudTest.php


示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     // Enable user signatures.
     \Drupal::config('user.settings')->set('signatures', 1)->save();
     // Create Basic page node type.
     $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
     // Add a comment field with commenting enabled by default.
     $this->container->get('comment.manager')->addDefaultField('node', 'page');
     // Prefetch and create text formats.
     $this->filtered_html_format = entity_create('filter_format', array('format' => 'filtered_html_format', 'name' => 'Filtered HTML', 'weight' => -1, 'filters' => array('filter_html' => array('module' => 'filter', 'status' => TRUE, 'settings' => array('allowed_html' => '<a> <em> <strong>')))));
     $this->filtered_html_format->save();
     $this->full_html_format = entity_create('filter_format', array('format' => 'full_html', 'name' => 'Full HTML'));
     $this->full_html_format->save();
     user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array($this->filtered_html_format->getPermissionName()));
     // Create regular and administrative users.
     $this->web_user = $this->drupalCreateUser(array('post comments'));
     $admin_permissions = array('post comments', 'administer comments', 'administer user form display', 'administer account settings');
     foreach (filter_formats() as $format) {
         if ($permission = $format->getPermissionName()) {
             $admin_permissions[] = $permission;
         }
     }
     $this->admin_user = $this->drupalCreateUser($admin_permissions);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:25,代码来源:UserSignatureTest.php


示例3: getSettableOptions

 /**
  * {@inheritdoc}
  */
 public function getSettableOptions(AccountInterface $account = NULL)
 {
     // @todo: Avoid calling functions but move to injected dependencies.
     return array_map(function ($format) {
         return $format->label();
     }, filter_formats($account));
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:10,代码来源:FilterFormat.php


示例4: createTerm

 /**
  * Returns a new term with random properties in vocabulary $vid.
  *
  * @param \Drupal\taxonomy\Entity\Vocabulary $vocabulary
  *   The vocabulary object.
  * @param array $values
  *   (optional) An array of values to set, keyed by property name. If the
  *   entity type has bundles, the bundle key has to be specified.
  *
  * @return \Drupal\taxonomy\Entity\Term
  *   The new taxonomy term object.
  */
 function createTerm(Vocabulary $vocabulary, $values = array())
 {
     $filter_formats = filter_formats();
     $format = array_pop($filter_formats);
     $term = Term::create($values + ['name' => $this->randomMachineName(), 'description' => ['value' => $this->randomMachineName(), 'format' => $format->id()], 'vid' => $vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]);
     $term->save();
     return $term;
 }
开发者ID:318io,项目名称:318-io,代码行数:20,代码来源:TaxonomyTestTrait.php


示例5: getFormat

 /**
  * Get a text format object given its machine name.
  *
  * @param string $format_name
  *    Text format machine name.
  * @param bool $reset
  *    TRUE to reset filter formats cache.
  *
  * @return object|bool
  *    Text format object or FALSE.
  */
 public function getFormat($format_name, $reset = FALSE)
 {
     if ($reset) {
         filter_formats_reset();
     }
     $formats = filter_formats();
     return isset($formats[$format_name]) ? (object) $formats[$format_name] : FALSE;
 }
开发者ID:janoka,项目名称:platform-dev,代码行数:19,代码来源:Config.php


示例6: createTerm

 /**
  * Returns a new term with random properties in vocabulary $vid.
  *
  * @return \Drupal\taxonomy\Term
  *   The created taxonomy term.
  */
 protected function createTerm()
 {
     $filter_formats = filter_formats();
     $format = array_pop($filter_formats);
     $term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'format' => $format->format, 'vid' => $this->vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $term->save();
     return $term;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:14,代码来源:TaxonomyTestBase.php


示例7: buildConfigurationForm

 public function buildConfigurationForm(array &$form, array &$form_state)
 {
     global $user;
     $options = array();
     foreach (filter_formats($user) as $id => $format) {
         $options[$id] = $format->label();
     }
     $form['format'] = array('#type' => 'select', '#title' => $this->t('Description format'), '#options' => $options, '#default_value' => $this->configuration['format']);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:9,代码来源:TaxonomyTermHandler.php


示例8: buildConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $options = [];
     foreach (filter_formats($this->user) as $id => $format) {
         $options[$id] = $format->label();
     }
     $form['format'] = ['#type' => 'select', '#title' => $this->t('Filter format'), '#options' => $options, '#default_value' => $this->configuration['format']];
     return $form;
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:12,代码来源:Text.php


示例9: findDependencies

 /**
  * Overrides Drupal\configuration\Config\Configuration::findDependencies().
  */
 public function findDependencies()
 {
     $format = $this->getIdentifier();
     $formats = filter_formats();
     if (isset($formats[$format])) {
         $filter_format = ConfigurationManagement::createConfigurationInstance('text_format.' . $format);
         $this->addToDependencies($filter_format);
     }
     parent::findDependencies();
 }
开发者ID:gnulugtn,项目名称:portal,代码行数:13,代码来源:WysiwygConfiguration.php


示例10: getAttachments

 /**
  * Implements QuickEditInPlaceEditorInterface::getAttachments().
  *
  * @see Drupal 8's \Drupal\editor\Plugin\quickedit\editor\Editor::getAttachments().
  */
 public function getAttachments()
 {
     global $user;
     // Get a list of formats to which the current user has access.
     $formats = filter_formats($user);
     // Get filter configuration information for the available formats.
     $settings = editor_get_attached($formats);
     // Also include editor.module's formatted text editor.
     $settings['library'][] = array('editor', 'quickedit.inPlaceEditor.formattedText');
     $settings['js'][] = array('type' => 'setting', 'data' => array('quickedit' => array('ckeditor' => array('basePath' => base_path() . drupal_get_path('module', 'editor_ckeditor') . '/lib/ckeditor/'))));
     return $settings;
 }
开发者ID:drupalicus,项目名称:drupal-commons,代码行数:17,代码来源:CKEditor.php


示例11: bootstrap_subtheme_filter_tips

/**
 * Overrides theme_filter_tips().
 */
function bootstrap_subtheme_filter_tips($variables)
{
    global $user;
    drupal_set_title('');
    // Create a place holder for the tabs.
    $build['tabs'] = array('#theme' => 'item_list', '#items' => array(), '#attributes' => array('class' => array('nav', 'nav-tabs'), 'role' => 'tablist'));
    // Create a placeholder for the panes.
    $build['panes'] = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-content')));
    $format_id = arg(2);
    $current_path = current_path();
    $formats = filter_formats($user);
    $filter_info = filter_get_filters();
    foreach ($formats as $format) {
        $tab = array('data' => array('#type' => 'link', '#title' => check_plain($format->name), '#href' => $current_path, '#attributes' => array('role' => 'tab', 'data-toggle' => 'tab'), '#options' => array('fragment' => $format->format)));
        if (!$format_id || $format_id === $format->format) {
            $tab['class'][] = 'active';
            $format_id = $format->format;
        }
        $build['tabs']['#items'][] = $tab;
        // Retrieve each filter in the format.
        $tips = array();
        $filters = filter_list_format($format->format);
        foreach ($filters as $name => $filter) {
            if ($filter->status && isset($filter_info[$name]['tips callback']) && is_callable($filter_info[$name]['tips callback'])) {
                $tip = $filter_info[$name]['tips callback']($filter, $format, TRUE);
                if (isset($tip)) {
                    $tips[] = $tip;
                }
            }
        }
        // Construct the pane.
        $pane = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-pane', 'fade'), 'id' => $format->format));
        if (count($tips) === 1) {
            $pane['list'] = array('#markup' => $tips[0]);
        } else {
            $pane['list'] = array('#theme' => 'item_list', '#items' => $tips);
        }
        if ($format_id === $format->format) {
            $pane['#attributes']['class'][] = 'active';
            $pane['#attributes']['class'][] = 'in';
            $format_id = $format->format;
        }
        $build['panes'][] = $pane;
    }
    return drupal_render($build);
}
开发者ID:unicorn-fail,项目名称:commonmark.unicorn.fail,代码行数:49,代码来源:filter-tips.func.php


示例12: mass_add_terms

 /**
  * Helper function for mass adding of terms.
  *
  * @param $input
  *   The textual input with terms. Each line contains a single term. Child term
  *   can be prefixed with a dash '-' (one dash for each level). Term names
  *   starting with a dash and should not become a child term need to be wrapped
  *   in quotes.
  * @param $vid
  *   The vocabulary id.
  * @param int $parents
  *   An array of parent term ids for the new inserted terms. Can be 0.
  * @param $term_names_too_long
  *   Return value that is used to indicate that some term names were too long
  *   and truncated to 255 characters.
  *
  * @return An array of the newly inserted term objects
  */
 public static function mass_add_terms($input, $vid, $parents, &$term_names_too_long = array())
 {
     $new_terms = array();
     $terms = explode("\n", str_replace("\r", '', $input));
     $parents = count($parents) ? $parents : 0;
     // Stores the current lineage of newly inserted terms.
     $last_parents = array();
     foreach ($terms as $name) {
         if (empty($name)) {
             continue;
         }
         $matches = array();
         // Child term prefixed with one or more dashes
         if (preg_match('/^(-){1,}/', $name, $matches)) {
             $depth = strlen($matches[0]);
             $name = substr($name, $depth);
             $current_parents = isset($last_parents[$depth - 1]) ? array($last_parents[$depth - 1]->id()) : 0;
         } elseif (preg_match('/^\\"(-){1,}.*\\"/', $name, $matches)) {
             $name = substr($name, 1, -1);
             $depth = 0;
             $current_parents = $parents;
         } else {
             $depth = 0;
             $current_parents = $parents;
         }
         // Truncate long string names that will cause database exceptions.
         if (strlen($name) > 255) {
             $term_names_too_long[] = $name;
             $name = substr($name, 0, 255);
         }
         $filter_formats = filter_formats();
         $format = array_pop($filter_formats);
         $values = ['name' => $name, 'format' => $format->id(), 'vid' => $vid, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED];
         if (!empty($current_parents)) {
             foreach ($current_parents as $p) {
                 $values['parent'][] = array('target_id' => $p);
             }
         }
         $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->create($values);
         $term->save();
         $new_terms[] = $term;
         $last_parents[$depth] = $term;
     }
     return $new_terms;
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:63,代码来源:TaxonomyManagerHelper.php


示例13: createTerm

  /**
   * Creates and saves a new term with in vocabulary $vid.
   *
   * @param \Drupal\taxonomy\Entity\Vocabulary $vocabulary
   *   The vocabulary object.
   * @param array $values
   *   (optional) An array of values to set, keyed by property name. If the
   *   entity type has bundles, the bundle key has to be specified.
   *
   * @return \Drupal\taxonomy\Entity\Term
   *   The new taxonomy term object.
   */
  private function createTerm(Vocabulary $vocabulary, $values = array()) {
    $filter_formats = filter_formats();
    $format = array_pop($filter_formats);

    $termStorage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
    $term = $termStorage->create($values + array(
        'name' => $this->randomMachineName(),
        'description' => array(
          'value' => $this->randomMachineName(),
          // Use the first available text format.
          'format' => $format->id(),
        ),
        'vid' => $vocabulary->id(),
        'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
      ));
    $term->save();
    return $term;
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:30,代码来源:TermMatcherTest.php


示例14: createTerm

 /**
  * @param $contentTypes
  * @param $limit
  * @param $titleWords
  * @param $timeRange
  *
  * @return array
  */
 public function createTerm($vocabularies, $limit, $nameWords)
 {
     $terms = [];
     $values = [];
     for ($i = 0; $i < $limit; $i++) {
         $vocabulary = Vocabulary::load($vocabularies[array_rand($vocabularies)]);
         $filter_formats = filter_formats();
         $format = array_pop($filter_formats);
         $term = entity_create('taxonomy_term', $values + array('name' => $this->getRandom()->sentences(mt_rand(1, $nameWords), true), 'description' => array('value' => $this->getRandom()->sentences(), 'format' => $format->id()), 'vid' => $vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
         try {
             $term->save();
             $terms['success'][] = ['tid' => $term->id(), 'vocabulary' => $vocabulary->get('name'), 'name' => $term->getName()];
         } catch (\Exception $error) {
             $terms['error'][] = ['vocabulary' => $vocabularies[$vocabulary], 'name' => $term->getName(), 'error' => $error->getMessage()];
         }
     }
     return $terms;
 }
开发者ID:vielsoft,项目名称:DrupalConsole,代码行数:26,代码来源:Terms.php


示例15: alterDependencies

 /**
  * Overrides Drupal\configuration\Config\Configuration::alterDependencies().
  */
 public static function alterDependencies(Configuration $config)
 {
     if ($config->getComponent() == 'permission') {
         // Generate permissions for each text format. Warn the administrator that any
         // of them are potentially unsafe.
         foreach (filter_formats() as $format) {
             $permission = filter_permission_name($format);
             if (!empty($permission)) {
                 $data = $config->getData();
                 if ($permission == $data['permission']) {
                     $text_format = ConfigurationManagement::createConfigurationInstance('text_format.' . $format->format);
                     $config->addToDependencies($text_format);
                     break;
                 }
             }
         }
     }
 }
开发者ID:gnulugtn,项目名称:portal,代码行数:21,代码来源:TextFormatConfiguration.php


示例16: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $medium_editor = $this->getEntity();
     // Check duplication
     if ($this->getOperation() === 'duplicate') {
         $medium_editor = $medium_editor->createDuplicate();
         $medium_editor->set('label', $this->t('Duplicate of !label', array('!label' => $medium_editor->label())));
         $this->setEntity($medium_editor);
     }
     // Label
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Name'), '#default_value' => $medium_editor->label(), '#maxlength' => 64, '#required' => TRUE);
     // Id
     $form['id'] = array('#type' => 'machine_name', '#machine_name' => array('exists' => array(get_class($medium_editor), 'load'), 'source' => array('label')), '#default_value' => $medium_editor->id(), '#maxlength' => 32, '#required' => TRUE);
     // Description
     $form['description'] = array('#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $medium_editor->get('description'));
     // Delay
     $form['delay'] = array('#type' => 'textfield', '#title' => $this->t('Delay'), '#default_value' => $medium_editor->get('delay'));
     // Diffleft
     $form['diffleft'] = array('#type' => 'textfield', '#title' => $this->t('Diffleft'), '#default_value' => $medium_editor->get('diffleft'));
     // Diffright
     $form['difftop'] = array('#type' => 'textfield', '#title' => $this->t('Difftop'), '#default_value' => $medium_editor->get('difftop'));
     // Settings
     $form['settings'] = array('#tree' => TRUE);
     $widget_libraries = $widget['libraries'];
     unset($widget['libraries']);
     $form['settings']['toolbar_config'] = array('#type' => 'fieldset', '#title' => $this->t('Toolbar configuration'), '#attached' => array('library' => $widget_libraries, 'drupalSettings' => array('medium' => array('twSettings' => $widget))));
     $form['settings']['toolbar_config']['toolbar'] = array('#type' => 'textfield', '#title' => $this->t('Active toolbar'), '#default_value' => implode(', ', $medium_editor->getToolbar()), '#attributes' => array('class' => array('medium-toolbar-input')), '#maxlength' => NULL, '#parents' => array('settings', 'toolbar'));
     // Add demo
     if (!$medium_editor->isNew()) {
         $formats = array();
         foreach (filter_formats(\Drupal::currentUser()) as $format) {
             $formats[] = '<option value="' . String::checkPlain($format->id()) . '">' . String::checkPlain($format->label()) . '</option>';
         }
         $form['demo']['#markup'] = '<div class="form-item form-type-textarea medium-demo"><label>' . $this->t('Demo') . '</label><textarea class="form-textarea" cols="40" rows="5"></textarea><div class="form-item form-type-select filter-wrapper"><span class="label">' . $this->t('Text format') . '</span> <select class="filter-list form-select">' . implode('', $formats) . '</select></div></div>';
         $form['demo']['#weight'] = 1000;
         $form['demo']['#attached']['library'] = $medium_editor->getLibraries();
         $form['demo']['#attached']['drupalSettings']['medium']['demoSettings'] = $medium_editor->getJSSettings();
     }
     // Add admin library
     $form['#attached']['library'][] = 'medium/drupal.medium.admin';
     // Allow plugins to add their elements
     \Drupal::service('plugin.manager.medium.plugin')->alterEditorForm($form, $form_state, $medium_editor);
     return parent::form($form, $form_state);
 }
开发者ID:digideskio,项目名称:medium-editor-d8,代码行数:47,代码来源:MediumForm.php


示例17: preprocessVariables

 /**
  * {@inheritdoc}
  */
 public function preprocessVariables(Variables $variables, $hook, array $info)
 {
     /** @var \Drupal\filter\FilterFormatInterface $current_format */
     $current_format = \Drupal::routeMatch()->getParameter('filter_format');
     $current_format_id = $current_format ? $current_format->id() : FALSE;
     // Create a place holder for the tabs.
     $build['tabs'] = ['#theme' => 'item_list__filter_tips__tabs', '#items' => [], '#attributes' => ['class' => ['nav', 'nav-tabs', 'filter-formats'], 'role' => 'tablist']];
     // Create a placeholder for the panes.
     $build['panes'] = ['#theme_wrappers' => ['container__filter_tips__panes'], '#attributes' => ['class' => ['tab-content']]];
     foreach (filter_formats(\Drupal::currentUser()) as $format_id => $format) {
         // Set the current format ID to the first format.
         if (!$current_format_id) {
             $current_format_id = $format_id;
         }
         $tab = ['#type' => 'link', '#title' => $format->label(), '#url' => Url::fromRoute('filter.tips', ['filter_format' => $format_id]), '#attributes' => ['role' => 'tab', 'data-toggle' => 'tab', 'data-target' => "#{$format_id}"]];
         if ($current_format_id === $format_id) {
             $tab['#wrapper_attributes']['class'][] = 'active';
         }
         $build['tabs']['#items'][] = $tab;
         $tips = [];
         // Iterate over each format's enabled filters.
         /** @var \Drupal\filter\Plugin\FilterBase $filter */
         foreach ($format->filters() as $name => $filter) {
             // Ignore filters that are not enabled.
             if (!$filter->status) {
                 continue;
             }
             $tip = $filter->tips(TRUE);
             if (isset($tip)) {
                 $tips[] = ['#markup' => $tip];
             }
         }
         // Construct the pane.
         $pane = ['#theme_wrappers' => ['container__filter_tips'], '#attributes' => ['class' => ['tab-pane', 'fade'], 'id' => $format_id], 'list' => ['#theme' => 'item_list', '#items' => $tips]];
         if ($current_format_id === $format_id) {
             $pane['#attributes']['class'][] = 'active';
             $pane['#attributes']['class'][] = 'in';
         }
         $build['panes'][] = $pane;
     }
     $variables['tips'] = $build;
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:45,代码来源:FilterTips.php


示例18: getAttachments

 /**
  * {@inheritdoc}
  */
 public function getAttachments()
 {
     $user = \Drupal::currentUser();
     $user_format_ids = array_keys(filter_formats($user));
     $manager = \Drupal::service('plugin.manager.editor');
     $definitions = $manager->getDefinitions();
     // Filter the current user's formats to those that support inline editing.
     $formats = array();
     foreach ($user_format_ids as $format_id) {
         if ($editor = editor_load($format_id)) {
             $editor_id = $editor->getEditor();
             if (isset($definitions[$editor_id]['supports_inline_editing']) && $definitions[$editor_id]['supports_inline_editing'] === TRUE) {
                 $formats[] = $format_id;
             }
         }
     }
     // Get the attachments for all text editors that the user might use.
     $attachments = $manager->getAttachments($formats);
     // Also include editor.module's formatted text editor.
     $attachments['library'][] = 'editor/quickedit.inPlaceEditor.formattedText';
     return $attachments;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:25,代码来源:Editor.php


示例19: generateValues

 public function generateValues($object, $instance, $plugin_definition, $form_display_options)
 {
     $object_field = array();
     $settings = $instance->getSettings();
     if (!empty($settings['text_processing'])) {
         $formats = filter_formats();
         $format = array_rand($formats);
     } else {
         $format = filter_fallback_format();
     }
     if (empty($settings['max_length'])) {
         // Textarea handling
         $object_field['value'] = DevelGenerateBase::createContent($format);
         if ($form_display_options['type'] == 'text_textarea_with_summary' && !empty($settings['display_summary'])) {
             $object_field['summary'] = DevelGenerateBase::createContent($format);
         }
     } else {
         // Textfield handling.
         $object_field['value'] = substr(DevelGenerateBase::createGreeking(mt_rand(1, $settings['max_length'] / 6), FALSE), 0, $settings['max_length']);
     }
     $object_field['format'] = $format;
     return $object_field;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:23,代码来源:DevelGenerateFieldText.php


示例20: createTermWithProperties

 /**
  * Creates a taxonomy term with specified name and other properties.
  *
  * @param array $properties
  *   Array of properties and field values to set.
  *
  * @return \Drupal\taxonomy\TermInterface
  *   The created taxonomy term.
  */
 protected function createTermWithProperties($properties)
 {
     // Use the first available text format.
     $filter_formats = filter_formats();
     $format = array_pop($filter_formats);
     $properties += array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'field_foo' => $this->randomMachineName());
     $term = Term::create(['name' => $properties['name'], 'description' => $properties['description'], 'format' => $format->id(), 'vid' => $this->vocabulary->id(), 'langcode' => $properties['langcode']]);
     $term->field_foo->value = $properties['field_foo'];
     $term->save();
     return $term;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:20,代码来源:TaxonomyFieldFilterTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP filter_formats_reset函数代码示例发布时间:2022-05-15
下一篇:
PHP filter_field_list函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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