Get the library package (not asset package).

@param OperationInterface $operation The operation

@return null|PackageInterface Return NULL if the package is an asset
979485
protected static function getLibraryPackage(OperationInterface $operation)
    {
        $package = static::getOperationPackage($operation);
        $data = null;

        if ($package && !static::isAsset($package)) {
            $data = $package;
        }

        return $data;
    }
517232
public static function get(Composer $composer): ?ProjectTypeInterface
    {
        $rootDir = dirname($composer->getConfig()->getConfigSource()->getName());

        $classes = static::getClasses($composer);

        $composerProjectType = $composer->getPackage()->getExtra()['rikudou']['installer']['project-type'] ?? null;
        if ($composerProjectType && isset($classes[$composerProjectType])) {
            $class = $classes[$composerProjectType];

            return new $class;
        }

        foreach ($classes as $class) {
            /** @var ProjectTypeInterface $instance */
            $instance = new $class;
            foreach ($instance->getDirs() as $dir) {
                if (is_array($dir)) {
                    $exists = true;
                    foreach ($dir as $requiredDir) {
                        $exists = $exists && file_exists("{$rootDir}/{$requiredDir}");
                    }
                    if ($exists) {
                        return $instance;
                    }
                } else {
                    if (file_exists("{$rootDir}/{$dir}")) {
                        return $instance;
                    }
                }
            }
        }

        return null;
    }
242194
protected function getClassFromOperation($name, Operation $operation = null, $reference, $registry)
    {
        if (null === $operation) {
            return;
        }

        if ($operation->getParameters()) {
            foreach ($operation->getParameters() as $key => $parameter) {
                if ($parameter instanceof BodyParameter) {
                    $this->chainGuesser->guessClass($parameter->getSchema(), $name . 'Body', $reference . '/parameters/' . $key, $registry);
                }
            }
        }

        if ($operation->getRequestBody() && $operation->getRequestBody()->getContent()) {
            foreach ($operation->getRequestBody()->getContent() as $contentType => $content) {
                $this->chainGuesser->guessClass($content->getSchema(), $name . 'Body', $reference . '/requestBody/content/' . $contentType . '/schema', $registry);
            }
        }

        if ($operation->getResponses()) {
            foreach ($operation->getResponses() as $status => $response) {
                if ($response instanceof Response && $response->getContent()) {
                    foreach ($response->getContent() as $contentType => $content) {
                        $this->chainGuesser->guessClass($content->getSchema(), $name . 'Response' . $status, $reference . '/responses/' . $status . '/content/' . $contentType . '/schema', $registry);
                    }
                }
            }
        }
    }
337159
public function process($src, OperationInterface $operation)
    {
        $callable = $operation->getCallback();
        $arguments = array_merge([$src], $operation->getArguments());
        $res = call_user_func_array($callable, $arguments);
        return $res ?: $src;
    }
712718
public function getProcessor(OperationInterface $operation)
    {
        $operationClass = get_class($operation);
        if (!array_key_exists($operationClass, $this->processors)) {
            throw new ProcessorNotFoundException(
                $operationClass,
                get_class($this)
            );
        }
        $processorClass = $this->processors[$operationClass];
        return new $processorClass();
    }
772425
public function getLibrary(PackageEvent $event)
    {
        // Ensure package is the valid type
        $package = $this->getOperationPackage($event);
        if (!$package) {
            return null;
        }

        // Get appropriate installer and query install path
        $installer = $event->getComposer()->getInstallationManager()->getInstaller($package->getType());
        $path = $installer->getInstallPath($package);

        // Build module
        return new Library($this->getProjectPath(), $path);
    }
666537
public function get(string $package, string $feature = null, string $option = null)
    {
        if (empty($feature) && empty($option)) {
            preg_match('/(\w+)\.(\w+)(\.\w+)?/', $package, $match);

            $package = $match[1];
            $feature = $match[2];
            $option = $match[3] ?? null;
        }

        $parameters = [];
        $parameterName = self::makeParameterName($package, $feature);

        if (array_key_exists($parameterName, $this->cached)) {
            $parameters = $this->cached[$parameterName];
        } else {
            if ($this->parameter->has($parameterName)) {
                $this->cached[$parameterName] = $parameters = $this->parameter->get($parameterName);
            }
        }

        if (empty($option)) {
            return $parameters;
        }

        return (new Dot((array)$parameters))->get(ltrim($option, '.'), null);
    }
314767
public static Map<Method, OperationId> getMethodMap(Class<?> serviceInterface) {
    if (!serviceInterface.isInterface()) {
      Map<Method, OperationId> operations = new HashMap<>();
      for (Class<?> iface : serviceInterface.getInterfaces()) {
        operations.putAll(findMethods(iface));
      }
      return operations;
    }
    return findMethods(serviceInterface);
  }
372500
protected function getPackage(PackageEvent $event)
    {
        $operation = $event->getOperation();
        
        if (method_exists($operation, 'getPackage')) {
            return $operation->getPackage();
        }
        
        return $operation->getTargetPackage();
    }
17922
public function install(): OperationResult
    {
        $result = new OperationResult();

        $sourcePath = "{$this->packageInstallDir}/.installer/%s/files";
        foreach ($this->projectType->getProjectDirs() as $projectDir) {
            if (is_dir(sprintf($sourcePath, $projectDir))) {
                /** @var \RecursiveDirectoryIterator $iterator */
                $iterator = new \RecursiveIteratorIterator(
                    new \RecursiveDirectoryIterator(
                        sprintf($sourcePath, $projectDir),
                        \RecursiveDirectoryIterator::SKIP_DOTS
                    ),
                    \RecursiveIteratorIterator::SELF_FIRST
                );

                /** @var \SplFileInfo $file */
                foreach ($iterator as $file) {
                    $target = "{$this->projectRootDir}/{$iterator->getSubPathname()}";
                    if ($file->isDir()) {
                        if (!is_dir($target)) {
                            if (!mkdir($target)) {
                                $result->addErrorMessage("<error>Could not create target directory '${target}'</error>");
                            }
                        }
                    } elseif (!file_exists($target)) {
                        assert(is_string($file->getRealPath()));
                        if (!copy($file->getRealPath(), $target)) {
                            $result->addErrorMessage("<error>Could not copy file to '${target}'</error>");
                        }
                    }
                }
            }
        }

        if (!$result->isFailure()) {
            $result->addStatusMessage("Successfully copied files from package {$this->packageName}");
        }

        return $result;
    }
248903
public function getInstallPath( PackageInterface $package, $frameworkType = '' ) {
		$type = $this->package->getType();

		$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'];
		}

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

		$packageType = substr($type, strlen($frameworkType) + 1);
		if( !isset($this->locations[$packageType]) ) {
			throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
		}

		return $this->templatePath($this->locations[$packageType], $availableVars);
	}
603777
public function getPackage($name = null)
    {
        /** @var PackageResolver $resolver */
        $resolver = $this->container->get('package.resolver');

        return $resolver->getPackage($name);
    }
578645
public function process($src, OperationInterface $operation)
    {
        $field = $operation->getField();
        $order = $operation->getOrder();
        $src->order .= "ORDER BY $field $order";
        return $src;
    }
1194481
public function getPackage(string $package): Package
	{
		if(!isset($this->packages[$package]))
		{
			throw new RuntimeException(vsprintf('Unknown package [ %s ].', [$package]));
		}

		return $this->packages[$package];
	}
293197
protected function ensureContext(OperationContextInterface $context = null)
    {
        if ($context === null) {
            $context = $this->getSession()->getDefaultContext();
        }

        return $context;
    }
840686
protected function getPackageFromOperation(OperationInterface $operation)
    {
        if ($operation instanceof InstallOperation) {
            $package = $operation->getPackage();
        } elseif ($operation instanceof UpdateOperation) {
            $package = $operation->getTargetPackage();
        } else {
            throw new \Exception('Unknown operation: ' . get_class($operation));
        }

        return $package;
    }
296038
public function removeOperation(OperationInterface $operation)
    {
        if ($this->operations->contains($operation)) {
            $this->operations->removeElement($operation);
        }

        return $this;
    }