Example #1
0
 /**
  * Initializes and returns a package or profile array.
  *
  * @param string $machine_name
  *   Machine name of the package.
  * @param string $name
  *   (optional) Human readable name of the package.
  * @param string $description
  *   (optional) Description of the package.
  * @param string $type
  *   (optional) Type of project.
  * @param \Drupal\features\FeaturesBundleInterface $bundle
  *   (optional) Bundle to use to add profile directories to the scan.
  * @param \Drupal\Core\Extension\Extension $extension
  *   (optional) An Extension object.
  *
  * @return \Drupal\features\Package
  *   An array of package properties; see
  *   FeaturesManagerInterface::getPackages().
  */
 protected function getPackageObject($machine_name, $name = NULL, $description = '', $type = 'module', FeaturesBundleInterface $bundle = NULL, Extension $extension = NULL)
 {
     if (!isset($bundle)) {
         $bundle = $this->getAssigner()->getBundle();
     }
     $package = new Package($machine_name, ['name' => isset($name) ? $name : ucwords(str_replace(['_', '-'], ' ', $machine_name)), 'description' => $description, 'type' => $type, 'core' => Drupal::CORE_COMPATIBILITY, 'dependencies' => [], 'themes' => [], 'config' => [], 'status' => FeaturesManagerInterface::STATUS_DEFAULT, 'version' => '', 'state' => FeaturesManagerInterface::STATE_DEFAULT, 'directory' => $machine_name, 'files' => [], 'bundle' => $bundle->isDefault() ? '' : $bundle->getMachineName(), 'extension' => NULL, 'info' => [], 'configOrig' => []]);
     // If no extension was passed in, look for a match.
     if (!isset($extension)) {
         $module_list = $this->getFeaturesModules($bundle);
         $full_name = $bundle->getFullName($package->getMachineName());
         if (isset($module_list[$full_name])) {
             $extension = $module_list[$full_name];
         }
     }
     // If there is an extension, set extension-specific properties.
     if (isset($extension)) {
         $info = $this->getExtensionInfo($extension);
         $features_info = $this->getFeaturesInfo($extension);
         $package->setExtension($extension);
         $package->setInfo($info);
         $package->setFeaturesInfo($features_info);
         $package->setConfigOrig($this->listExtensionConfig($extension));
         $package->setStatus($this->moduleHandler->moduleExists($extension->getName()) ? FeaturesManagerInterface::STATUS_INSTALLED : FeaturesManagerInterface::STATUS_UNINSTALLED);
         $package->setVersion(isset($info['version']) ? $info['version'] : '');
     }
     return $package;
 }