/** * {@inheritdoc} */ public function generate(array $packages = array(), FeaturesBundleInterface $bundle = NULL) { // If no packages were specified, get all packages. if (empty($packages)) { $packages = $this->featuresManager->getPackages(); } // Determine the best name for the tar archive. // Single package export, so name by package name. if (count($packages) == 1) { $filename = current($packages)['machine_name']; } elseif (isset($bundle) && $bundle->isProfile()) { $filename = $bundle->getProfileName(); } elseif (isset($bundle) && !$bundle->isDefault()) { $filename = $bundle->getMachineName(); } else { $filename = 'generated_features'; } $return = []; $this->archiveName = $filename . '.tar.gz'; $archive_name = file_directory_temp() . '/' . $this->archiveName; if (file_exists($archive_name)) { file_unmanaged_delete($archive_name); } $archiver = new ArchiveTar($archive_name); // Add package files. foreach ($packages as $package) { if (count($packages) == 1) { // Single module export, so don't generate entire modules dir structure. $package['directory'] = $package['machine_name']; } $this->generatePackage($return, $package, $archiver); } return $return; }
/** * {@inheritdoc} */ public function generate(array $packages = array(), FeaturesBundleInterface $bundle = NULL) { // If no packages were specified, get all packages. if (empty($packages)) { $packages = $this->featuresManager->getPackages(); } $return = []; // Add profile files. if (isset($bundle) && $bundle->isProfile()) { $profile_package = $this->featuresManager->getPackage($bundle->getProfileName()); if (!empty($profile_package)) { $this->generatePackage($return, $profile_package); } } // Add package files. // We need to update the system.module.files state because it's cached. // Cannot just call system_rebuild_module_data() because $listing->scan() has // it's own internal static cache that we cannot clear at this point. $files = \Drupal::state()->get('system.module.files'); foreach ($packages as $package) { $this->generatePackage($return, $package); if (!isset($files[$package['machine_name']]) && isset($package['files']['info'])) { $files[$package['machine_name']] = $package['directory'] . '/' . $package['files']['info']['filename']; } } // Rebuild system module cache \Drupal::state()->set('system.module.files', $files); return $return; }
/** * {@inheritdoc} */ public function getExportInfo($package, FeaturesBundleInterface $bundle = NULL) { $full_name = $package['machine_name']; $path = ''; // Adjust export directory to be in profile. if (isset($bundle) && $bundle->isProfile()) { $path .= 'profiles/' . $bundle->getProfileName(); } // If this is not the profile package, nest the directory. if (!isset($bundle) || !$bundle->isProfilePackage($package['machine_name'])) { $path .= empty($path) ? 'modules' : '/modules'; $export_settings = $this->getExportSettings(); if (!empty($export_settings['folder'])) { $path .= '/' . $export_settings['folder']; } } return array($full_name, $path); }
/** * {@inheritdoc} */ public function getExportInfo(Package $package, FeaturesBundleInterface $bundle = NULL) { $full_name = isset($bundle) ? $bundle->getFullName($package->getMachineName()) : $package->getMachineName(); $path = ''; // Adjust export directory to be in profile. if (isset($bundle) && $bundle->isProfile()) { $path .= 'profiles/' . $bundle->getProfileName(); } // If this is not the profile package, nest the directory. if (!isset($bundle) || !$bundle->isProfilePackage($package->getMachineName())) { $path .= empty($path) ? 'modules' : '/modules'; $export_settings = $this->getExportSettings(); if (!empty($export_settings['folder'])) { $path .= '/' . $export_settings['folder']; } } // Use the same path of a package to override it. if ($extension = $package->getExtension()) { $extension_path = $extension->getPath(); $path = dirname($extension_path); } return array($full_name, $path); }
/** * {@inheritdoc} */ public function getExportInfo($package, FeaturesBundleInterface $bundle = NULL) { $full_name = $package['machine_name']; if (isset($bundle) && $bundle->isProfile()) { // Adjust export directory to be in profile. $path = 'profiles/' . $bundle->getProfileName() . '/modules'; } else { $path = 'modules'; } $export_settings = $this->getExportSettings(); if (!empty($export_settings['folder'])) { $path .= '/' . $export_settings['folder']; } return array($full_name, $path); }