Is the given mapping type predictable in terms of path to class name
public static isAutoloadTypeWithPredictableClassPath ( string $mappingType ) : boolean | ||
$mappingType | string | |
Результат | boolean |
/** * @param PackageInterface $package * @return array */ protected function getPrimaryNamespaceAndEntryPath(PackageInterface $package) { $autoloadConfigurations = $package->getComposerManifest('autoload'); $firstAutoloadType = null; $firstAutoloadConfiguration = null; foreach ($autoloadConfigurations as $autoloadType => $autoloadConfiguration) { if (ClassLoader::isAutoloadTypeWithPredictableClassPath($autoloadType)) { $firstAutoloadType = $autoloadType; $firstAutoloadConfiguration = $autoloadConfiguration; break; } } $autoloadPaths = reset($firstAutoloadConfiguration); $firstAutoloadPath = is_array($autoloadPaths) ? reset($autoloadPaths) : $autoloadPaths; $namespace = key($firstAutoloadConfiguration); $autoloadPathPostfix = ''; if ($firstAutoloadType === ClassLoader::MAPPING_TYPE_PSR0) { $autoloadPathPostfix = str_replace('\\', '/', trim($namespace, '\\')); } return [$namespace, Files::concatenatePaths([$package->getPackagePath(), $firstAutoloadPath, $autoloadPathPostfix]), $firstAutoloadType]; }
/** * Brings the composer autoload configuration into an easy to use format for various parts of Flow. * * @return void */ protected function explodeAutoloadConfiguration() { $this->namespaces = []; $this->autoloadTypes = []; $this->flattenedAutoloadConfiguration = []; $allAutoloadConfiguration = $this->autoloadConfiguration; foreach ($allAutoloadConfiguration as $autoloadType => $autoloadConfiguration) { $this->autoloadTypes[] = $autoloadType; if (ClassLoader::isAutoloadTypeWithPredictableClassPath($autoloadType)) { $this->namespaces = array_merge($this->namespaces, array_keys($autoloadConfiguration)); foreach ($autoloadConfiguration as $namespace => $paths) { $paths = (array) $paths; foreach ($paths as $path) { $this->flattenedAutoloadConfiguration[] = ['namespace' => $namespace, 'classPath' => $this->packagePath . $path, 'mappingType' => $autoloadType]; } } } } }