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


PHP Html::decodeEntities方法代码示例

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


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

示例1: autocomplete

 /**
  * Handles the response for inline entity form autocompletion.
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function autocomplete($entity_type_id, $field_name, $bundle, Request $request)
 {
     $string = $request->query->get('q');
     $fields = $this->entityManager->getFieldDefinitions($entity_type_id, $bundle);
     $widget = $this->entityManager->getStorage('entity_form_display')->load($entity_type_id . '.' . $bundle . '.default')->getComponent($field_name);
     // The path was passed invalid parameters, or the string is empty.
     // strlen() is used instead of empty() since '0' is a valid value.
     if (!isset($fields[$field_name]) || !$widget || !strlen($string)) {
         throw new AccessDeniedHttpException();
     }
     $field = $fields[$field_name];
     $results = array();
     if ($field->getType() == 'entity_reference') {
         /** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler */
         $handler = $this->selectionManager->getSelectionHandler($field);
         $entity_labels = $handler->getReferenceableEntities($string, $widget['settings']['match_operator'], 10);
         foreach ($entity_labels as $bundle => $labels) {
             // Loop through each entity type, and autocomplete with its titles.
             foreach ($labels as $entity_id => $label) {
                 // entityreference has already check_plain-ed the title.
                 $results[] = t('!label (!entity_id)', array('!label' => $label, '!entity_id' => $entity_id));
             }
         }
     }
     $matches = array();
     foreach ($results as $result) {
         // Strip things like starting/trailing white spaces, line breaks and tags.
         $key = preg_replace('/\\s\\s+/', ' ', str_replace("\n", '', trim(Html::decodeEntities(strip_tags($result)))));
         $matches[] = ['value' => $key, 'label' => '<div class="reference-autocomplete">' . $result . '</div>'];
     }
     return new JsonResponse($matches);
 }
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:37,代码来源:AutocompleteController.php

示例2: getLinks

 /**
  * Gets the list of links used by this field.
  *
  * @return array
  *   The links which are used by the render function.
  */
 protected function getLinks()
 {
     $links = array();
     foreach ($this->options['fields'] as $field) {
         if (empty($this->view->field[$field]->last_render_text)) {
             continue;
         }
         $title = $this->view->field[$field]->last_render_text;
         $path = '';
         $url = NULL;
         if (!empty($this->view->field[$field]->options['alter']['path'])) {
             $path = $this->view->field[$field]->options['alter']['path'];
         } elseif (!empty($this->view->field[$field]->options['alter']['url']) && $this->view->field[$field]->options['alter']['url'] instanceof UrlObject) {
             $url = $this->view->field[$field]->options['alter']['url'];
         }
         // Make sure that tokens are replaced for this paths as well.
         $tokens = $this->getRenderTokens(array());
         $path = strip_tags(Html::decodeEntities($this->viewsTokenReplace($path, $tokens)));
         $links[$field] = array('url' => $path ? UrlObject::fromUri('internal:/' . $path) : $url, 'title' => $title);
         if (!empty($this->options['destination'])) {
             $links[$field]['query'] = \Drupal::destination()->getAsArray();
         }
     }
     return $links;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:31,代码来源:Links.php

示例3: process

 /**
  * {@inheritdoc}
  */
 public function process($text, $langcode)
 {
     $result = new FilterProcessResult($text);
     if (stristr($text, 'data-caption') !== FALSE) {
         $dom = Html::load($text);
         $xpath = new \DOMXPath($dom);
         foreach ($xpath->query('//*[@data-caption]') as $node) {
             // Read the data-caption attribute's value, then delete it.
             $caption = Html::escape($node->getAttribute('data-caption'));
             $node->removeAttribute('data-caption');
             // Sanitize caption: decode HTML encoding, limit allowed HTML tags; only
             // allow inline tags that are allowed by default, plus <br>.
             $caption = Html::decodeEntities($caption);
             $caption = FilteredMarkup::create(Xss::filter($caption, array('a', 'em', 'strong', 'cite', 'code', 'br')));
             // The caption must be non-empty.
             if (Unicode::strlen($caption) === 0) {
                 continue;
             }
             // Given the updated node and caption: re-render it with a caption, but
             // bubble up the value of the class attribute of the captioned element,
             // this allows it to collaborate with e.g. the filter_align filter.
             $tag = $node->tagName;
             $classes = $node->getAttribute('class');
             $node->removeAttribute('class');
             $node = $node->parentNode->tagName === 'a' ? $node->parentNode : $node;
             $filter_caption = array('#theme' => 'filter_caption', '#node' => FilteredMarkup::create($node->C14N()), '#tag' => $tag, '#caption' => $caption, '#classes' => $classes);
             $altered_html = drupal_render($filter_caption);
             // Load the altered HTML into a new DOMDocument and retrieve the element.
             $updated_nodes = Html::load($altered_html)->getElementsByTagName('body')->item(0)->childNodes;
             foreach ($updated_nodes as $updated_node) {
                 // Import the updated node from the new DOMDocument into the original
                 // one, importing also the child nodes of the updated node.
                 $updated_node = $dom->importNode($updated_node, TRUE);
                 $node->parentNode->insertBefore($updated_node, $node);
             }
             // Finally, remove the original data-caption node.
             $node->parentNode->removeChild($node);
         }
         $result->setProcessedText(Html::serialize($dom))->addAttachments(array('library' => array('filter/caption')));
     }
     return $result;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:45,代码来源:FilterCaption.php

示例4: getMatches

 /**
  * Returns matched labels based on a given search string.
  *
  * @param string $target_type
  *   The ID of the target entity type.
  * @param string $selection_handler
  *   The plugin ID of the entity reference selection handler.
  * @param array $selection_settings
  *   An array of settings that will be passed to the selection handler.
  * @param string $string
  *   (optional) The label of the entity to query by.
  *
  * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
  *   Thrown when the current user doesn't have access to the specifies entity.
  *
  * @return array
  *   An array of matched entity labels, in the format required by the AJAX
  *   autocomplete API (e.g. array('value' => $value, 'label' => $label)).
  *
  * @see \Drupal\system\Controller\EntityAutocompleteController
  */
 public function getMatches($target_type, $selection_handler, $selection_settings, $string = '')
 {
     $matches = array();
     $options = array('target_type' => $target_type, 'handler' => $selection_handler, 'handler_settings' => $selection_settings);
     $handler = $this->selectionManager->getInstance($options);
     if (isset($string)) {
         // Get an array of matching entities.
         $match_operator = !empty($selection_settings['match_operator']) ? $selection_settings['match_operator'] : 'CONTAINS';
         $entity_labels = $handler->getReferenceableEntities($string, $match_operator, 10);
         // Loop through the entities and convert them into autocomplete output.
         foreach ($entity_labels as $values) {
             foreach ($values as $entity_id => $label) {
                 $key = "{$label} ({$entity_id})";
                 // Strip things like starting/trailing white spaces, line breaks and
                 // tags.
                 $key = preg_replace('/\\s\\s+/', ' ', str_replace("\n", '', trim(Html::decodeEntities(strip_tags($key)))));
                 // Names containing commas or quotes must be wrapped in quotes.
                 $key = Tags::encode($key);
                 $matches[] = array('value' => $key, 'label' => $label);
             }
         }
     }
     return $matches;
 }
开发者ID:brstde,项目名称:gap1,代码行数:45,代码来源:EntityAutocompleteMatcher.php

示例5: getTokenValuesRecursive

 /**
  * Recursive function to add replacements for nested query string parameters.
  *
  * E.g. if you pass in the following array:
  *   array(
  *     'foo' => array(
  *       'a' => 'value',
  *       'b' => 'value',
  *     ),
  *     'bar' => array(
  *       'a' => 'value',
  *       'b' => array(
  *         'c' => value,
  *       ),
  *     ),
  *   );
  *
  * Would yield the following array of tokens:
  *   array(
  *     '%foo_a' => 'value'
  *     '%foo_b' => 'value'
  *     '%bar_a' => 'value'
  *     '%bar_b_c' => 'value'
  *   );
  *
  * @param $array
  *   An array of values.
  *
  * @param $parent_keys
  *   An array of parent keys. This will represent the array depth.
  *
  * @return
  *   An array of available tokens, with nested keys representative of the array structure.
  */
 protected function getTokenValuesRecursive(array $array, array $parent_keys = array())
 {
     $tokens = array();
     foreach ($array as $param => $val) {
         if (is_array($val)) {
             // Copy parent_keys array, so we don't affect other elements of this
             // iteration.
             $child_parent_keys = $parent_keys;
             $child_parent_keys[] = $param;
             // Get the child tokens.
             $child_tokens = $this->getTokenValuesRecursive($val, $child_parent_keys);
             // Add them to the current tokens array.
             $tokens += $child_tokens;
         } else {
             // Create a token key based on array element structure.
             $token_string = !empty($parent_keys) ? implode('_', $parent_keys) . '_' . $param : $param;
             $tokens['%' . $token_string] = strip_tags(Html::decodeEntities($val));
         }
     }
     return $tokens;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:55,代码来源:FieldPluginBase.php

示例6: getAllEvents

 protected function getAllEvents(DrupalStyle $io, $eventType, $eventSeverity, $userId, $asc, $offset, $limit)
 {
     $connection = $this->getDrupalService('database');
     $dateFormatter = $this->getDrupalService('date.formatter');
     $userStorage = $this->getDrupalService('entity_type.manager')->getStorage('user');
     $severity = RfcLogLevel::getLevels();
     $query = $connection->select('watchdog', 'w');
     $query->fields('w', ['wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables']);
     if ($eventType) {
         $query->condition('type', $eventType);
     }
     if ($eventSeverity) {
         if (!in_array($eventSeverity, $severity)) {
             $io->error(sprintf($this->trans('commands.database.log.debug.messages.invalid-severity'), $eventSeverity));
             return false;
         }
         $query->condition('severity', array_search($eventSeverity, $severity));
     }
     if ($userId) {
         $query->condition('uid', $userId);
     }
     if ($asc) {
         $query->orderBy('wid', 'ASC');
     } else {
         $query->orderBy('wid', 'DESC');
     }
     if ($limit) {
         $query->range($offset, $limit);
     }
     $result = $query->execute();
     $tableHeader = [$this->trans('commands.database.log.debug.messages.event-id'), $this->trans('commands.database.log.debug.messages.type'), $this->trans('commands.database.log.debug.messages.date'), $this->trans('commands.database.log.debug.messages.message'), $this->trans('commands.database.log.debug.messages.user'), $this->trans('commands.database.log.debug.messages.severity')];
     $tableRows = [];
     foreach ($result as $dblog) {
         $user = $userStorage->load($dblog->uid);
         $tableRows[] = [$dblog->wid, $dblog->type, $dateFormatter->format($dblog->timestamp, 'short'), Unicode::truncate(Html::decodeEntities(strip_tags($this->formatMessage($dblog))), 56, true, true), $user->getUsername() . ' (' . $user->id() . ')', $severity[$dblog->severity]];
     }
     $io->table($tableHeader, $tableRows);
     return true;
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:39,代码来源:LogDebugCommand.php

示例7: buttonWasClicked

 /**
  * Determines if a given button triggered the form submission.
  *
  * This detects button controls that trigger a form submission by being
  * clicked and having the click processed by the browser rather than being
  * captured by JavaScript. Essentially, it detects if the button's name and
  * value are part of the POST data, but with extra code to deal with the
  * convoluted way in which browsers submit data for image button clicks.
  *
  * This does not detect button clicks processed by Ajax (that is done in
  * self::elementTriggeredScriptedSubmission()) and it does not detect form
  * submissions from Internet Explorer in response to an ENTER key pressed in a
  * textfield (self::doBuildForm() has extra code for that).
  *
  * Because this function contains only part of the logic needed to determine
  * $form_state->getTriggeringElement(), it should not be called from anywhere
  * other than within the Form API. Form validation and submit handlers needing
  * to know which button was clicked should get that information from
  * $form_state->getTriggeringElement().
  */
 protected function buttonWasClicked($element, FormStateInterface &$form_state)
 {
     // First detect normal 'vanilla' button clicks. Traditionally, all standard
     // buttons on a form share the same name (usually 'op'), and the specific
     // return value is used to determine which was clicked. This ONLY works as
     // long as $form['#name'] puts the value at the top level of the tree of
     // \Drupal::request()->request data.
     $input = $form_state->getUserInput();
     // The input value attribute is treated as CDATA by browsers. This means
     // that they replace character entities with characters. Therefore, we need
     // to decode the value in $element['#value']. For more details see
     // http://www.w3.org/TR/html401/types.html#type-cdata.
     if (isset($input[$element['#name']]) && $input[$element['#name']] == Html::decodeEntities($element['#value'])) {
         return TRUE;
     } elseif (!empty($element['#has_garbage_value']) && isset($element['#value']) && $element['#value'] !== '') {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:komejo,项目名称:article-test,代码行数:39,代码来源:FormBuilder.php

示例8: sendPlaceholders

    /**
     * Sends BigPipe placeholders' replacements as embedded AJAX responses.
     *
     * @param array $placeholders
     *   Associative array; the BigPipe placeholders. Keys are the BigPipe
     *   selectors.
     * @param array $placeholder_order
     *   Indexed array; the order in which the BigPipe placeholders must be sent.
     *   Values are the BigPipe selectors. (These values correspond to keys in
     *   $placeholders.)
     * @param \Drupal\Core\Asset\AttachedAssetsInterface $cumulative_assets
     *   The cumulative assets sent so far; to be updated while rendering BigPipe
     *   placeholders.
     */
    protected function sendPlaceholders(array $placeholders, array $placeholder_order, AttachedAssetsInterface $cumulative_assets)
    {
        // Return early if there are no BigPipe placeholders to send.
        if (empty($placeholders)) {
            return;
        }
        // Send a container and the start signal.
        print "\n";
        print '<script type="application/json" data-big-pipe-event="start"></script>' . "\n";
        flush();
        // A BigPipe response consists of a HTML response plus multiple embedded
        // AJAX responses. To process the attachments of those AJAX responses, we
        // need a fake request that is identical to the master request, but with
        // one change: it must have the right Accept header, otherwise the work-
        // around for a bug in IE9 will cause not JSON, but <textarea>-wrapped JSON
        // to be returned.
        // @see \Drupal\Core\EventSubscriber\AjaxResponseSubscriber::onResponse()
        $fake_request = $this->requestStack->getMasterRequest()->duplicate();
        $fake_request->headers->set('Accept', 'application/json');
        foreach ($placeholder_order as $placeholder) {
            if (!isset($placeholders[$placeholder])) {
                continue;
            }
            // Render the placeholder.
            $placeholder_render_array = $placeholders[$placeholder];
            $elements = $this->renderPlaceholder($placeholder, $placeholder_render_array);
            // Create a new AjaxResponse.
            $ajax_response = new AjaxResponse();
            // JavaScript's querySelector automatically decodes HTML entities in
            // attributes, so we must decode the entities of the current BigPipe
            // placeholder (which has HTML entities encoded since we use it to find
            // the placeholders).
            $big_pipe_js_selector = Html::decodeEntities($placeholder);
            $ajax_response->addCommand(new ReplaceCommand(sprintf('[data-big-pipe-selector="%s"]', $big_pipe_js_selector), $elements['#markup']));
            $ajax_response->setAttachments($elements['#attached']);
            // Push a fake request with the asset libraries loaded so far and dispatch
            // KernelEvents::RESPONSE event. This results in the attachments for the
            // AJAX response being processed by AjaxResponseAttachmentsProcessor and
            // hence:
            // - the necessary AJAX commands to load the necessary missing asset
            //   libraries and updated AJAX page state are added to the AJAX response
            // - the attachments associated with the response are finalized, which
            //   allows us to track the total set of asset libraries sent in the
            //   initial HTML response plus all embedded AJAX responses sent so far.
            $fake_request->request->set('ajax_page_state', ['libraries' => implode(',', $cumulative_assets->getAlreadyLoadedLibraries())] + $cumulative_assets->getSettings()['ajaxPageState']);
            $this->requestStack->push($fake_request);
            $event = new FilterResponseEvent($this->httpKernel, $fake_request, HttpKernelInterface::SUB_REQUEST, $ajax_response);
            $this->eventDispatcher->dispatch(KernelEvents::RESPONSE, $event);
            $ajax_response = $event->getResponse();
            $this->requestStack->pop();
            // Send this embedded AJAX response.
            $json = $ajax_response->getContent();
            $output = <<<EOF
    <script type="application/json" data-big-pipe-placeholder="{$placeholder}" data-drupal-ajax-processor="big_pipe">
    {$json}
    </script>
EOF;
            print $output;
            flush();
            // Another placeholder was rendered and sent, track the set of asset
            // libraries sent so far. Any new settings are already sent; we don't need
            // to track those.
            if (isset($ajax_response->getAttachments()['drupalSettings']['ajaxPageState']['libraries'])) {
                $cumulative_assets->setAlreadyLoadedLibraries(explode(',', $ajax_response->getAttachments()['drupalSettings']['ajaxPageState']['libraries']));
            }
        }
        // Send the stop signal.
        print '<script type="application/json" data-big-pipe-event="stop"></script>' . "\n";
        flush();
    }
开发者ID:DrupalTV,项目名称:DrupalTV,代码行数:84,代码来源:BigPipe.php

示例9: assertNoNormalized

 /**
  * Asserts that text transformed to lowercase with HTML entities decoded does not contain a given string.
  *
  * Otherwise fails the test with a given message, similar to all the
  * SimpleTest assert* functions.
  *
  * Note that this does not remove nulls, new lines, and other character that
  * could be used to obscure a tag or an attribute name.
  *
  * @param $haystack
  *   Text to look in.
  * @param $needle
  *   Lowercase, plain text to look for.
  * @param $message
  *   (optional) Message to display if failed. Defaults to an empty string.
  * @param $group
  *   (optional) The group this message belongs to. Defaults to 'Other'.
  *
  * @return bool
  *   TRUE on pass, FALSE on fail.
  */
 function assertNoNormalized($haystack, $needle, $message = '', $group = 'Other')
 {
     return $this->assertTrue(strpos(strtolower(Html::decodeEntities($haystack)), $needle) === FALSE, $message, $group);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:25,代码来源:FilterUnitTest.php

示例10: autocomplete

 /**
  * Menu callback; autocomplete.js callback to return a list of files.
  */
 public static function autocomplete(Request $request, $entity_type, $bundle_name, $field_name)
 {
     $matches = array();
     $string = Unicode::strtolower($request->query->get('q'));
     $field_definition = entity_load('field_config', $entity_type . '.' . $bundle_name . '.' . $field_name);
     $handler = \Drupal::getContainer()->get('plugin.manager.entity_reference_selection')->getSelectionHandler($field_definition);
     if (isset($string)) {
         // Get an array of matching entities.
         $widget = entity_get_form_display($entity_type, $bundle_name, 'default')->getComponent($field_name);
         $autocomplete_type = $widget['third_party_settings']['filefield_sources']['filefield_sources']['source_reference']['autocomplete'];
         $match_operator = !empty($autocomplete_type) ? $autocomplete_type : FILEFIELD_SOURCE_REFERENCE_CONTAINS_AUTOCOMPLETE_TYPE;
         $entity_labels = $handler->getReferenceableEntities($string, $match_operator, 10);
         // Loop through the entities and convert them into autocomplete output.
         foreach ($entity_labels as $values) {
             foreach ($values as $entity_id => $label) {
                 $key = "{$label} [fid:{$entity_id}]";
                 // Strip things like starting/trailing white spaces, line breaks and
                 // tags.
                 $key = preg_replace('/\\s\\s+/', ' ', str_replace("\n", '', trim(Html::decodeEntities(strip_tags($key)))));
                 // Names containing commas or quotes must be wrapped in quotes.
                 $matches[] = array('value' => $key, 'label' => $label);
             }
         }
     }
     return new JsonResponse($matches);
 }
开发者ID:shrimala,项目名称:filefield_sources,代码行数:29,代码来源:Reference.php

示例11: assertLogMessage

 /**
  * Confirms that a log message appears on the database log overview screen.
  *
  * This function should only be used for the admin/reports/dblog page, because
  * it checks for the message link text truncated to 56 characters. Other log
  * pages have no detail links so they contain the full message text.
  *
  * @param string $log_message
  *   The database log message to check.
  * @param string $message
  *   The message to pass to simpletest.
  */
 protected function assertLogMessage($log_message, $message)
 {
     $message_text = Unicode::truncate(Html::decodeEntities(strip_tags($log_message)), 56, TRUE, TRUE);
     $this->assertLink($message_text, 0, $message);
 }
开发者ID:318io,项目名称:318-io,代码行数:17,代码来源:DbLogTest.php

示例12: testAlterUrl

 /**
  * Tests rewriting the output to a link.
  */
 public function testAlterUrl()
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = \Drupal::service('renderer');
     $view = Views::getView('test_view');
     $view->setDisplay();
     $view->initHandlers();
     $this->executeView($view);
     $row = $view->result[0];
     $id_field = $view->field['id'];
     // Setup the general settings required to build a link.
     $id_field->options['alter']['make_link'] = TRUE;
     $id_field->options['alter']['path'] = $path = $this->randomMachineName();
     // Tests that the suffix/prefix appears on the output.
     $id_field->options['alter']['prefix'] = $prefix = $this->randomMachineName();
     $id_field->options['alter']['suffix'] = $suffix = $this->randomMachineName();
     $output = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
         return $id_field->theme($row);
     });
     $this->assertSubString($output, $prefix);
     $this->assertSubString($output, $suffix);
     unset($id_field->options['alter']['prefix']);
     unset($id_field->options['alter']['suffix']);
     $output = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
         return $id_field->theme($row);
     });
     $this->assertSubString($output, $path, 'Make sure that the path is part of the output');
     // Some generic test code adapted from the UrlTest class, which tests
     // mostly the different options for the path.
     foreach (array(FALSE, TRUE) as $absolute) {
         $alter =& $id_field->options['alter'];
         $alter['path'] = 'node/123';
         $expected_result = \Drupal::url('entity.node.canonical', ['node' => '123'], ['absolute' => $absolute]);
         $alter['absolute'] = $absolute;
         $result = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
             return $id_field->theme($row);
         });
         $this->assertSubString($result, $expected_result);
         $expected_result = \Drupal::url('entity.node.canonical', ['node' => '123'], ['fragment' => 'foo', 'absolute' => $absolute]);
         $alter['path'] = 'node/123#foo';
         $result = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
             return $id_field->theme($row);
         });
         $this->assertSubString($result, $expected_result);
         $expected_result = \Drupal::url('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => NULL], 'absolute' => $absolute]);
         $alter['path'] = 'node/123?foo';
         $result = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
             return $id_field->theme($row);
         });
         $this->assertSubString($result, $expected_result);
         $expected_result = \Drupal::url('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => 'bar', 'bar' => 'baz'], 'absolute' => $absolute]);
         $alter['path'] = 'node/123?foo=bar&bar=baz';
         $result = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
             return $id_field->theme($row);
         });
         $this->assertSubString(Html::decodeEntities($result), Html::decodeEntities($expected_result));
         // @todo The route-based URL generator strips out NULL attributes.
         // $expected_result = \Drupal::url('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => NULL], 'fragment' => 'bar', 'absolute' => $absolute]);
         $expected_result = \Drupal::urlGenerator()->generateFromPath('node/123', array('query' => array('foo' => NULL), 'fragment' => 'bar', 'absolute' => $absolute));
         $alter['path'] = 'node/123?foo#bar';
         $result = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
             return $id_field->theme($row);
         });
         $this->assertSubString(Html::decodeEntities($result), Html::decodeEntities($expected_result));
         $expected_result = \Drupal::url('<front>', [], ['absolute' => $absolute]);
         $alter['path'] = '<front>';
         $result = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
             return $id_field->theme($row);
         });
         $this->assertSubString($result, $expected_result);
     }
     // Tests the replace spaces with dashes feature.
     $id_field->options['alter']['replace_spaces'] = TRUE;
     $id_field->options['alter']['path'] = $path = $this->randomMachineName() . ' ' . $this->randomMachineName();
     $output = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
         return $id_field->theme($row);
     });
     $this->assertSubString($output, str_replace(' ', '-', $path));
     $id_field->options['alter']['replace_spaces'] = FALSE;
     $output = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
         return $id_field->theme($row);
     });
     // The url has a space in it, so to check we have to decode the url output.
     $this->assertSubString(urldecode($output), $path);
     // Tests the external flag.
     // Switch on the external flag should output an external url as well.
     $id_field->options['alter']['external'] = TRUE;
     $id_field->options['alter']['path'] = $path = 'www.drupal.org';
     $output = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
         return $id_field->theme($row);
     });
     $this->assertSubString($output, 'http://www.drupal.org');
     // Setup a not external url, which shouldn't lead to an external url.
     $id_field->options['alter']['external'] = FALSE;
     $id_field->options['alter']['path'] = $path = 'www.drupal.org';
     $output = $renderer->executeInRenderContext(new RenderContext(), function () use($id_field, $row) {
         return $id_field->theme($row);
//.........这里部分代码省略.........
开发者ID:nsp15,项目名称:Drupal8,代码行数:101,代码来源:FieldWebTest.php

示例13: normalizeText

 /**
  * Removes superfluous whitespace and unescapes HTML entities.
  *
  * @param string $value
  *   The text to process.
  *
  * @return string
  *   The text without unnecessary whitespace and HTML entities transformed
  *   back to plain text.
  */
 protected function normalizeText($value) {
   $value = Html::decodeEntities($value);
   $value = trim($value);
   $value = preg_replace('/\s+/', ' ', $value);
   return $value;
 }
开发者ID:jkyto,项目名称:agolf,代码行数:16,代码来源:HtmlFilter.php

示例14: sanitizeLabel

 /**
  * {@inheritdoc}
  */
 protected function sanitizeLabel(&$label)
 {
     // Select form inputs allow unencoded HTML entities, but no HTML tags.
     $label = Html::decodeEntities(strip_tags($label));
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:8,代码来源:OptionsSelectWidget.php

示例15: testDecodeEntities

 /**
  * Tests Html::decodeEntities().
  *
  * @dataProvider providerDecodeEntities
  * @covers ::decodeEntities
  */
 public function testDecodeEntities($text, $expected)
 {
     $this->assertEquals($expected, Html::decodeEntities($text));
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:10,代码来源:HtmlTest.php


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