/**
  * Constructor
  *
  * @param \TYPO3\Flow\Package\PackageManager $packageManager the package manager which knows this package
  * @param string $packageKey Key of this package
  * @param string $packagePath Absolute path to the location of the package's composer manifest
  * @param string $classesPath Path the classes of the package are in, relative to $packagePath. Optional, read from Composer manifest if not set.
  * @param string $manifestPath Path the composer manifest of the package, relative to $packagePath. Optional, defaults to ''.
  * @throws \TYPO3\Flow\Package\Exception\InvalidPackageKeyException if an invalid package key was passed
  * @throws \TYPO3\Flow\Package\Exception\InvalidPackagePathException if an invalid package path was passed
  * @throws \TYPO3\Flow\Package\Exception\InvalidPackageManifestException if no composer manifest file could be found
  */
 public function __construct(\TYPO3\Flow\Package\PackageManager $packageManager, $packageKey, $packagePath, $classesPath = NULL, $manifestPath = '')
 {
     if (!$packageManager->isPackageKeyValid($packageKey)) {
         throw new \TYPO3\Flow\Package\Exception\InvalidPackageKeyException('"' . $packageKey . '" is not a valid package key.', 1217959511);
     }
     if (!(@is_dir($packagePath) || \TYPO3\Flow\Utility\Files::is_link($packagePath) && is_dir(\TYPO3\Flow\Utility\Files::getNormalizedPath($packagePath)))) {
         throw new \TYPO3\Flow\Package\Exception\InvalidPackagePathException(sprintf('Tried to instantiate a package object for package "%s" with a non-existing package path "%s". Either the package does not exist anymore, or the code creating this object contains an error.', $packageKey, $packagePath), 1166631890);
     }
     if (substr($packagePath, -1, 1) !== '/') {
         throw new \TYPO3\Flow\Package\Exception\InvalidPackagePathException(sprintf('The package path "%s" provided for package "%s" has no trailing forward slash.', $packagePath, $packageKey), 1166633722);
     }
     if ($classesPath[1] === '/') {
         throw new \TYPO3\Flow\Package\Exception\InvalidPackagePathException(sprintf('The package classes path provided for package "%s" has a leading forward slash.', $packageKey), 1334841321);
     }
     if (!@file_exists($packagePath . $manifestPath . 'ext_emconf.php')) {
         throw new \TYPO3\Flow\Package\Exception\InvalidPackageManifestException(sprintf('No ext_emconf file found for package "%s". Please create one at "%sext_emconf.php".', $packageKey, $manifestPath), 1360403545);
     }
     $this->packageManager = $packageManager;
     $this->manifestPath = $manifestPath;
     $this->packageKey = $packageKey;
     $this->packagePath = \TYPO3\Flow\Utility\Files::getNormalizedPath($packagePath);
     $this->classesPath = \TYPO3\Flow\Utility\Files::getNormalizedPath(\TYPO3\Flow\Utility\Files::concatenatePaths(array($this->packagePath, self::DIRECTORY_CLASSES)));
     try {
         $this->getComposerManifest();
     } catch (\TYPO3\Flow\Package\Exception\MissingPackageManifestException $exception) {
         $this->getExtensionEmconf($packageKey, $this->packagePath);
     }
     $this->loadFlagsFromComposerManifest();
     if ($this->objectManagementEnabled === NULL) {
         $this->objectManagementEnabled = FALSE;
     }
 }
Ejemplo n.º 2
0
 /**
  * Check the conformance of the given package key
  *
  * @param string $packageKey The package key to validate
  * @return boolean If the package key is valid, returns TRUE otherwise FALSE
  * @api
  */
 public function isPackageKeyValid($packageKey)
 {
     return parent::isPackageKeyValid($packageKey) || preg_match(\TYPO3\CMS\Core\Package\Package::PATTERN_MATCH_EXTENSIONKEY, $packageKey) === 1;
 }