コード例 #1
0
ファイル: Extension.php プロジェクト: GDrupal/DrupalConsole
 /**
  * @param $fullPath
  * @return string
  */
 public function getPath($fullPath = false)
 {
     if ($fullPath) {
         return $this->root . '/' . parent::getPath();
     }
     return parent::getPath();
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function getActiveTheme(Extension $theme, array $base_themes = [])
 {
     $theme_path = $theme->getPath();
     $values['path'] = $theme_path;
     $values['name'] = $theme->getName();
     // Prepare stylesheets from this theme as well as all ancestor themes.
     // We work it this way so that we can have child themes override parent
     // theme stylesheets easily.
     $values['stylesheets'] = array();
     // CSS file basenames to override, pointing to the final, overridden filepath.
     $values['stylesheets_override'] = array();
     // CSS file basenames to remove.
     $values['stylesheets_remove'] = array();
     // Grab stylesheets from base theme.
     $final_stylesheets = array();
     foreach ($base_themes as $base) {
         if (!empty($base->stylesheets)) {
             foreach ($base->stylesheets as $media => $stylesheets) {
                 foreach ($stylesheets as $name => $stylesheet) {
                     $final_stylesheets[$media][$name] = $stylesheet;
                 }
             }
         }
         $base_theme_path = $base->getPath();
         if (!empty($base->info['stylesheets-remove'])) {
             foreach ($base->info['stylesheets-remove'] as $basename) {
                 $values['stylesheets_remove'][$basename] = $base_theme_path . '/' . $basename;
             }
         }
         if (!empty($base->info['stylesheets-override'])) {
             foreach ($base->info['stylesheets-override'] as $name) {
                 $basename = drupal_basename($name);
                 $values['stylesheets_override'][$basename] = $base_theme_path . '/' . $name;
             }
         }
     }
     // Add stylesheets used by this theme.
     if (!empty($theme->stylesheets)) {
         foreach ($theme->stylesheets as $media => $stylesheets) {
             foreach ($stylesheets as $name => $stylesheet) {
                 $final_stylesheets[$media][$name] = $stylesheet;
             }
         }
     }
     if (!empty($theme->info['stylesheets-remove'])) {
         foreach ($theme->info['stylesheets-remove'] as $basename) {
             $values['stylesheets_remove'][$basename] = $theme_path . '/' . $basename;
             if (isset($values['stylesheets_override'][$basename])) {
                 unset($values['stylesheets_override'][$basename]);
             }
         }
     }
     if (!empty($theme->info['stylesheets-override'])) {
         foreach ($theme->info['stylesheets-override'] as $name) {
             $basename = drupal_basename($name);
             $values['stylesheets_override'][$basename] = $theme_path . '/' . $name;
             if (isset($values['stylesheets_remove'][$basename])) {
                 unset($values['stylesheets_remove'][$basename]);
             }
         }
     }
     // And now add the stylesheets properly.
     $values['stylesheets'] = $final_stylesheets;
     // Do basically the same as the above for libraries
     $values['libraries'] = array();
     // Grab libraries from base theme
     foreach ($base_themes as $base) {
         if (!empty($base->libraries)) {
             foreach ($base->libraries as $library) {
                 $values['libraries'][] = $library;
             }
         }
     }
     // Add libraries used by this theme.
     if (!empty($theme->libraries)) {
         foreach ($theme->libraries as $library) {
             $values['libraries'][] = $library;
         }
     }
     $values['engine'] = isset($theme->engine) ? $theme->engine : NULL;
     $values['owner'] = isset($theme->owner) ? $theme->owner : NULL;
     $values['extension'] = $theme;
     $base_active_themes = array();
     foreach ($base_themes as $base_theme) {
         $base_active_themes[$base_theme->getName()] = $this->getActiveTheme($base_theme, array_slice($base_themes, 1));
     }
     $values['base_themes'] = $base_active_themes;
     return new ActiveTheme($values);
 }
コード例 #3
0
ファイル: UpdateRegistry.php プロジェクト: eigentor/tommiblog
 /**
  * Loads the {$this->updateType}.php file for a given extension.
  *
  * @param \Drupal\Core\Extension\Extension $module
  *   The extension of the module to load its file.
  */
 protected function loadUpdateFile(Extension $module)
 {
     $filename = $this->root . '/' . $module->getPath() . '/' . $module->getName() . ".{$this->updateType}.php";
     if (file_exists($filename)) {
         include_once $filename;
     }
 }
コード例 #4
0
ファイル: Theme.php プロジェクト: r-daneelolivaw/chalk
 /**
  * Returns the relative path of the theme.
  *
  * @return string
  *   The relative path of the theme.
  */
 public function getPath()
 {
     return $this->theme->getPath();
 }
コード例 #5
0
ファイル: InstallStorage.php プロジェクト: 318io/318-io
 /**
  * Get folder inside each component that contains the files.
  *
  * @param \Drupal\Core\Extension\Extension $extension
  *   The Extension object for the component.
  *
  * @return string
  *   The configuration folder name for this component.
  */
 protected function getComponentFolder(Extension $extension)
 {
     return $extension->getPath() . '/' . $this->getCollectionDirectory();
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function getActiveTheme(Extension $theme, array $base_themes = [])
 {
     $theme_path = $theme->getPath();
     $values['path'] = $theme_path;
     $values['name'] = $theme->getName();
     // @todo Remove in Drupal 9.0.x.
     $values['stylesheets_remove'] = $this->prepareStylesheetsRemove($theme, $base_themes);
     // Prepare libraries overrides from this theme and ancestor themes. This
     // allows child themes to easily remove CSS files from base themes and
     // modules.
     $values['libraries_override'] = [];
     // Get libraries overrides declared by base themes.
     foreach ($base_themes as $base) {
         if (!empty($base->info['libraries-override'])) {
             foreach ($base->info['libraries-override'] as $library => $override) {
                 $values['libraries_override'][$base->getPath()][$library] = $override;
             }
         }
     }
     // Add libraries overrides declared by this theme.
     if (!empty($theme->info['libraries-override'])) {
         foreach ($theme->info['libraries-override'] as $library => $override) {
             $values['libraries_override'][$theme->getPath()][$library] = $override;
         }
     }
     // Get libraries extensions declared by base themes.
     foreach ($base_themes as $base) {
         if (!empty($base->info['libraries-extend'])) {
             foreach ($base->info['libraries-extend'] as $library => $extend) {
                 if (isset($values['libraries_extend'][$library])) {
                     // Merge if libraries-extend has already been defined for this
                     // library.
                     $values['libraries_extend'][$library] = array_merge($values['libraries_extend'][$library], $extend);
                 } else {
                     $values['libraries_extend'][$library] = $extend;
                 }
             }
         }
     }
     // Add libraries extensions declared by this theme.
     if (!empty($theme->info['libraries-extend'])) {
         foreach ($theme->info['libraries-extend'] as $library => $extend) {
             if (isset($values['libraries_extend'][$library])) {
                 // Merge if libraries-extend has already been defined for this
                 // library.
                 $values['libraries_extend'][$library] = array_merge($values['libraries_extend'][$library], $extend);
             } else {
                 $values['libraries_extend'][$library] = $extend;
             }
         }
     }
     // Do basically the same as the above for libraries
     $values['libraries'] = array();
     // Grab libraries from base theme
     foreach ($base_themes as $base) {
         if (!empty($base->libraries)) {
             foreach ($base->libraries as $library) {
                 $values['libraries'][] = $library;
             }
         }
     }
     // Add libraries used by this theme.
     if (!empty($theme->libraries)) {
         foreach ($theme->libraries as $library) {
             $values['libraries'][] = $library;
         }
     }
     $values['engine'] = isset($theme->engine) ? $theme->engine : NULL;
     $values['owner'] = isset($theme->owner) ? $theme->owner : NULL;
     $values['extension'] = $theme;
     $base_active_themes = array();
     foreach ($base_themes as $base_theme) {
         $base_active_themes[$base_theme->getName()] = $this->getActiveTheme($base_theme, array_slice($base_themes, 1));
     }
     $values['base_themes'] = $base_active_themes;
     if (!empty($theme->info['regions'])) {
         $values['regions'] = $theme->info['regions'];
     }
     return new ActiveTheme($values);
 }
コード例 #7
0
ファイル: ProjectInfo.php プロジェクト: anatalsceo/en-classe
 /**
  * Determines what project a given file object belongs to.
  *
  * @param \Drupal\Core\Extension\Extension $file
  *   An extension object.
  *
  * @return string
  *   The canonical project short name.
  */
 function getProjectName(Extension $file)
 {
     $project_name = '';
     if (isset($file->info['project'])) {
         $project_name = $file->info['project'];
     } elseif (strpos($file->getPath(), 'core/modules') === 0) {
         $project_name = 'drupal';
     }
     return $project_name;
 }
コード例 #8
0
ファイル: ThemeInitialization.php プロジェクト: nsp15/Drupal8
 /**
  * {@inheritdoc}
  */
 public function getActiveTheme(Extension $theme, array $base_themes = [])
 {
     $theme_path = $theme->getPath();
     $values['path'] = $theme_path;
     $values['name'] = $theme->getName();
     // Prepare stylesheets from this theme as well as all ancestor themes.
     // We work it this way so that we can have child themes remove CSS files
     // easily from parent.
     $values['stylesheets_remove'] = array();
     // Grab stylesheets from base theme.
     foreach ($base_themes as $base) {
         $base_theme_path = $base->getPath();
         if (!empty($base->info['stylesheets-remove'])) {
             foreach ($base->info['stylesheets-remove'] as $css_file) {
                 $css_file = $this->resolveStyleSheetPlaceholders($css_file);
                 $values['stylesheets_remove'][$css_file] = $css_file;
             }
         }
     }
     // Add stylesheets used by this theme.
     if (!empty($theme->info['stylesheets-remove'])) {
         foreach ($theme->info['stylesheets-remove'] as $css_file) {
             $css_file = $this->resolveStyleSheetPlaceholders($css_file);
             $values['stylesheets_remove'][$css_file] = $css_file;
         }
     }
     // Do basically the same as the above for libraries
     $values['libraries'] = array();
     // Grab libraries from base theme
     foreach ($base_themes as $base) {
         if (!empty($base->libraries)) {
             foreach ($base->libraries as $library) {
                 $values['libraries'][] = $library;
             }
         }
     }
     // Add libraries used by this theme.
     if (!empty($theme->libraries)) {
         foreach ($theme->libraries as $library) {
             $values['libraries'][] = $library;
         }
     }
     $values['engine'] = isset($theme->engine) ? $theme->engine : NULL;
     $values['owner'] = isset($theme->owner) ? $theme->owner : NULL;
     $values['extension'] = $theme;
     $base_active_themes = array();
     foreach ($base_themes as $base_theme) {
         $base_active_themes[$base_theme->getName()] = $this->getActiveTheme($base_theme, array_slice($base_themes, 1));
     }
     $values['base_themes'] = $base_active_themes;
     if (!empty($theme->info['regions'])) {
         $values['regions'] = $theme->info['regions'];
     }
     return new ActiveTheme($values);
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function getFeaturesInfo(Extension $extension)
 {
     $features_info = NULL;
     $filename = $this->root . '/' . $extension->getPath() . '/' . $extension->getName() . '.features.yml';
     if (file_exists($filename)) {
         $features_info = Yaml::decode(file_get_contents($filename));
     }
     return $features_info;
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 public function getFeaturesInfo(Extension $extension)
 {
     $module_name = $extension->getName();
     if (isset($this->featureInfoCache[$module_name])) {
         return $this->featureInfoCache[$module_name];
     }
     $features_info = NULL;
     $filename = $this->root . '/' . $extension->getPath() . '/' . $module_name . '.features.yml';
     if (file_exists($filename)) {
         $features_info = Yaml::decode(file_get_contents($filename));
     }
     $this->featureInfoCache[$module_name] = $features_info;
     return $features_info;
 }