Neos\Flow\Package\PackageManager::getPackage PHP Method

getPackage() public method

Returns a PackageInterface object for the specified package.
public getPackage ( string $packageKey ) : Neos\Flow\Package\PackageInterface
$packageKey string
return Neos\Flow\Package\PackageInterface The requested package object
    public function getPackage($packageKey)
    {
        if (!$this->isPackageAvailable($packageKey)) {
            throw new Exception\UnknownPackageException('Package "' . $packageKey . '" is not available. Please check if the package exists and that the package key is correct (package keys are case sensitive).', 1166546734);
        }
        return $this->packages[$packageKey];
    }

Usage Example

 /**
  * @test
  * @expectedException \Neos\Flow\Package\Exception\UnknownPackageException
  */
 public function getPackageThrowsExceptionOnUnknownPackage()
 {
     $this->packageManager->getPackage('PrettyUnlikelyThatThisPackageExists');
 }