Example #1
0
 /**
  * Returns a block theme demo page.
  *
  * @param string $theme
  *   The name of the theme.
  *
  * @return array
  *   A #type 'page' render array containing the block region demo.
  */
 public function demo($theme)
 {
     $page = ['#title' => $this->themeHandler->getName($theme), '#type' => 'page', '#attached' => array('drupalSettings' => ['path' => ['currentPathIsAdmin' => TRUE]], 'library' => array('block/drupal.block.admin'))];
     // Show descriptions in each visible page region, nothing else.
     $visible_regions = $this->getVisibleRegionNames($theme);
     foreach (array_keys($visible_regions) as $region) {
         $page[$region]['block_description'] = array('#type' => 'inline_template', '#template' => '<div class="block-region demo-block">{{ region_name }}</div>', '#context' => array('region_name' => $visible_regions[$region]));
     }
     return $page;
 }
Example #2
0
 /**
  * Gets the label for a breakpoint group.
  *
  * @param string $group
  *   The breakpoint group.
  *
  * @return string
  *   The label.
  */
 protected function getGroupLabel($group)
 {
     // Extension names are not translatable.
     if ($this->moduleHandler->moduleExists($group)) {
         $label = $this->moduleHandler->getName($group);
     } elseif ($this->themeHandler->themeExists($group)) {
         $label = $this->themeHandler->getName($group);
     } else {
         // Custom group label that should be translatable.
         $label = $this->t($group, array(), array('context' => 'breakpoint'));
     }
     return $label;
 }
Example #3
0
 /**
  * Generates a report about config updates.
  *
  * @param string $report_type
  *   Type of report to generate: 'type', 'module', 'theme', or 'profile'.
  * @param string $value
  *   Machine name of a configuration type, module, or theme to generate the
  *   report for. Ignored for profile, since that uses the active profile.
  *
  * @return array
  *   Render array for the updates report. Empty if invalid or missing
  *   report type or value.
  */
 protected function generateReport($report_type, $value)
 {
     // Figure out what to name the report, and incidentally, validate that
     // $value exists for this type of report.
     switch ($report_type) {
         case 'type':
             if ($value == 'system.all') {
                 $label = $this->t('All configuration');
             } elseif ($value == 'system.simple') {
                 $label = $this->t('Simple configuration');
             } else {
                 $definition = $this->configList->getType($value);
                 if (!$definition) {
                     return NULL;
                 }
                 $label = $this->t('@name configuration', array('@name' => $definition->getLabel()));
             }
             break;
         case 'module':
             $list = $this->moduleHandler->getModuleList();
             if (!isset($list[$value])) {
                 return NULL;
             }
             $label = $this->t('@name module', array('@name' => $this->moduleHandler->getName($value)));
             break;
         case 'theme':
             $list = $this->themeHandler->listInfo();
             if (!isset($list[$value])) {
                 return NULL;
             }
             $label = $this->t('@name theme', array('@name' => $this->themeHandler->getName($value)));
             break;
         case 'profile':
             $profile = Settings::get('install_profile');
             $label = $this->t('@name profile', array('@name' => $this->moduleHandler->getName($profile)));
             break;
         default:
             return NULL;
     }
     // List the active and extension-provided config.
     list($active_list, $install_list, $optional_list) = $this->configList->listConfig($report_type, $value);
     // Build the report.
     $build = array();
     $build['#title'] = $this->t('Configuration updates report for @label', array('@label' => $label));
     $build['report_header'] = array('#markup' => '<h3>' . $this->t('Updates report') . '</h3>');
     // List items missing from site.
     $removed = array_diff($install_list, $active_list);
     $build['removed'] = array('#caption' => $this->t('Missing configuration items'), '#empty' => $this->t('None: all provided configuration items are in your active configuration.')) + $this->makeReportTable($removed, 'extension', array('import'));
     // List optional items that are not installed.
     $inactive = array_diff($optional_list, $active_list);
     $build['inactive'] = array('#caption' => $this->t('Inactive optional items'), '#empty' => $this->t('None: all optional configuration items are in your active configuration.')) + $this->makeReportTable($inactive, 'extension', array('import'));
     // List items added to site, which only makes sense in the report for a
     // config type.
     $added = array_diff($active_list, $install_list, $optional_list);
     if ($report_type == 'type') {
         $build['added'] = array('#caption' => $this->t('Added configuration items'), '#empty' => $this->t('None: all active configuration items of this type were provided by modules, themes, or install profile.')) + $this->makeReportTable($added, 'active', array('export', 'delete'));
     }
     // For differences, we need to go through the array of config in both
     // and see if each config item is the same or not.
     $both = array_diff($active_list, $added);
     $different = array();
     foreach ($both as $name) {
         if (!$this->configDiff->same($this->configRevert->getFromExtension('', $name), $this->configRevert->getFromActive('', $name))) {
             $different[] = $name;
         }
     }
     $build['different'] = array('#caption' => $this->t('Changed configuration items'), '#empty' => $this->t('None: no active configuration items differ from their current provided versions.')) + $this->makeReportTable($different, 'active', array('diff', 'export', 'revert'));
     return $build;
 }
 /**
  * Returns a block theme demo page.
  *
  * @param string $theme
  *   The name of the theme.
  *
  * @return array
  *   A render array containing the CSS and title for the block region demo.
  */
 public function demo($theme)
 {
     return array('#title' => String::checkPlain($this->themeHandler->getName($theme)), '#attached' => array('js' => array(array('data' => array('path' => array('currentPathIsAdmin' => TRUE)), 'type' => 'setting')), 'library' => array('block/drupal.block.admin')));
 }