protected function doDisplay(array $context, array $blocks = array())
 {
     // line 21
     $context["classes"] = array(0 => "views-ui-display-tab-bucket", 1 => isset($context["name"]) ? $context["name"] : null ? \Drupal\Component\Utility\Html::getClass(isset($context["name"]) ? $context["name"] : null) : "", 2 => isset($context["overridden"]) ? $context["overridden"] : null ? "overridden" : "");
     // line 27
     echo "<div";
     echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["classes"]) ? $context["classes"] : null), "method"), "html", null, true);
     echo ">\n  ";
     // line 28
     if (isset($context["title"]) ? $context["title"] : null) {
         // line 29
         echo "<h3 class=\"views-ui-display-tab-bucket__title\">";
         echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["title"]) ? $context["title"] : null, "html", null, true);
         echo "</h3>";
     }
     // line 31
     echo "  ";
     if (isset($context["actions"]) ? $context["actions"] : null) {
         // line 32
         echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["actions"]) ? $context["actions"] : null, "html", null, true);
     }
     // line 34
     echo "  ";
     echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["content"]) ? $context["content"] : null, "html", null, true);
     echo "\n</div>\n";
 }
 /**
  * Tests tablesort_init().
  */
 function testTableSortInit()
 {
     // Test simple table headers.
     $headers = array('foo', 'bar', 'baz');
     // Reset $request->query to prevent parameters from Simpletest and Batch API
     // ending up in $ts['query'].
     $expected_ts = array('name' => 'foo', 'sql' => '', 'sort' => 'asc', 'query' => array());
     $request = Request::createFromGlobals();
     $request->query->replace(array());
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.');
     // Test with simple table headers plus $_GET parameters that should _not_
     // override the default.
     $request = Request::createFromGlobals();
     $request->query->replace(array('order' => 'bar'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.');
     // Test with simple table headers plus $_GET parameters that _should_
     // override the default.
     $request = Request::createFromGlobals();
     $request->query->replace(array('sort' => 'DESC', 'alpha' => 'beta'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $expected_ts['sort'] = 'desc';
     $expected_ts['query'] = array('alpha' => 'beta');
     $ts = tablesort_init($headers);
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers plus $_GET parameters sorted correctly.');
     // Test complex table headers.
     $headers = array('foo', array('data' => '1', 'field' => 'one', 'sort' => 'asc', 'colspan' => 1), array('data' => '2', 'field' => 'two', 'sort' => 'desc'));
     // Reset $_GET from previous assertion.
     $request = Request::createFromGlobals();
     $request->query->replace(array('order' => '2'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
     $expected_ts = array('name' => '2', 'sql' => 'two', 'sort' => 'desc', 'query' => array());
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers sorted correctly.');
     // Test complex table headers plus $_GET parameters that should _not_
     // override the default.
     $request = Request::createFromGlobals();
     $request->query->replace(array('order' => 'bar'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
     $expected_ts = array('name' => '1', 'sql' => 'one', 'sort' => 'asc', 'query' => array());
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.');
     // Test complex table headers plus $_GET parameters that _should_
     // override the default.
     $request = Request::createFromGlobals();
     $request->query->replace(array('order' => '1', 'sort' => 'ASC', 'alpha' => 'beta'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $expected_ts = array('name' => '1', 'sql' => 'one', 'sort' => 'asc', 'query' => array('alpha' => 'beta'));
     $ts = tablesort_init($headers);
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.');
 }
/**
 * Submit Mobile Blocks settings.
 * @param $values
 * @param $theme
 * @param $generated_files_path
 */
function at_core_submit_mobile_blocks($values, $theme, $generated_files_path)
{
    $mobile_blocks_css = array();
    // TODO entityManager() is deprecated, but how to replace?
    $theme_blocks = \Drupal::entityManager()->getStorage('block')->loadByProperties(['theme' => $theme]);
    if (!empty($theme_blocks)) {
        foreach ($theme_blocks as $block_key => $block_values) {
            $block_id = $block_values->id();
            if (isset($values['settings_mobile_block_show_' . $block_id]) && $values['settings_mobile_block_show_' . $block_id] == 1) {
                $block_selector = '#' . Html::getUniqueId('block-' . $block_id);
                $mobile_blocks_css[] = $block_selector . ' {display:none}' . "\n";
                $mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:block}' . "\n";
            }
            if (isset($values['settings_mobile_block_hide_' . $block_id]) && $values['settings_mobile_block_hide_' . $block_id] == 1) {
                $block_selector = '#' . Html::getUniqueId('block-' . $block_id);
                $mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:none}' . "\n";
                $mobile_blocks_css[] = $block_selector . ' {display:block}' . "\n";
            }
        }
    }
    if (!empty($mobile_blocks_css)) {
        $file_name = 'mobile-blocks.css';
        $filepath = $generated_files_path . '/' . $file_name;
        file_unmanaged_save_data($mobile_blocks_css, $filepath, FILE_EXISTS_REPLACE);
    }
}
 /**
  * Tests the generation of all system site information tokens.
  */
 public function testSystemSiteTokenReplacement()
 {
     $url_options = array('absolute' => TRUE, 'language' => $this->interfaceLanguage);
     $slogan = '<blink>Slogan</blink>';
     $safe_slogan = Xss::filterAdmin($slogan);
     // Set a few site variables.
     $config = $this->config('system.site');
     $config->set('name', '<strong>Drupal<strong>')->set('slogan', $slogan)->set('mail', '*****@*****.**')->save();
     // Generate and test tokens.
     $tests = array();
     $tests['[site:name]'] = Html::escape($config->get('name'));
     $tests['[site:slogan]'] = $safe_slogan;
     $tests['[site:mail]'] = $config->get('mail');
     $tests['[site:url]'] = \Drupal::url('<front>', [], $url_options);
     $tests['[site:url-brief]'] = preg_replace(array('!^https?://!', '!/$!'), '', \Drupal::url('<front>', [], $url_options));
     $tests['[site:login-url]'] = \Drupal::url('user.page', [], $url_options);
     $base_bubbleable_metadata = new BubbleableMetadata();
     $metadata_tests = [];
     $metadata_tests['[site:name]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
     $metadata_tests['[site:slogan]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
     $metadata_tests['[site:mail]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
     $bubbleable_metadata = clone $base_bubbleable_metadata;
     $metadata_tests['[site:url]'] = $bubbleable_metadata->addCacheContexts(['url.site']);
     $metadata_tests['[site:url-brief]'] = $bubbleable_metadata;
     $metadata_tests['[site:login-url]'] = $bubbleable_metadata;
     // Test to make sure that we generated something for each token.
     $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
     foreach ($tests as $input => $expected) {
         $bubbleable_metadata = new BubbleableMetadata();
         $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()), $bubbleable_metadata);
         $this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
         $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
     }
 }
 public function block_navbar($context, array $blocks = array())
 {
     // line 67
     echo "    ";
     // line 68
     $context["navbar_classes"] = array(0 => "navbar", 1 => $this->getAttribute($this->getAttribute(isset($context["theme"]) ? $context["theme"] : null, "settings", array()), "navbar_inverse", array()) ? "navbar-inverse" : "navbar-default", 2 => $this->getAttribute($this->getAttribute(isset($context["theme"]) ? $context["theme"] : null, "settings", array()), "navbar_position", array()) ? "navbar-" . \Drupal\Component\Utility\Html::getClass($this->getAttribute($this->getAttribute(isset($context["theme"]) ? $context["theme"] : null, "settings", array()), "navbar_position", array())) : "container");
     // line 74
     echo "    <header";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["navbar_attributes"]) ? $context["navbar_attributes"] : null, "addClass", array(0 => isset($context["navbar_classes"]) ? $context["navbar_classes"] : null), "method"), "html", null, true));
     echo " id=\"navbar\" role=\"banner\"  style=\"border:none;background-color:white;margin-bottom:0px\"> \n      <div class=\"navbar-header\">\n        ";
     // line 76
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["page"]) ? $context["page"] : null, "navigation", array()), "html", null, true));
     echo "\n        ";
     // line 78
     echo "        <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">\n          <span class=\"sr-only\">";
     // line 79
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(t("Toggle navigation")));
     echo "</span>\n          <span class=\"icon-bar\"></span>\n          <span class=\"icon-bar\"></span>\n          <span class=\"icon-bar\"></span>\n        </button>\n      </div>\n\n      ";
     // line 87
     echo "      ";
     if ($this->getAttribute(isset($context["page"]) ? $context["page"] : null, "navigation_collapsible", array())) {
         // line 88
         echo "        <div class=\"navbar-collapse collapse\" style=\"padding-top: 80px;\">\n          ";
         // line 89
         echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["page"]) ? $context["page"] : null, "navigation_collapsible", array()), "html", null, true));
         echo "\n        </div>\n      ";
     }
     // line 92
     echo "    </header>\n  ";
 }
 /**
  * @covers ::createPlaceholder
  * @dataProvider providerCreatePlaceholderGeneratesValidHtmlMarkup
  *
  * Ensure that the generated placeholder markup is valid. If it is not, then
  * simply using DOMDocument on HTML that contains placeholders may modify the
  * placeholders' markup, which would make it impossible to replace the
  * placeholders: the placeholder markup in #attached versus that in the HTML
  * processed by DOMDocument would no longer match.
  */
 public function testCreatePlaceholderGeneratesValidHtmlMarkup(array $element)
 {
     $build = $this->placeholderGenerator->createPlaceholder($element);
     $original_placeholder_markup = (string) $build['#markup'];
     $processed_placeholder_markup = Html::serialize(Html::load($build['#markup']));
     $this->assertEquals($original_placeholder_markup, $processed_placeholder_markup);
 }
 /**
  * Get album images by $node->id().
  * @todo move function so it is easily accessible.
  */
 public function getAlbumImages($nid, $limit = 10) {
   $images = array();
   $column = isset($_GET['field']) ? \Drupal\Component\Utility\Html::escape($_GET['field']) : '';
   $sort = isset($_GET['sort']) ? \Drupal\Component\Utility\Html::escape($_GET['sort']) : '';
   $term = _photos_order_value($column, $sort, $limit, array('column' => 'p.wid', 'sort' => 'asc'));
   $query = db_select('file_managed', 'f')
     ->extend('Drupal\Core\Database\Query\PagerSelectExtender');
   $query->join('photos_image', 'p', 'p.fid = f.fid');
   $query->join('users_field_data', 'u', 'f.uid = u.uid');
   $query->join('node', 'n', 'n.nid = p.pid');
   $query->fields('f', array('uri', 'filemime', 'created', 'filename', 'filesize'));
   $query->fields('p');
   $query->fields('u', array('uid', 'name'));
   $query->condition('p.pid', $nid);
   $query->limit($term['limit']);
   $query->orderBy($term['order']['column'], $term['order']['sort']);
   $query->addTag('node_access');
   $result = $query->execute();
   foreach ($result as $data) {
     // @todo create new function to return image object.
     $images[] = photos_get_info(0, $data);
   }
   if (isset($images[0]->fid)) {
     $node = \Drupal::entityManager()->getStorage('node')->load($nid);
     $images[0]->info = array(
       'pid' => $node->id(),
       'title' => $node->getTitle(),
       'uid' => $node->getOwnerId()
     );
     if (isset($node->album['cover'])) {
       $images[0]->info['cover'] = $node->album['cover'];
     }
   }
   return $images;
 }
 /**
  * Tests that the database was properly loaded.
  */
 public function testDatabaseLoaded()
 {
     foreach (['user', 'node', 'system', 'update_test_schema'] as $module) {
         $this->assertEqual(drupal_get_installed_schema_version($module), 8000, SafeMarkup::format('Module @module schema is 8000', ['@module' => $module]));
     }
     // Ensure that all {router} entries can be unserialized. If they cannot be
     // unserialized a notice will be thrown by PHP.
     $result = \Drupal::database()->query("SELECT name, route from {router}")->fetchAllKeyed(0, 1);
     // For the purpose of fetching the notices and displaying more helpful error
     // messages, let's override the error handler temporarily.
     set_error_handler(function ($severity, $message, $filename, $lineno) {
         throw new \ErrorException($message, 0, $severity, $filename, $lineno);
     });
     foreach ($result as $route_name => $route) {
         try {
             unserialize($route);
         } catch (\Exception $e) {
             $this->fail(sprintf('Error "%s" while unserializing route %s', $e->getMessage(), Html::escape($route_name)));
         }
     }
     restore_error_handler();
     // Before accessing the site we need to run updates first or the site might
     // be broken.
     $this->runUpdates();
     $this->assertEqual(\Drupal::config('system.site')->get('name'), 'Site-Install');
     $this->drupalGet('<front>');
     $this->assertText('Site-Install');
     // Ensure that the database tasks have been run during set up. Neither MySQL
     // nor SQLite make changes that are testable.
     $database = $this->container->get('database');
     if ($database->driver() == 'pgsql') {
         $this->assertEqual('on', $database->query("SHOW standard_conforming_strings")->fetchField());
         $this->assertEqual('escape', $database->query("SHOW bytea_output")->fetchField());
     }
 }
Beispiel #9
0
 /**
  * {@inheritdoc}
  */
 protected function preprocessVariables(Variables $variables, $hook, array $info)
 {
     // Retrieve the ID, generating one if needed.
     $id = $variables->getAttribute('id', Html::getUniqueId($variables->offsetGet('id', 'bootstrap-carousel')));
     unset($variables['id']);
     // Build slides.
     foreach ($variables->slides as $key => &$slide) {
         if (!isset($slide['attributes'])) {
             $slide['attributes'] = [];
         }
         $slide['attributes'] = new Attribute($slide['attributes']);
     }
     // Build controls.
     if ($variables->controls) {
         $left_icon = Bootstrap::glyphicon('chevron-left');
         $right_icon = Bootstrap::glyphicon('chevron-right');
         $url = Url::fromUserInput("#{$id}");
         $variables->controls = ['left' => ['#type' => 'link', '#title' => new FormattableMarkup(Element::create($left_icon)->render() . '<span class="sr-only">@text</span>', ['@text' => t('Previous')]), '#url' => $url, '#attributes' => ['class' => ['left', 'carousel-control'], 'role' => 'button', 'data-slide' => 'prev']], 'right' => ['#type' => 'link', '#title' => new FormattableMarkup(Element::create($right_icon)->render() . '<span class="sr-only">@text</span>', ['@text' => t('Next')]), '#url' => $url, '#attributes' => ['class' => ['right', 'carousel-control'], 'role' => 'button', 'data-slide' => 'next']]];
     }
     // Build indicators.
     if ($variables->indicators) {
         $variables->indicators = ['#theme' => 'item_list__bootstrap_carousel_indicators', '#list_type' => 'ol', '#items' => array_keys($variables->slides), '#target' => "#{$id}", '#start_index' => $variables->start_index];
     }
     // Ensure all attributes are proper objects.
     $this->preprocessAttributes($variables, $hook, $info);
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 27);
     $filters = array("clean_class" => 29, "raw" => 37, "safe_join" => 38, "t" => 46);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set'), array('clean_class', 'raw', 'safe_join', 't'), array());
     } catch (Twig_Sandbox_SecurityError $e) {
         $e->setTemplateFile($this->getTemplateName());
         if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
             $e->setTemplateLine($tags[$e->getTagName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
             $e->setTemplateLine($filters[$e->getFilterName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
             $e->setTemplateLine($functions[$e->getFunctionName()]);
         }
         throw $e;
     }
     // line 27
     $context["body_classes"] = array(0 => isset($context["logged_in"]) ? $context["logged_in"] : null ? "user-logged-in" : "", 1 => !(isset($context["root_path"]) ? $context["root_path"] : null) ? "path-frontpage" : "path-" . \Drupal\Component\Utility\Html::getClass(isset($context["root_path"]) ? $context["root_path"] : null), 2 => isset($context["node_type"]) ? $context["node_type"] : null ? "node--type-" . \Drupal\Component\Utility\Html::getClass(isset($context["node_type"]) ? $context["node_type"] : null) : "", 3 => isset($context["db_offline"]) ? $context["db_offline"] : null ? "db-offline" : "");
     // line 34
     echo "<!DOCTYPE html>\n<html";
     // line 35
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["html_attributes"]) ? $context["html_attributes"] : null, "html", null, true));
     echo ">\n  <head>\n    <head-placeholder token=\"";
     // line 37
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["placeholder_token"]) ? $context["placeholder_token"] : null));
     echo "\">\n    <title>";
     // line 38
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar($this->env->getExtension('drupal_core')->safeJoin($this->env, isset($context["head_title"]) ? $context["head_title"] : null, " | ")));
     echo "</title>\n    <css-placeholder token=\"";
     // line 39
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["placeholder_token"]) ? $context["placeholder_token"] : null));
     echo "\">\n    ";
     // line 41
     echo "    ";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["base_font"]) ? $context["base_font"] : null));
     echo "\n    <js-placeholder token=\"";
     // line 42
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["placeholder_token"]) ? $context["placeholder_token"] : null));
     echo "\">\n  </head>\n  <body";
     // line 44
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["body_classes"]) ? $context["body_classes"] : null), "method"), "html", null, true));
     echo ">\n    <a href=\"#main-content\" class=\"visually-hidden focusable skip-link\">\n      ";
     // line 46
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(t("Skip to main content")));
     echo "\n    </a>\n    ";
     // line 48
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["page_top"]) ? $context["page_top"] : null, "html", null, true));
     echo "\n    ";
     // line 49
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["page"]) ? $context["page"] : null, "html", null, true));
     echo "\n    ";
     // line 50
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["page_bottom"]) ? $context["page_bottom"] : null, "html", null, true));
     echo "\n    <js-bottom-placeholder token=\"";
     // line 51
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(isset($context["placeholder_token"]) ? $context["placeholder_token"] : null));
     echo "\">\n  </body>\n</html>\n";
 }
Beispiel #11
0
  /**
   * Lists all instances of fields on any views.
   *
   * @return array
   *   The Views fields report page.
   */
  public function nodeMarkup($node, $key = 'default') {
    $node = Node::load($node);

    $builded_entity = entity_view($node, $key);
    $markup = drupal_render($builded_entity);

    $links = array();
    $links['default'] = array(
      'title' => 'Default',
      'url' => Url::fromRoute('ds_devel.markup', array('node' => $node->id())),
    );
    $view_modes = \Drupal::entityManager()->getViewModes('node');
    foreach ($view_modes as $id => $info) {
      if (!empty($info['status'])) {
        $links[] = array(
          'title' => $info['label'],
          'url' => Url::fromRoute('ds_devel.markup_view_mode', array('node' => $node->id(), 'key' => $id)),
        );
      }
    }

    $build['links'] = array(
      '#theme' => 'links',
      '#links' => $links,
      '#prefix' => '<div>',
      '#suffix' => '</div><hr />',
    );
    $build['markup'] = [
      '#markup' => '<code><pre>' . Html::escape($markup) . '</pre></code>',
      '#allowed_tags' => ['code', 'pre'],
    ];

    return $build;
  }
 /**
  * #pre_render callback for building the regions.
  */
 public function buildRegions(array $build)
 {
     $cacheability = CacheableMetadata::createFromRenderArray($build)->addCacheableDependency($this);
     $contexts = $this->getContexts();
     foreach ($this->getRegionAssignments() as $region => $blocks) {
         if (!$blocks) {
             continue;
         }
         $region_name = Html::getClass("block-region-{$region}");
         $build[$region]['#prefix'] = '<div class="' . $region_name . '">';
         $build[$region]['#suffix'] = '</div>';
         /** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */
         $weight = 0;
         foreach ($blocks as $block_id => $block) {
             if ($block instanceof ContextAwarePluginInterface) {
                 $this->contextHandler()->applyContextMapping($block, $contexts);
             }
             $access = $block->access($this->account, TRUE);
             $cacheability->addCacheableDependency($access);
             if (!$access->isAllowed()) {
                 continue;
             }
             $block_build = ['#theme' => 'block', '#attributes' => [], '#weight' => $weight++, '#configuration' => $block->getConfiguration(), '#plugin_id' => $block->getPluginId(), '#base_plugin_id' => $block->getBaseId(), '#derivative_plugin_id' => $block->getDerivativeId(), '#block_plugin' => $block, '#pre_render' => [[$this, 'buildBlock']], '#cache' => ['keys' => ['page_manager_block_display', $this->id(), 'block', $block_id], 'tags' => Cache::mergeTags($this->getCacheTags(), $block->getCacheTags()), 'contexts' => $block->getCacheContexts(), 'max-age' => $block->getCacheMaxAge()]];
             // Merge the cacheability metadata of blocks into the page. This helps
             // to avoid cache redirects if the blocks have more cache contexts than
             // the page, which the page must respect as well.
             $cacheability->addCacheableDependency($block);
             $build[$region][$block_id] = $block_build;
         }
     }
     $build['#title'] = $this->renderPageTitle($this->configuration['page_title']);
     $cacheability->applyTo($build);
     return $build;
 }
Beispiel #13
0
 /**
  * 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;
 }
Beispiel #14
0
/**
 * @file
 * Save Breadcrumb CSS to file
 */
function at_core_submit_mobile_blocks($values, $theme, $generated_files_path) {
  $mobile_blocks_css = array();
  $theme_blocks = entity_load_multiple_by_properties('block', ['theme' => $theme]);

  if (!empty($theme_blocks)) {
    foreach ($theme_blocks as $block_key => $block_values) {
      $block_id = $block_values->id();
      if (isset($values['settings_mobile_block_show_' . $block_id]) && $values['settings_mobile_block_show_' . $block_id] == 1) {
        $block_selector = '#' . Html::getUniqueId('block-' . $block_id);
        $mobile_blocks_css[] = $block_selector . ' {display:none}' . "\n";
        $mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:block}' . "\n";
      }
      if (isset($values['settings_mobile_block_hide_' . $block_id]) && $values['settings_mobile_block_hide_' . $block_id] == 1) {
        $block_selector = '#' . Html::getUniqueId('block-' . $block_id);
        $mobile_blocks_css[] = '.is-mobile ' . $block_selector . ' {display:none}' . "\n";
        $mobile_blocks_css[] = $block_selector . ' {display:block}' . "\n";
      }
    }
  }

  if (!empty($mobile_blocks_css)) {
    $file_name = 'mobile-blocks.css';
    $filepath = $generated_files_path . '/' . $file_name;
    file_unmanaged_save_data($mobile_blocks_css, $filepath, FILE_EXISTS_REPLACE);
  }
}
    protected function doDisplay(array $context, array $blocks = array())
    {
        $tags = array("set" => 29, "if" => 37, "block" => 41);
        $filters = array("clean_class" => 31);
        $functions = array();

        try {
            $this->env->getExtension('sandbox')->checkSecurity(
                array('set', 'if', 'block'),
                array('clean_class'),
                array()
            );
        } catch (Twig_Sandbox_SecurityError $e) {
            $e->setTemplateFile($this->getTemplateName());

            if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
                $e->setTemplateLine($tags[$e->getTagName()]);
            } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
                $e->setTemplateLine($filters[$e->getFilterName()]);
            } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
                $e->setTemplateLine($functions[$e->getFunctionName()]);
            }

            throw $e;
        }

        // line 29
        $context["classes"] = array(0 => "block", 1 => ("block-" . \Drupal\Component\Utility\Html::getClass($this->getAttribute(        // line 31
(isset($context["configuration"]) ? $context["configuration"] : null), "provider", array()))), 2 => ("block-" . \Drupal\Component\Utility\Html::getClass(        // line 32
(isset($context["plugin_id"]) ? $context["plugin_id"] : null))));
        // line 35
        echo "<div";
        echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute((isset($context["attributes"]) ? $context["attributes"] : null), "addClass", array(0 => (isset($context["classes"]) ? $context["classes"] : null)), "method"), "html", null, true));
        echo ">
  ";
        // line 36
        echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_prefix"]) ? $context["title_prefix"] : null), "html", null, true));
        echo "
  ";
        // line 37
        if ((isset($context["label"]) ? $context["label"] : null)) {
            // line 38
            echo "    <h2";
            echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_attributes"]) ? $context["title_attributes"] : null), "html", null, true));
            echo ">";
            echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["label"]) ? $context["label"] : null), "html", null, true));
            echo "</h2>
  ";
        }
        // line 40
        echo "  ";
        echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, (isset($context["title_suffix"]) ? $context["title_suffix"] : null), "html", null, true));
        echo "
  ";
        // line 41
        $this->displayBlock('content', $context, $blocks);
        // line 44
        echo "</div>
";
    }
 /**
  * Assert sorting by field and property.
  */
 public function testSort()
 {
     // Add text field to entity, to sort by.
     entity_create('field_storage_config', array('field_name' => 'field_text', 'entity_type' => 'node', 'type' => 'text', 'entity_types' => array('node')))->save();
     entity_create('field_config', array('label' => 'Text Field', 'field_name' => 'field_text', 'entity_type' => 'node', 'bundle' => 'article', 'settings' => array(), 'required' => FALSE))->save();
     // Build a set of test data.
     $node_values = array('published1' => array('type' => 'article', 'status' => 1, 'title' => 'Node published1 (<&>)', 'uid' => 1, 'field_text' => array(array('value' => 1))), 'published2' => array('type' => 'article', 'status' => 1, 'title' => 'Node published2 (<&>)', 'uid' => 1, 'field_text' => array(array('value' => 2))));
     $nodes = array();
     $node_labels = array();
     foreach ($node_values as $key => $values) {
         $node = Node::create($values);
         $node->save();
         $nodes[$key] = $node;
         $node_labels[$key] = Html::escape($node->label());
     }
     $selection_options = array('target_type' => 'node', 'handler' => 'default', 'handler_settings' => array('target_bundles' => array(), 'sort' => array('field' => 'field_text.value', 'direction' => 'DESC')));
     $handler = $this->container->get('plugin.manager.entity_reference_selection')->getInstance($selection_options);
     // Not only assert the result, but make sure the keys are sorted as
     // expected.
     $result = $handler->getReferenceableEntities();
     $expected_result = array($nodes['published2']->id() => $node_labels['published2'], $nodes['published1']->id() => $node_labels['published1']);
     $this->assertIdentical($result['article'], $expected_result, 'Query sorted by field returned expected values.');
     // Assert sort by base field.
     $selection_options['handler_settings']['sort'] = array('field' => 'nid', 'direction' => 'ASC');
     $handler = $this->container->get('plugin.manager.entity_reference_selection')->getInstance($selection_options);
     $result = $handler->getReferenceableEntities();
     $expected_result = array($nodes['published1']->id() => $node_labels['published1'], $nodes['published2']->id() => $node_labels['published2']);
     $this->assertIdentical($result['article'], $expected_result, 'Query sorted by property returned expected values.');
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $__internal_7a0e19497cc5621f359001e57941961d5fa9198360c2e2b87d5e42aa5f916bf4 = $this->env->getExtension("native_profiler");
     $__internal_7a0e19497cc5621f359001e57941961d5fa9198360c2e2b87d5e42aa5f916bf4->enter($__internal_7a0e19497cc5621f359001e57941961d5fa9198360c2e2b87d5e42aa5f916bf4_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "core/themes/classy/templates/field/image.html.twig"));
     $tags = array("set" => 14);
     $filters = array("clean_class" => 15);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set'), array('clean_class'), array());
     } catch (Twig_Sandbox_SecurityError $e) {
         $e->setTemplateFile($this->getTemplateName());
         if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
             $e->setTemplateLine($tags[$e->getTagName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
             $e->setTemplateLine($filters[$e->getFilterName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
             $e->setTemplateLine($functions[$e->getFunctionName()]);
         }
         throw $e;
     }
     // line 14
     $context["classes"] = array(0 => isset($context["style_name"]) ? $context["style_name"] : null ? "image-style-" . \Drupal\Component\Utility\Html::getClass(isset($context["style_name"]) ? $context["style_name"] : null) : "");
     // line 18
     echo "<img";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["classes"]) ? $context["classes"] : null), "method"), "html", null, true));
     echo " />\n";
     $__internal_7a0e19497cc5621f359001e57941961d5fa9198360c2e2b87d5e42aa5f916bf4->leave($__internal_7a0e19497cc5621f359001e57941961d5fa9198360c2e2b87d5e42aa5f916bf4_prof);
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 36
     $context["classes"] = array(0 => "block", 1 => "block-" . \Drupal\Component\Utility\Html::getClass($this->getAttribute(isset($context["configuration"]) ? $context["configuration"] : null, "provider", array())));
     // line 41
     echo "<div";
     echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["classes"]) ? $context["classes"] : null), "method"), "html", null, true);
     echo ">\n  ";
     // line 42
     echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["title_prefix"]) ? $context["title_prefix"] : null, "html", null, true);
     echo "\n  ";
     // line 43
     if (isset($context["label"]) ? $context["label"] : null) {
         // line 44
         echo "    <h2";
         echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["title_attributes"]) ? $context["title_attributes"] : null, "html", null, true);
         echo ">";
         echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["label"]) ? $context["label"] : null, "html", null, true);
         echo "</h2>\n  ";
     }
     // line 46
     echo "  ";
     echo $this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["title_suffix"]) ? $context["title_suffix"] : null, "html", null, true);
     echo "\n  ";
     // line 47
     $this->displayBlock('content', $context, $blocks);
     // line 50
     echo "</div>\n";
 }
 /**
  * Assert that a trail exists in the internal browser.
  *
  * @param array $trail
  *   An associative array whose keys are expected breadcrumb link paths and
  *   whose values are expected breadcrumb link texts (not sanitized).
  */
 protected function assertBreadcrumbParts($trail)
 {
     // Compare paths with actual breadcrumb.
     $parts = $this->getBreadcrumbParts();
     $pass = TRUE;
     // There may be more than one breadcrumb on the page. If $trail is empty
     // this test would go into an infinite loop, so we need to check that too.
     while ($trail && !empty($parts)) {
         foreach ($trail as $path => $title) {
             // If the path is empty, generate the path from the <front> route.  If
             // the path does not start with a leading slash, then run it through
             // Url::fromUri('base:')->toString() to get the correct base
             // prepended.
             if ($path == '') {
                 $url = Url::fromRoute('<front>')->toString();
             } elseif ($path[0] != '/') {
                 $url = Url::fromUri('base:' . $path)->toString();
             } else {
                 $url = $path;
             }
             $part = array_shift($parts);
             $pass = $pass && $part['href'] === $url && $part['text'] === Html::escape($title);
         }
     }
     // No parts must be left, or an expected "Home" will always pass.
     $pass = $pass && empty($parts);
     $this->assertTrue($pass, format_string('Breadcrumb %parts found on @path.', array('%parts' => implode(' » ', $trail), '@path' => $this->getUrl())));
 }
 /**
  * Sets the AJAX parameter from the current request.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *   The response event, which contains the current request.
  */
 public function onRequest(GetResponseEvent $event)
 {
     // Pass to the Html class that the current request is an Ajax request.
     if ($event->getRequest()->request->get(static::AJAX_REQUEST_PARAMETER)) {
         Html::setIsAjax(TRUE);
     }
 }
Beispiel #21
0
 /**
  * Returns a string representation of the attribute.
  *
  * While __toString only returns the value in a string form, render()
  * contains the name of the attribute as well.
  *
  * @return string
  *   The string representation of the attribute.
  */
 public function render()
 {
     $value = (string) $this;
     if (isset($this->value) && static::RENDER_EMPTY_ATTRIBUTE || !empty($value)) {
         return Html::escape($this->name) . '="' . $value . '"';
     }
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 16, "if" => 21);
     $filters = array("clean_class" => 18);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'if'), array('clean_class'), array());
     } catch (Twig_Sandbox_SecurityError $e) {
         $e->setTemplateFile($this->getTemplateName());
         if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
             $e->setTemplateLine($tags[$e->getTagName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
             $e->setTemplateLine($filters[$e->getFilterName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
             $e->setTemplateLine($functions[$e->getFunctionName()]);
         }
         throw $e;
     }
     // line 16
     $context["classes"] = array(0 => "region", 1 => "region-" . \Drupal\Component\Utility\Html::getClass(isset($context["region"]) ? $context["region"] : null));
     // line 21
     if (isset($context["content"]) ? $context["content"] : null) {
         // line 22
         echo "  <div";
         echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["classes"]) ? $context["classes"] : null), "method"), "html", null, true));
         echo ">\n    ";
         // line 23
         echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["content"]) ? $context["content"] : null, "html", null, true));
         echo "\n  </div>\n";
     }
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 36, "block" => 38);
     $filters = array("clean_id" => 36, "without" => 37);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'block'), array('clean_id', 'without'), array());
     } catch (Twig_Sandbox_SecurityError $e) {
         $e->setTemplateFile($this->getTemplateName());
         if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
             $e->setTemplateLine($tags[$e->getTagName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
             $e->setTemplateLine($filters[$e->getFilterName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
             $e->setTemplateLine($functions[$e->getFunctionName()]);
         }
         throw $e;
     }
     // line 36
     $context["heading_id"] = $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()) . \Drupal\Component\Utility\Html::getId("-menu");
     // line 37
     echo "<nav role=\"navigation\" aria-labelledby=\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["heading_id"]) ? $context["heading_id"] : null, "html", null, true));
     echo "\"";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, twig_without($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "removeClass", array(0 => "clearfix"), "method"), "role", "aria-labelledby"), "html", null, true));
     echo ">\n  ";
     // line 38
     $this->displayBlock('content', $context, $blocks);
     // line 41
     echo "</nav>\n";
 }
 /**
  * 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);
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 10, "trans" => 17);
     $filters = array("clean_id" => 10);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set', 'trans'), array('clean_id'), array());
     } catch (Twig_Sandbox_SecurityError $e) {
         $e->setTemplateFile($this->getTemplateName());
         if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
             $e->setTemplateLine($tags[$e->getTagName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
             $e->setTemplateLine($filters[$e->getFilterName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
             $e->setTemplateLine($functions[$e->getFunctionName()]);
         }
         throw $e;
     }
     // line 10
     $context["show_anchor"] = "show-" . \Drupal\Component\Utility\Html::getId($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()));
     // line 11
     $context["hide_anchor"] = "hide-" . \Drupal\Component\Utility\Html::getId($this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "id", array()));
     // line 1
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     $tags = array("set" => 14);
     $filters = array("clean_class" => 15);
     $functions = array();
     try {
         $this->env->getExtension('sandbox')->checkSecurity(array('set'), array('clean_class'), array());
     } catch (Twig_Sandbox_SecurityError $e) {
         $e->setTemplateFile($this->getTemplateName());
         if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
             $e->setTemplateLine($tags[$e->getTagName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
             $e->setTemplateLine($filters[$e->getFilterName()]);
         } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
             $e->setTemplateLine($functions[$e->getFunctionName()]);
         }
         throw $e;
     }
     // line 14
     $context["classes"] = array(0 => isset($context["style_name"]) ? $context["style_name"] : null ? "image-style-" . \Drupal\Component\Utility\Html::getClass(isset($context["style_name"]) ? $context["style_name"] : null) : "");
     // line 18
     echo "<img";
     echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => isset($context["classes"]) ? $context["classes"] : null), "method"), "html", null, true));
     echo " />\n";
 }
 /**
  * Test pathauto_cleanstring().
  */
 public function testCleanString()
 {
     $config = $this->config('pathauto.settings');
     $tests = array();
     $config->set('ignore_words', ', in, is,that, the  , this, with, ');
     $config->set('max_component_length', 35);
     $config->set('transliterate', TRUE);
     $config->save();
     \Drupal::service('pathauto.manager')->resetCaches();
     // Test the 'ignored words' removal.
     $tests['this'] = 'this';
     $tests['this with that'] = 'this-with-that';
     $tests['this thing with that thing'] = 'thing-thing';
     // Test length truncation and duplicate separator removal.
     $tests[' - Pathauto is the greatest - module ever in Drupal hiarticle - '] = 'pathauto-greatest-module-ever';
     // Test that HTML tags are removed.
     $tests['This <span class="text">text</span> has <br /><a href="http://example.com"><strong>HTML tags</strong></a>.'] = 'text-has-html-tags';
     $tests[Html::escape('This <span class="text">text</span> has <br /><a href="http://example.com"><strong>HTML tags</strong></a>.')] = 'text-has-html-tags';
     // Transliteration.
     $tests['ľščťžýáíéňô'] = 'lsctzyaieno';
     foreach ($tests as $input => $expected) {
         $output = \Drupal::service('pathauto.alias_cleaner')->cleanString($input);
         $this->assertEqual($output, $expected, t("Drupal::service('pathauto.alias_cleaner')->cleanString('@input') expected '@expected', actual '@output'", array('@input' => $input, '@expected' => $expected, '@output' => $output)));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL)
 {
     /** @var \Drupal\tour\TourInterface[] $entities */
     $build = array();
     foreach ($entities as $entity_id => $entity) {
         $tips = $entity->getTips();
         $count = count($tips);
         $list_items = array();
         foreach ($tips as $index => $tip) {
             if ($output = $tip->getOutput()) {
                 $attributes = array('class' => array('tip-module-' . Html::cleanCssIdentifier($entity->getModule()), 'tip-type-' . Html::cleanCssIdentifier($tip->getPluginId()), 'tip-' . Html::cleanCssIdentifier($tip->id())));
                 $list_items[] = array('output' => $output, 'counter' => array('#type' => 'container', '#attributes' => array('class' => array('tour-progress')), '#children' => t('@tour_item of @total', array('@tour_item' => $index + 1, '@total' => $count))), '#wrapper_attributes' => $tip->getAttributes() + $attributes);
             }
         }
         // If there is at least one tour item, build the tour.
         if ($list_items) {
             end($list_items);
             $key = key($list_items);
             $list_items[$key]['#wrapper_attributes']['data-text'] = t('End tour');
             $build[$entity_id] = array('#theme' => 'item_list', '#items' => $list_items, '#list_type' => 'ol', '#attributes' => array('id' => 'tour', 'class' => array('hidden')), '#cache' => ['tags' => $entity->getCacheTags()]);
         }
     }
     // If at least one tour was built, attach the tour library.
     if ($build) {
         $build['#attached']['library'][] = 'tour/tour';
     }
     return $build;
 }
 /**
  * Tests the rendering of blocks.
  */
 public function testBasicRendering()
 {
     \Drupal::state()->set('block_test.content', '');
     $entity = $this->controller->create(array('id' => 'test_block1', 'theme' => 'stark', 'plugin' => 'test_html'));
     $entity->save();
     // Test the rendering of a block.
     $entity = Block::load('test_block1');
     $output = entity_view($entity, 'block');
     $expected = array();
     $expected[] = '<div id="block-test-block1">';
     $expected[] = '  ';
     $expected[] = '    ';
     $expected[] = '      ';
     $expected[] = '  </div>';
     $expected[] = '';
     $expected_output = implode("\n", $expected);
     $this->assertEqual($this->renderer->renderRoot($output), $expected_output);
     // Reset the HTML IDs so that the next render is not affected.
     Html::resetSeenIds();
     // Test the rendering of a block with a given title.
     $entity = $this->controller->create(array('id' => 'test_block2', 'theme' => 'stark', 'plugin' => 'test_html', 'settings' => array('label' => 'Powered by Bananas')));
     $entity->save();
     $output = entity_view($entity, 'block');
     $expected = array();
     $expected[] = '<div id="block-test-block2">';
     $expected[] = '  ';
     $expected[] = '      <h2>Powered by Bananas</h2>';
     $expected[] = '    ';
     $expected[] = '      ';
     $expected[] = '  </div>';
     $expected[] = '';
     $expected_output = implode("\n", $expected);
     $this->assertEqual($this->renderer->renderRoot($output), $expected_output);
 }
 /**
  * Builds the Toolbar as a structured array ready for drupal_render().
  *
  * Since building the toolbar takes some time, it is done just prior to
  * rendering to ensure that it is built only if it will be displayed.
  *
  * @param array $element
  *   A renderable array.
  *
  * @return array
  *  A renderable array.
  *
  * @see toolbar_page_top().
  */
 public static function preRenderToolbar($element)
 {
     // Get the configured breakpoints to switch from vertical to horizontal
     // toolbar presentation.
     $breakpoints = static::breakpointManager()->getBreakpointsByGroup('toolbar');
     if (!empty($breakpoints)) {
         $media_queries = array();
         foreach ($breakpoints as $id => $breakpoint) {
             $media_queries[$id] = $breakpoint->getMediaQuery();
         }
         $element['#attached']['drupalSettings']['toolbar']['breakpoints'] = $media_queries;
     }
     $module_handler = static::moduleHandler();
     // Get toolbar items from all modules that implement hook_toolbar().
     $items = $module_handler->invokeAll('toolbar');
     // Allow for altering of hook_toolbar().
     $module_handler->alter('toolbar', $items);
     // Sort the children.
     uasort($items, array('\\Drupal\\Component\\Utility\\SortArray', 'sortByWeightProperty'));
     // Merge in the original toolbar values.
     $element = array_merge($element, $items);
     // Assign each item a unique ID, based on its key.
     foreach (Element::children($element) as $key) {
         $element[$key]['#id'] = Html::getId('toolbar-item-' . $key);
     }
     return $element;
 }