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


PHP Editor::id方法代码示例

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


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

示例1: generateFormatTagsSetting

 /**
  * Builds the "format_tags" configuration part of the CKEditor JS settings.
  *
  * @see getConfig()
  *
  * @param \Drupal\editor\Entity\Editor $editor
  *   A configured text editor object.
  *
  * @return array
  *   An array containing the "format_tags" configuration.
  */
 protected function generateFormatTagsSetting(Editor $editor)
 {
     // When no text format is associated yet, assume no tag is allowed.
     // @see \Drupal\Editor\EditorInterface::hasAssociatedFilterFormat()
     if (!$editor->hasAssociatedFilterFormat()) {
         return array();
     }
     $format = $editor->getFilterFormat();
     $cid = 'ckeditor_internal_format_tags:' . $format->id();
     if ($cached = $this->cache->get($cid)) {
         $format_tags = $cached->data;
     } else {
         // The <p> tag is always allowed — HTML without <p> tags is nonsensical.
         $format_tags = ['p'];
         // Given the list of possible format tags, automatically determine whether
         // the current text format allows this tag, and thus whether it should show
         // up in the "Format" dropdown.
         $possible_format_tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre'];
         foreach ($possible_format_tags as $tag) {
             $input = '<' . $tag . '>TEST</' . $tag . '>';
             $output = trim(check_markup($input, $editor->id()));
             if ($input == $output) {
                 $format_tags[] = $tag;
             }
         }
         $format_tags = implode(';', $format_tags);
         // Cache the "format_tags" configuration. This cache item is infinitely
         // valid; it only changes whenever the text format is changed, hence it's
         // tagged with the text format's cache tag.
         $this->cache->set($cid, $format_tags, Cache::PERMANENT, $format->getCacheTags());
     }
     return $format_tags;
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:44,代码来源:Internal.php


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