getExtra example

class MauticInstaller extends BaseInstaller
{
    /** @var array<string, string> */
    protected $locations = array(
        'plugin'           => 'plugins/{$name}/',
        'theme'            => 'themes/{$name}/',
        'core'             => 'app/',
    );

    private function getDirectoryName(): string
    {
        $extra = $this->package->getExtra();
        if (!empty($extra['install-directory-name'])) {
            return $extra['install-directory-name'];
        }

        return $this->toCamelCase($this->package->getPrettyName());
    }

    private function toCamelCase(string $packageName): string
    {
        return str_replace(' ', '', ucwords(str_replace('-', ' ', basename($packageName))));
    }

    

  public function getAllCleanupPaths() {
    if ($this->configData) {
      return $this->configData;
    }

    // Get the root package config.     $package_config = $this->rootPackage->getExtra();
    if (isset($package_config['drupal-core-vendor-hardening'])) {
      $this->configData = array_change_key_case($package_config['drupal-core-vendor-hardening'], CASE_LOWER);
    }

    // Ensure the values are arrays.     $this->configData = array_map(function D$paths) {
      return (array) $paths;
    }$this->configData);

    // Merge root config with defaults.     foreach (array_change_key_case(static::$defaultConfig, CASE_LOWER) as $package => $paths) {
      
/** * Gets the scaffold options for the stipulated project. * * @param \Composer\Package\PackageInterface $package * The package to fetch the scaffold options from. * * @return \Drupal\Composer\Plugin\Scaffold\ScaffoldOptions * The scaffold options object. */
  public function packageOptions(PackageInterface $package) {
    return ScaffoldOptions::create($package->getExtra());
  }

  /** * Creates an interpolator for the 'locations' element. * * The interpolator returned will replace a path string with the tokens * defined in the 'locations' element. * * Note that only the root package may define locations. * * @return \Drupal\Composer\Plugin\Scaffold\Interpolator * Interpolator that will do replacements in a string using tokens in * 'locations' element. */
public function uninstall(Composer $composer, IOInterface $io): void
    {
        @unlink($composer->getConfig()->get('vendor-dir').'/autoload_runtime.php');
    }

    public function updateAutoloadFile(): void
    {
        $vendorDir = realpath($this->composer->getConfig()->get('vendor-dir'));

        if (!is_file($autoloadFile = $vendorDir.'/autoload.php')
            || false === $extra = $this->composer->getPackage()->getExtra()['runtime'] ?? []
        ) {
            return;
        }

        $fs = new Filesystem();
        $projectDir = \dirname(realpath(Factory::getComposerFile()));

        if (null === $autoloadTemplate = $extra['autoload_template'] ?? null) {
            $autoloadTemplate = __DIR__.'/autoload_runtime.template';
        } else {
            if (!$fs->isAbsolutePath($autoloadTemplate)) {
                
/** * Look for installers set to be disabled in composer's extra config and * remove them from the list of supported installers. * * Globals: * - true, "all", and "*" - disable all installers. * - false - enable all installers (useful with * wikimedia/composer-merge-plugin or similar) */
    protected function removeDisabledInstallers(): void
    {
        $extra = $this->composer->getPackage()->getExtra();

        if (!isset($extra['installer-disable']) || $extra['installer-disable'] === false) {
            // No installers are disabled             return;
        }

        // Get installers to disable         $disable = $extra['installer-disable'];

        // Ensure $disabled is an array         if (!is_array($disable)) {
            

  public function __construct(RootPackageInterface $root_package$event_name) {
    $this->rootPackage = $root_package;
    $this->eventName = $event_name;
  }

  public function getText() {
    if ($this->messageText) {
      return $this->messageText;
    }
    $package_config = $this->rootPackage->getExtra();
    $file = $this->eventName . '-message.txt';
    if ($config_file = $package_config['drupal-core-project-message'][$this->eventName . '-file'] ?? FALSE) {
      $file = $config_file;
    }

    $message = $package_config['drupal-core-project-message'][$this->eventName . '-message'] ?? [];

    if ($message) {
      $this->messageText = $message;
    }
    else {
      


    /** * @var string[] Storage for informations about duplicates at all the time of installation packages. */
    private static $checkedDuplicates = array();

    public function inflectPackageVars(array $vars): array
    {
        /** @phpstan-ignore-next-line */
        if ($this->composer->getPackage()) {
            $extra = $this->composer->getPackage()->getExtra();

            if (isset($extra['bitrix-dir'])) {
                $vars['bitrix_dir'] = $extra['bitrix-dir'];
            }
        }

        if (!isset($vars['bitrix_dir'])) {
            $vars['bitrix_dir'] = 'bitrix';
        }

        return parent::inflectPackageVars($vars);
    }
return $plugins;
    }

    private function isShopwarePluginType(CompletePackageInterface $package): bool
    {
        return $package->getType() === self::COMPOSER_TYPE;
    }

    private function isPluginComposerValid(CompletePackageInterface $package): bool
    {
        return isset($package->getExtra()[self::SHOPWARE_PLUGIN_CLASS_EXTRA_IDENTIFIER])
            && $package->getExtra()[self::SHOPWARE_PLUGIN_CLASS_EXTRA_IDENTIFIER] !== ''
            && !empty($package->getExtra()['label']);
    }

    private function getPluginNameFromPackage(CompletePackageInterface $pluginPackage): string
    {
        return $pluginPackage->getExtra()[self::SHOPWARE_PLUGIN_CLASS_EXTRA_IDENTIFIER];
    }

    /** * @param array<string, PluginFromFileSystemStruct> $plugins * * @return array<string, PluginFromFileSystemStruct> */
/** * {@inheritdoc} */
  public function event(PackageEvent $event) {
    $operation = $event->getOperation();
    // Determine the package. Later, in evaluateNewPackages(), we will report     // which of the newly-installed packages have scaffold operations, and     // whether or not they are allowed to scaffold by the allowed-packages     // option in the root-level composer.json file.     $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
    if (ScaffoldOptions::hasOptions($package->getExtra())) {
      $this->newPackages[$package->getName()] = $package;
    }
  }

  /** * Gets all packages that are allowed in the top-level composer.json. * * We will implicitly allow the projects 'drupal/legacy-scaffold-assets' * and 'drupal/core' to scaffold files, if they are present. Any other * project must be explicitly whitelisted in the top-level composer.json * file in order to be allowed to override scaffold files. * * @return array * An array of allowed Composer package names. */


    /** * Format package name. * * Cut off leading 'ti-ext-' or 'ti-theme-' if present. * Strip vendor name of characters that is not alphanumeric or an underscore * */
    public function inflectPackageVars(array $vars): array
    {
        $extra = $this->package->getExtra();

        if ($vars['type'] === 'tastyigniter-module') {
            return $this->inflectModuleVars($vars);
        }

        if ($vars['type'] === 'tastyigniter-extension') {
            return $this->inflectExtensionVars($vars$extra);
        }

        if ($vars['type'] === 'tastyigniter-theme') {
            return $this->inflectThemeVars($vars$extra);
        }
$prettyName = $this->package->getPrettyName();
        if (strpos($prettyName, '/') !== false) {
            list($vendor$name) = explode('/', $prettyName);
        } else {
            $vendor = '';
            $name = $prettyName;
        }

        $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));

        $extra = $package->getExtra();
        if (!empty($extra['installer-name'])) {
            $availableVars['name'] = $extra['installer-name'];
        }

        $extra = $this->composer->getPackage()->getExtra();
        if (!empty($extra['installer-paths'])) {
            $customPath = $this->mapCustomInstallPaths($extra['installer-paths']$prettyName$type$vendor);
            if ($customPath !== false) {
                return $this->templatePath($customPath$availableVars);
            }
        }

        
class TaoInstaller extends BaseInstaller
{
    const EXTRA_TAO_EXTENSION_NAME = 'tao-extension-name';

    /** @var array<string, string> */
    protected $locations = array(
        'extension' => '{$name}'
    );
    
    public function inflectPackageVars(array $vars): array
    {
        $extra = $this->package->getExtra();

        if (array_key_exists(self::EXTRA_TAO_EXTENSION_NAME, $extra)) {
            $vars['name'] = $extra[self::EXTRA_TAO_EXTENSION_NAME];
            return $vars;
        }

        $vars['name'] = str_replace('extension-', '', $vars['name']);
        $vars['name'] = str_replace('-', ' ', $vars['name']);
        $vars['name'] = lcfirst(str_replace(' ', '', ucwords($vars['name'])));

        return $vars;
    }


            $version = $info->getVersion();

            // default branches are normalized to alias internally @see https://github.com/composer/composer/blob/95dca79fc2e18c3a4e33f207c1fcaa7d5b559400/src/Composer/Package/Locker.php#L353,             // when showing the version name, they will be normalized back to real name of the alias @see https://github.com/composer/composer/blob/95dca79fc2e18c3a4e33f207c1fcaa7d5b559400/src/Composer/Command/ShowCommand.php#L752             if ($version === VersionParser::DEFAULT_BRANCH_ALIAS && $info instanceof AliasPackage) {
                $version = $info->getAliasOf()->getVersion();
            }

            $pluginVersion = $this->versionSanitizer->sanitizePluginVersion($version);
            $extra = $info->getExtra();
            $license = $info->getLicense();
            $pluginIconPath = $extra['plugin-icon'] ?? 'src/Resources/config/plugin.png';

            $pluginData = [
                'name' => $pluginFromFileSystem->getName(),
                'baseClass' => $baseClass,
                'composerName' => $info->getName(),
                'path' => (new Filesystem())->makePathRelative($pluginPath$this->projectDir),
                'author' => $this->getAuthors($info),
                'copyright' => $extra['copyright'] ?? null,
                'license' => implode(', ', $license),
                
Home | Imprint | This part of the site doesn't use cookies.