/** * Index action * * @return void * @author Christopher Hlubek <*****@*****.**> * @author Robert Lemke <*****@*****.**> * @author Bastian Waidelich <*****@*****.**> */ public function indexAction() { $this->view->assign('flow3PathRoot', realpath(FLOW3_PATH_ROOT)); $this->view->assign('flow3PathWeb', realpath(FLOW3_PATH_WEB)); $this->view->assign('myPackageUrl', $this->uriBuilder->uriFor('index', array(), 'Standard', 'MyPackage')); $this->view->assign('isWindows', $this->isWindows()); $flow3Package = $this->packageManager->getPackage('FLOW3'); $version = $flow3Package->getPackageMetaData()->getVersion(); $this->view->assign('version', $version); $activePackages = $this->packageManager->getActivePackages(); $this->view->assign('activePackages', $activePackages); $this->view->assign('notDevelopmentContext', $this->objectManager->getContext() !== 'Development'); }
/** * The view action loads the file from the given documentation and * acts as a proxy between the documentation browser and the private * documentation, that is not directly accessible. * * @param string $packageKey The package key * @param string $documentationName The documentation name * @param string $language The language * @param string $file The file to display * @return string The file contents * @author Christopher Hlubek <*****@*****.**> */ public function viewAction($packageKey, $documentationName, $language, $file) { $packageKey = $this->packageManager->getCaseSensitivePackageKey($packageKey); $package = $this->packageManager->getPackage($packageKey); $documentations = $package->getPackageDocumentations(); foreach ($documentations as $iteratedDocumentationName => $iteratedDocumentation) { if (strtolower($iteratedDocumentationName) == strtolower($documentationName)) { $documentation = $iteratedDocumentation; break; } } if (!isset($documentation)) { return 'Documentation for ' . $packageKey . ' / ' . $documentationName . ' not found'; } $formats = $documentation->getDocumentationFormats(); if (!isset($formats['HTML'])) { return 'HTML documentation for ' . $packageKey . ' not found'; } $format = $formats['HTML']; $contentType = $this->guessContentTypeByFilename($file); header('Content-Type: ' . $contentType); $path = $format->getFormatPath() . $language . '/' . $file; $path = dirname($path) . '/' . basename($path); if (strpos($path, $documentation->getDocumentationPath()) !== 0) { return 'Invalid file for documentation'; } return file_get_contents($path); }
/** * Retrieve information about a file. * * This method is called in response to all stat() related functions. * * $flags can hold one or more of the following values OR'd together: * STREAM_URL_STAT_LINK * For resources with the ability to link to other resource (such as an * HTTP Location: forward, or a filesystem symlink). This flag specified * that only information about the link itself should be returned, not * the resource pointed to by the link. This flag is set in response to * calls to lstat(), is_link(), or filetype(). * STREAM_URL_STAT_QUIET * If this flag is set, your wrapper should not raise any errors. If * this flag is not set, you are responsible for reporting errors using * the trigger_error() function during stating of the path. * * @param string $path The file path or URL to stat. Note that in the case of a URL, it must be a :// delimited URL. Other URL forms are not supported. * @param integer $flags Holds additional flags set by the streams API. * @return array Should return as many elements as stat() does. Unknown or unavailable values should be set to a rational value (usually 0). * @author Karsten Dambekalns <*****@*****.**> */ public function pathStat($path, $flags) { $this->checkScheme($path); $uri = $this->objectFactory->create('F3\\FLOW3\\Property\\DataType\\Uri', $path); $package = $this->packageManager->getPackage($uri->getHost()); $path = \F3\FLOW3\Utility\Files::concatenatePaths(array($package->getResourcesPath(), $uri->getPath())); if (file_exists($path)) { return stat($path); } else { return FALSE; } }
/** * Initializes the cache framework * * @return void * @author Robert Lemke <*****@*****.**> * @see initialize() */ public function initializeCache() { $this->cacheManager = $this->objectManager->getObject('F3\\FLOW3\\Cache\\CacheManager'); $this->cacheManager->setCacheConfigurations($this->configurationManager->getConfiguration(\F3\FLOW3\Configuration\ConfigurationManager::CONFIGURATION_TYPE_CACHES)); $this->cacheManager->initialize(); $cacheFactory = $this->objectManager->getObject('F3\\FLOW3\\Cache\\CacheFactory'); $cacheFactory->setCacheManager($this->cacheManager); $coreCache = $this->cacheManager->getCache('FLOW3_Core'); $cachedRevision = $coreCache->has('revision') ? $coreCache->get('revision') : NULL; $currentRevision = $this->packageManager->getPackage('FLOW3')->getPackageMetaData()->getVersion() . ' (r' . substr(self::REVISION, 11, -2) . ')'; if ($cachedRevision !== $currentRevision) { $this->systemLogger->log('The caches are based on FLOW3 ' . $cachedRevision . ' not matching ' . $currentRevision . ', therefore flushing all caches.', LOG_NOTICE); $this->cacheManager->flushCaches(); $coreCache->set('revision', $currentRevision); } }
/** * Generate a repository for a model given a model name and package key * * @param string $packageKey The package key * @param string $modelName The name of the model * @return array An array of generated filenames * @author Christopher Hlubek <*****@*****.**> */ public function generateRepository($packageKey, $modelName) { $modelName = ucfirst($modelName); $repositoryClassName = $modelName . 'Repository'; $namespace = 'F3\\' . $packageKey . '\\Domain\\Repository'; $templatePathAndFilename = 'package://Kickstart/Private/Generator/Repository/RepositoryTemplate.php.tmpl'; $contextVariables = array(); $contextVariables['packageKey'] = $packageKey; $contextVariables['modelName'] = $modelName; $contextVariables['repositoryClassName'] = $repositoryClassName; $contextVariables['namespace'] = $namespace; $fileContent = $this->renderTemplate($templatePathAndFilename, $contextVariables); $repositoryFilename = $repositoryClassName . '.php'; $repositoryPath = $this->packageManager->getPackage($packageKey)->getClassesPath() . 'Domain/Repository/'; $targetPathAndFilename = $repositoryPath . $repositoryFilename; $this->generateFile($targetPathAndFilename, $fileContent); return $this->generatedFiles; }