getPackage() public method

A package is available, if the package directory contains valid meta information.
public getPackage ( string $packageKey ) : Neos\Flow\Package\PackageInterface
$packageKey string
return Neos\Flow\Package\PackageInterface
Esempio n. 1
0
 /**
  * Set the routes configuration for the Neos setup and configures the routing component
  * to skip initialisation, which would overwrite the specific settings again.
  *
  * @param ComponentContext $componentContext
  * @return void
  */
 public function handle(ComponentContext $componentContext)
 {
     $configurationSource = $this->objectManager->get(\Neos\Flow\Configuration\Source\YamlSource::class);
     $routesConfiguration = $configurationSource->load($this->packageManager->getPackage('Neos.Setup')->getConfigurationPath() . ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
     $this->router->setRoutesConfiguration($routesConfiguration);
     $componentContext->setParameter(\Neos\Flow\Mvc\Routing\RoutingComponent::class, 'skipRouterInitialization', true);
 }
Esempio n. 2
0
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     $this->view->assign('flowPathRoot', realpath(FLOW_PATH_ROOT));
     $this->view->assign('flowPathWeb', realpath(FLOW_PATH_WEB));
     $this->view->assign('isMyPackageActive', $this->packageManager->isPackageActive('MyCompany.MyPackage'));
     $baseUri = $this->request->getHttpRequest()->getBaseUri();
     $this->view->assign('baseUri', $baseUri);
     $this->view->assign('isWindows', DIRECTORY_SEPARATOR !== '/');
     $flowPackage = $this->packageManager->getPackage('Neos.Flow');
     $version = $flowPackage->getInstalledVersion();
     $this->view->assign('version', $version);
     $activePackages = $this->packageManager->getActivePackages();
     $this->view->assign('activePackages', $activePackages);
     $this->view->assign('notDevelopmentContext', !$this->objectManager->getContext()->isDevelopment());
 }
 /**
  * Generate a documentation skeleton for the package key
  *
  * @param string $packageKey The package key
  * @return array An array of generated filenames
  */
 public function generateDocumentation($packageKey)
 {
     $documentationPath = Files::concatenatePaths([$this->packageManager->getPackage($packageKey)->getPackagePath(), 'Documentation']);
     $contextVariables = array();
     $contextVariables['packageKey'] = $packageKey;
     $templatePathAndFilename = 'resource://Neos.Kickstarter/Private/Generator/Documentation/conf.py';
     $fileContent = $this->renderTemplate($templatePathAndFilename, $contextVariables);
     $targetPathAndFilename = $documentationPath . '/conf.py';
     $this->generateFile($targetPathAndFilename, $fileContent);
     $templatePathAndFilename = 'resource://Neos.Kickstarter/Private/Generator/Documentation/Makefile';
     $fileContent = file_get_contents($templatePathAndFilename);
     $targetPathAndFilename = $documentationPath . '/Makefile';
     $this->generateFile($targetPathAndFilename, $fileContent);
     $templatePathAndFilename = 'resource://Neos.Kickstarter/Private/Generator/Documentation/index.rst';
     $fileContent = $this->renderTemplate($templatePathAndFilename, $contextVariables);
     $targetPathAndFilename = $documentationPath . '/index.rst';
     $this->generateFile($targetPathAndFilename, $fileContent);
     $targetPathAndFilename = $documentationPath . '/_build/.gitignore';
     $this->generateFile($targetPathAndFilename, '*' . chr(10) . '!.gitignore' . chr(10));
     $targetPathAndFilename = $documentationPath . '/_static/.gitignore';
     $this->generateFile($targetPathAndFilename, '*' . chr(10) . '!.gitignore' . chr(10));
     $targetPathAndFilename = $documentationPath . '/_templates/.gitignore';
     $this->generateFile($targetPathAndFilename, '*' . chr(10) . '!.gitignore' . chr(10));
     return $this->generatedFiles;
 }
 /**
  * Return the json array for a given locale, sourceCatalog, xliffPath and package.
  * The json will be cached.
  *
  * @param Locale $locale The locale
  * @return Result
  * @throws Exception
  */
 public function getCachedJson(Locale $locale)
 {
     $cacheIdentifier = md5($locale);
     if ($this->xliffToJsonTranslationsCache->has($cacheIdentifier)) {
         $json = $this->xliffToJsonTranslationsCache->get($cacheIdentifier);
     } else {
         $labels = [];
         $localeChain = $this->localizationService->getLocaleChain($locale);
         foreach ($this->packagesRegisteredForAutoInclusion as $packageKey => $sourcesToBeIncluded) {
             if (!is_array($sourcesToBeIncluded)) {
                 continue;
             }
             $translationBasePath = Files::concatenatePaths([$this->packageManager->getPackage($packageKey)->getResourcesPath(), $this->xliffBasePath]);
             // We merge labels in the chain from the worst choice to best choice
             foreach (array_reverse($localeChain) as $allowedLocale) {
                 $localeSourcePath = Files::getNormalizedPath(Files::concatenatePaths([$translationBasePath, $allowedLocale]));
                 foreach ($sourcesToBeIncluded as $sourceName) {
                     foreach (glob($localeSourcePath . $sourceName . '.xlf') as $xliffPathAndFilename) {
                         $xliffPathInfo = pathinfo($xliffPathAndFilename);
                         $sourceName = str_replace($localeSourcePath, '', $xliffPathInfo['dirname'] . '/' . $xliffPathInfo['filename']);
                         $labels = Arrays::arrayMergeRecursiveOverrule($labels, $this->parseXliffToArray($xliffPathAndFilename, $packageKey, $sourceName));
                     }
                 }
             }
         }
         $json = json_encode($labels);
         $this->xliffToJsonTranslationsCache->set($cacheIdentifier, $json);
     }
     return $json;
 }
 /**
  * @param string $packageKey
  * @return string|null
  */
 protected function getPackagePrivateResourcesPath($packageKey)
 {
     if (!$this->packageManager->isPackageActive($packageKey)) {
         return null;
     }
     $packageResourcesPath = $this->packageManager->getPackage($packageKey)->getResourcesPath();
     return Files::concatenatePaths([$packageResourcesPath, 'Private']);
 }
Esempio n. 6
0
 /**
  * Generate additional folders for site packages.
  *
  * @param string $packageKey
  */
 protected function generateAdditionalFolders($packageKey)
 {
     $resourcesPath = $this->packageManager->getPackage($packageKey)->getResourcesPath();
     $publicResourcesPath = Files::concatenatePaths(array($resourcesPath, 'Public'));
     foreach (array('Images', 'JavaScript', 'Styles') as $publicResourceFolder) {
         Files::createDirectoryRecursively(Files::concatenatePaths(array($publicResourcesPath, $publicResourceFolder)));
     }
 }
Esempio n. 7
0
 /**
  * @param PaletteInterface $proxy
  * @param $profilePath
  * @return \Imagine\Image\Profile
  */
 protected function createAndSetProfileOnProxy(PaletteInterface $proxy, $profilePath)
 {
     if (substr($profilePath, 0, 11) !== 'resource://') {
         $profilePath = $this->packageManager->getPackage('imagine.imagine')->getPackagePath() . 'lib/Imagine/resources/' . $profilePath;
     }
     $profile = Profile::fromPath($profilePath);
     ObjectAccess::setProperty($proxy, 'profile', $profile, TRUE);
     return $profile;
 }
 /**
  * A edit view for a site and its settings.
  *
  * @param Site $site Site to view
  * @Flow\IgnoreValidation("$site")
  * @return void
  */
 public function editAction(Site $site)
 {
     try {
         $sitePackage = $this->packageManager->getPackage($site->getSiteResourcesPackageKey());
     } catch (\Exception $e) {
         $this->addFlashMessage('The site package with key "%s" was not found.', 'Site package not found', Message::SEVERITY_ERROR, array(htmlspecialchars($site->getSiteResourcesPackageKey())));
     }
     $this->view->assignMultiple(array('site' => $site, 'sitePackage' => isset($sitePackage) ? $sitePackage : array(), 'domains' => $this->domainRepository->findBySite($site), 'assetCollections' => $this->assetCollectionRepository->findAll()));
 }
 /**
  * @return void
  */
 protected function displayHelpIndex()
 {
     $context = $this->bootstrap->getContext();
     $applicationPackage = $this->packageManager->getPackage($this->applicationPackageKey);
     $this->outputLine('<b>%s %s ("%s" context)</b>', [$applicationPackage->getComposerManifest('description'), $applicationPackage->getInstalledVersion() ?: 'dev', $context]);
     $this->outputLine('<i>usage: %s <command identifier></i>', [$this->getFlowInvocationString()]);
     $this->outputLine();
     $this->outputLine('The following commands are currently available:');
     $this->displayShortHelpForCommands($this->commandManager->getAvailableCommands());
     $this->outputLine('* = compile time command');
     $this->outputLine();
     $this->outputLine('See "%s help <commandidentifier>" for more information about a specific command.', [$this->getFlowInvocationString()]);
     $this->outputLine();
 }
 /**
  * @param string $driver
  * @return array Not supported image format
  */
 protected function findUnsupportedImageFormats($driver)
 {
     $this->imagineFactory->injectSettings(array('driver' => ucfirst($driver)));
     $imagine = $this->imagineFactory->create();
     $unsupportedFormats = array();
     foreach (array('jpg', 'gif', 'png') as $imageFormat) {
         $imagePath = Files::concatenatePaths(array($this->packageManager->getPackage('Neos.Neos')->getResourcesPath(), 'Private/Installer/TestImages/Test.' . $imageFormat));
         try {
             $imagine->open($imagePath);
         } catch (\Exception $exception) {
             $unsupportedFormats[] = sprintf('"%s"', $imageFormat);
         }
     }
     return $unsupportedFormats;
 }
 /**
  * Evaluates the absolute path and filename of the resource file specified
  * by the given path.
  *
  * @param string $requestedPath
  * @param boolean $checkForExistence Whether a (non-hash) path should be checked for existence before being returned
  * @return mixed The full path and filename or FALSE if the file doesn't exist
  * @throws \InvalidArgumentException|ResourceException
  */
 protected function evaluateResourcePath($requestedPath, $checkForExistence = true)
 {
     if (substr($requestedPath, 0, strlen(self::SCHEME)) !== self::SCHEME) {
         throw new \InvalidArgumentException('The ' . __CLASS__ . ' only supports the \'' . self::SCHEME . '\' scheme.', 1256052544);
     }
     $uriParts = Functions::parse_url($requestedPath);
     if (!is_array($uriParts) || !isset($uriParts['host'])) {
         return false;
     }
     if (preg_match('/^[0-9a-f]{40}$/i', $uriParts['host']) === 1) {
         $resource = $this->resourceManager->getResourceBySha1($uriParts['host']);
         return $this->resourceManager->getStreamByResource($resource);
     }
     if (!$this->packageManager->isPackageAvailable($uriParts['host'])) {
         throw new ResourceException(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $uriParts['host']), 1309269952);
     }
     $package = $this->packageManager->getPackage($uriParts['host']);
     $resourceUri = Files::concatenatePaths([$package->getResourcesPath(), $uriParts['path']]);
     if ($checkForExistence === false || file_exists($resourceUri)) {
         return $resourceUri;
     }
     return false;
 }
Esempio n. 12
0
 /**
  * Stores the current reflection data related to classes of the specified package
  * in the PrecompiledReflectionData directory for the current context.
  *
  * This method is used by the package manager.
  *
  * @param string $packageKey
  * @return void
  */
 public function freezePackageReflection($packageKey)
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     $package = $this->packageManager->getPackage($packageKey);
     $packageNamespace = $package->getNamespace() . '\\';
     $reflectionData = ['classReflectionData' => $this->classReflectionData, 'classSchemata' => $this->classSchemata, 'annotatedClasses' => $this->annotatedClasses, 'classesByMethodAnnotations' => $this->classesByMethodAnnotations];
     $reflectionData['classReflectionData'] = $this->filterArrayByClassesInNamespace($reflectionData['classReflectionData'], $packageNamespace);
     $reflectionData['classSchemata'] = $this->filterArrayByClassesInNamespace($reflectionData['classSchemata'], $packageNamespace);
     $reflectionData['annotatedClasses'] = $this->filterArrayByClassesInNamespace($reflectionData['annotatedClasses'], $packageNamespace);
     $reflectionData['classesByMethodAnnotations'] = isset($reflectionData['classesByMethodAnnotations']) ? $reflectionData['classesByMethodAnnotations'] : [];
     $methodAnnotationsFilters = function ($className) use($packageNamespace) {
         return strpos($className, $packageNamespace) === 0;
     };
     foreach ($reflectionData['classesByMethodAnnotations'] as $annotationClassName => $classNames) {
         $reflectionData['classesByMethodAnnotations'][$annotationClassName] = array_filter($classNames, $methodAnnotationsFilters);
     }
     $precompiledReflectionStoragePath = $this->getPrecompiledReflectionStoragePath();
     if (!is_dir($precompiledReflectionStoragePath)) {
         Files::createDirectoryRecursively($precompiledReflectionStoragePath);
     }
     $pathAndFilename = $precompiledReflectionStoragePath . $packageKey . '.dat';
     file_put_contents($pathAndFilename, extension_loaded('igbinary') ? igbinary_serialize($reflectionData) : serialize($reflectionData));
 }