本文整理汇总了PHP中TYPO3\Flow\Utility\Files::concatenatePaths方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::concatenatePaths方法的具体用法?PHP Files::concatenatePaths怎么用?PHP Files::concatenatePaths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Utility\Files
的用法示例。
在下文中一共展示了Files::concatenatePaths方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Executes this task
*
* @param \TYPO3\Surf\Domain\Model\Node $node
* @param \TYPO3\Surf\Domain\Model\Application $application
* @param \TYPO3\Surf\Domain\Model\Deployment $deployment
* @param array $options
* @throws \TYPO3\Surf\Exception\TaskExecutionException
* @throws \TYPO3\Surf\Exception\InvalidConfigurationException
*/
public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
{
$configurationFileExtension = isset($options['configurationFileExtension']) ? $options['configurationFileExtension'] : 'yaml';
$targetReleasePath = $deployment->getApplicationReleasePath($application);
$configurationPath = $deployment->getDeploymentConfigurationPath();
if (!is_dir($configurationPath)) {
return;
}
$commands = array();
$configurationFiles = Files::readDirectoryRecursively($configurationPath, $configurationFileExtension);
foreach ($configurationFiles as $configuration) {
$targetConfigurationPath = dirname(str_replace($configurationPath, '', $configuration));
$escapedSourcePath = escapeshellarg($configuration);
$escapedTargetPath = escapeshellarg(Files::concatenatePaths(array($targetReleasePath, 'Configuration', $targetConfigurationPath)) . '/');
if ($node->isLocalhost()) {
$commands[] = 'mkdir -p ' . $escapedTargetPath;
$commands[] = 'cp ' . $escapedSourcePath . ' ' . $escapedTargetPath;
} else {
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$sshPort = isset($options['port']) ? '-p ' . escapeshellarg($options['port']) . ' ' : '';
$scpPort = isset($options['port']) ? '-P ' . escapeshellarg($options['port']) . ' ' : '';
$createDirectoryCommand = '"mkdir -p ' . $escapedTargetPath . '"';
$commands[] = "ssh {$sshPort}{$username}{$hostname} {$createDirectoryCommand}";
$commands[] = "scp {$scpPort}{$escapedSourcePath} {$username}{$hostname}:\"{$escapedTargetPath}\"";
}
}
$localhost = new Node('localhost');
$localhost->setHostname('localhost');
$this->shell->executeOrSimulate($commands, $localhost, $deployment);
}
示例2: getProfile
/**
* Returns a ProfilingRun instance that has been saved as $filename.
*
* @param string $filename
* @return \Sandstorm\PhpProfiler\Domain\Model\ProfilingRun
*/
protected function getProfile($filename)
{
$pathAndFilename = Files::concatenatePaths(array($this->settings['profilePath'], $filename));
$profile = unserialize(file_get_contents($pathAndFilename));
$profile->setPathAndFilename($pathAndFilename);
return $profile;
}
示例3: buildTestResource
/**
* @return \TYPO3\Flow\Resource\Resource
* @throws \TYPO3\Flow\Resource\Exception
*/
protected function buildTestResource()
{
$testImagePath = Files::concatenatePaths([__DIR__, 'Fixtures/Resources/Lighthouse.jpg']);
$resource = $this->resourceManager->importResource($testImagePath);
$asset = new \TYPO3\Media\Domain\Model\Asset($resource);
return $asset;
}
示例4: prepareTemporaryDirectory
/**
* Builds a temporary directory to work on.
* @return void
*/
protected function prepareTemporaryDirectory()
{
$this->temporaryDirectory = \TYPO3\Flow\Utility\Files::concatenatePaths(array(FLOW_PATH_DATA, 'Temporary', 'Testing', str_replace('\\', '_', __CLASS__)));
if (!file_exists($this->temporaryDirectory)) {
\TYPO3\Flow\Utility\Files::createDirectoryRecursively($this->temporaryDirectory);
}
}
示例5: writeComposerManifest
/**
* @return void
*/
protected function writeComposerManifest()
{
$composerJsonFilename = Files::concatenatePaths(array($this->targetPackageData['path'], 'composer.json'));
if (file_exists($composerJsonFilename)) {
return;
}
$manifest = array();
$nameParts = explode('.', $this->targetPackageData['packageKey']);
$vendor = array_shift($nameParts);
$manifest['name'] = strtolower($vendor . '/' . implode('-', $nameParts));
switch ($this->targetPackageData['category']) {
case 'Application':
$manifest['type'] = 'typo3-flow-package';
break;
default:
$manifest['type'] = strtolower('typo3-flow-' . $this->targetPackageData['category']);
}
$manifest['description'] = $this->targetPackageData['meta']['description'];
$manifest['version'] = $this->targetPackageData['meta']['version'];
$manifest['require'] = array('typo3/flow' => '*');
$manifest['autoload'] = array('psr-0' => array(str_replace('.', '\\', $this->targetPackageData['packageKey']) => 'Classes'));
if (defined('JSON_PRETTY_PRINT')) {
file_put_contents($composerJsonFilename, json_encode($manifest, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
} else {
file_put_contents($composerJsonFilename, json_encode($manifest));
}
}
示例6: create
/**
* Factory method which creates an EntityManager.
*
* @return \Doctrine\ORM\EntityManager
*/
public function create()
{
$config = new \Doctrine\ORM\Configuration();
$config->setClassMetadataFactoryName('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\ClassMetadataFactory');
$cache = new \TYPO3\Flow\Persistence\Doctrine\CacheAdapter();
// must use ObjectManager in compile phase...
$cache->setCache($this->objectManager->get('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Persistence_Doctrine'));
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
$resultCache = new \TYPO3\Flow\Persistence\Doctrine\CacheAdapter();
// must use ObjectManager in compile phase...
$resultCache->setCache($this->objectManager->get('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Persistence_Doctrine_Results'));
$config->setResultCacheImpl($resultCache);
if (class_exists($this->settings['doctrine']['sqlLogger'])) {
$config->setSQLLogger(new $this->settings['doctrine']['sqlLogger']());
}
$eventManager = $this->buildEventManager();
$flowAnnotationDriver = $this->objectManager->get('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\Driver\\FlowAnnotationDriver');
$config->setMetadataDriverImpl($flowAnnotationDriver);
$proxyDirectory = \TYPO3\Flow\Utility\Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies'));
\TYPO3\Flow\Utility\Files::createDirectoryRecursively($proxyDirectory);
$config->setProxyDir($proxyDirectory);
$config->setProxyNamespace('TYPO3\\Flow\\Persistence\\Doctrine\\Proxies');
$config->setAutoGenerateProxyClasses(FALSE);
$entityManager = \Doctrine\ORM\EntityManager::create($this->settings['backendOptions'], $config, $eventManager);
$flowAnnotationDriver->setEntityManager($entityManager);
\Doctrine\DBAL\Types\Type::addType('objectarray', 'TYPO3\\Flow\\Persistence\\Doctrine\\DataTypes\\ObjectArray');
if (isset($this->settings['doctrine']['filters']) && is_array($this->settings['doctrine']['filters'])) {
foreach ($this->settings['doctrine']['filters'] as $filterName => $filterClass) {
$config->addFilter($filterName, $filterClass);
$entityManager->getFilters()->enable($filterName);
}
}
return $entityManager;
}
示例7: acquire
/**
* @param string $subject
* @param boolean $exclusiveLock TRUE to, acquire an exclusive (write) lock, FALSE for a shared (read) lock.
* @throws LockNotAcquiredException
* @throws \TYPO3\Flow\Utility\Exception
* @return void
*/
public function acquire($subject, $exclusiveLock)
{
if ($this->isWindowsOS()) {
return;
}
if (self::$temporaryDirectory === null) {
if (Bootstrap::$staticObjectManager === null || !Bootstrap::$staticObjectManager->isRegistered(\TYPO3\Flow\Utility\Environment::class)) {
throw new LockNotAcquiredException('Environment object could not be accessed', 1386680952);
}
$environment = Bootstrap::$staticObjectManager->get(\TYPO3\Flow\Utility\Environment::class);
$temporaryDirectory = Files::concatenatePaths(array($environment->getPathToTemporaryDirectory(), 'Lock'));
Files::createDirectoryRecursively($temporaryDirectory);
self::$temporaryDirectory = $temporaryDirectory;
}
$this->lockFileName = Files::concatenatePaths(array(self::$temporaryDirectory, md5($subject)));
if (($this->filePointer = @fopen($this->lockFileName, 'r')) === false) {
if (($this->filePointer = @fopen($this->lockFileName, 'w')) === false) {
throw new LockNotAcquiredException(sprintf('Lock file "%s" could not be opened', $this->lockFileName), 1386520596);
}
}
if ($exclusiveLock === false && flock($this->filePointer, LOCK_SH) === true) {
// Shared lock acquired
} elseif ($exclusiveLock === true && flock($this->filePointer, LOCK_EX) === true) {
// Exclusive lock acquired
} else {
throw new LockNotAcquiredException(sprintf('Could not lock file "%s"', $this->lockFileName), 1386520597);
}
}
示例8: detectFlowPackageFilePath
/**
* Detects if the package contains a package file and returns the path and classname.
*
* @param string $packageKey The package key
* @param string $absolutePackagePath Absolute path to the package
* @return array The path to the package file and classname for this package or an empty array if none was found.
* @throws Exception\CorruptPackageException
* @throws InvalidPackagePathException
*/
public function detectFlowPackageFilePath($packageKey, $absolutePackagePath)
{
if (!is_dir($absolutePackagePath)) {
throw new InvalidPackagePathException(sprintf('The given package path "%s" is not a readable directory.', $absolutePackagePath), 1445904440);
}
$composerManifest = ComposerUtility::getComposerManifest($absolutePackagePath);
if (!ComposerUtility::isFlowPackageType(isset($composerManifest['type']) ? $composerManifest['type'] : '')) {
return [];
}
$possiblePackageClassPaths = [Files::concatenatePaths(['Classes', 'Package.php']), Files::concatenatePaths(['Classes', str_replace('.', '/', $packageKey), 'Package.php'])];
$foundPackageClassPaths = array_filter($possiblePackageClassPaths, function ($packageClassPathAndFilename) use($absolutePackagePath) {
$absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]);
return is_file($absolutePackageClassPath);
});
if ($foundPackageClassPaths === []) {
return [];
}
if (count($foundPackageClassPaths) > 1) {
throw new Exception\CorruptPackageException(sprintf('The package "%s" contains multiple possible "Package.php" files. Please make sure that only one "Package.php" exists in the autoload root(s) of your Flow package.', $packageKey), 1457454840);
}
$packageClassPathAndFilename = reset($foundPackageClassPaths);
$absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]);
$packageClassContents = file_get_contents($absolutePackageClassPath);
$packageClassName = (new PhpAnalyzer($packageClassContents))->extractFullyQualifiedClassName();
if ($packageClassName === null) {
throw new Exception\CorruptPackageException(sprintf('The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class.', $packageKey, $packageClassPathAndFilename), 1327587091);
}
return ['className' => $packageClassName, 'pathAndFilename' => $packageClassPathAndFilename];
}
示例9: getPathToTemporaryDirectoryReturnsAnExistingPath
/**
* @test
*/
public function getPathToTemporaryDirectoryReturnsAnExistingPath()
{
$environment = new \TYPO3\Flow\Utility\Environment(new ApplicationContext('Testing'));
$environment->setTemporaryDirectoryBase(\TYPO3\Flow\Utility\Files::concatenatePaths(array(sys_get_temp_dir(), 'FlowEnvironmentTest')));
$path = $environment->getPathToTemporaryDirectory();
$this->assertTrue(file_exists($path), 'The temporary path does not exist.');
}
示例10: execute
/**
* Execute this task
*
* @param \TYPO3\Surf\Domain\Model\Node $node
* @param \TYPO3\Surf\Domain\Model\Application $application
* @param \TYPO3\Surf\Domain\Model\Deployment $deployment
* @param array $options Supported options: "scriptBasePath" and "scriptIdentifier"
* @return void
* @throws \TYPO3\Surf\Exception\InvalidConfigurationException
* @throws \TYPO3\Surf\Exception\TaskExecutionException
*/
public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
{
$workspacePath = $deployment->getWorkspacePath($application);
$scriptBasePath = isset($options['scriptBasePath']) ? $options['scriptBasePath'] : Files::concatenatePaths(array($workspacePath, 'Web'));
if (!isset($options['scriptIdentifier'])) {
// Generate random identifier
$factory = new \RandomLib\Factory();
$generator = $factory->getMediumStrengthGenerator();
$scriptIdentifier = $generator->generateString(32, \RandomLib\Generator::CHAR_ALNUM);
// Store the script identifier as an application option
$application->setOption('TYPO3\\Surf\\Task\\Php\\WebOpcacheResetExecuteTask[scriptIdentifier]', $scriptIdentifier);
} else {
$scriptIdentifier = $options['scriptIdentifier'];
}
$localhost = new Node('localhost');
$localhost->setHostname('localhost');
$commands = array('cd ' . escapeshellarg($scriptBasePath), 'rm -f surf-opcache-reset-*');
$this->shell->executeOrSimulate($commands, $localhost, $deployment);
if (!$deployment->isDryRun()) {
$scriptFilename = $scriptBasePath . '/surf-opcache-reset-' . $scriptIdentifier . '.php';
$result = file_put_contents($scriptFilename, '<?php
if (function_exists("opcache_reset")) {
opcache_reset();
}
@unlink(__FILE__);
echo "success";
');
if ($result === false) {
throw new \TYPO3\Surf\Exception\TaskExecutionException('Could not write file "' . $scriptFilename . '"', 1421932414);
}
}
}
示例11: create
/**
* Returns a package instance.
*
* @param string $packagesBasePath the base install path of packages,
* @param string $packagePath path to package, relative to base path
* @param string $packageKey key / name of the package
* @param string $classesPath path to the classes directory, relative to the package path
* @param string $manifestPath path to the package's Composer manifest, relative to package path, defaults to same path
* @return \TYPO3\Flow\Package\PackageInterface
* @throws Exception\CorruptPackageException
*/
public function create($packagesBasePath, $packagePath, $packageKey, $classesPath = null, $manifestPath = null)
{
$absolutePackagePath = Files::concatenatePaths(array($packagesBasePath, $packagePath)) . '/';
$absoluteManifestPath = $manifestPath === null ? $absolutePackagePath : Files::concatenatePaths(array($absolutePackagePath, $manifestPath)) . '/';
$autoLoadDirectives = array();
try {
$autoLoadDirectives = (array) PackageManager::getComposerManifest($absoluteManifestPath, 'autoload');
} catch (MissingPackageManifestException $exception) {
}
if (isset($autoLoadDirectives[Package::AUTOLOADER_TYPE_PSR4])) {
$packageClassPathAndFilename = Files::concatenatePaths(array($absolutePackagePath, 'Classes', 'Package.php'));
} else {
$packageClassPathAndFilename = Files::concatenatePaths(array($absolutePackagePath, 'Classes', str_replace('.', '/', $packageKey), 'Package.php'));
}
$package = null;
if (file_exists($packageClassPathAndFilename)) {
require_once $packageClassPathAndFilename;
$packageClassContents = file_get_contents($packageClassPathAndFilename);
$packageClassName = (new PhpAnalyzer($packageClassContents))->extractFullyQualifiedClassName();
if ($packageClassName === null) {
throw new Exception\CorruptPackageException(sprintf('The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class.', $packageKey, $packageClassPathAndFilename), 1327587091);
}
$package = new $packageClassName($this->packageManager, $packageKey, $absolutePackagePath, $classesPath, $manifestPath);
if (!$package instanceof PackageInterface) {
throw new Exception\CorruptPackageException(sprintf('The package class of package "%s" does not implement \\TYPO3\\Flow\\Package\\PackageInterface. Check the file "%s".', $packageKey, $packageClassPathAndFilename), 1427193370);
}
return $package;
}
return new Package($this->packageManager, $packageKey, $absolutePackagePath, $classesPath, $manifestPath);
}
示例12: create
/**
* Returns a package instance.
*
* @param string $packagesBasePath the base install path of packages,
* @param string $packagePath path to package, relative to base path
* @param string $packageKey key / name of the package
* @param string $classesPath path to the classes directory, relative to the package path
* @param string $manifestPath path to the package's Composer manifest, relative to package path, defaults to same path
* @return \TYPO3\Flow\Package\PackageInterface
* @throws \TYPO3\Flow\Package\Exception\CorruptPackageException
*/
public function create($packagesBasePath, $packagePath, $packageKey, $classesPath, $manifestPath = '')
{
$packagePath = Files::getNormalizedPath(Files::concatenatePaths(array($packagesBasePath, $packagePath)));
$packageClassPathAndFilename = Files::concatenatePaths(array($packagePath, 'Classes/' . str_replace('.', '/', $packageKey) . '/Package.php'));
$alternativeClassPathAndFilename = Files::concatenatePaths(array($packagePath, 'Classes/Package.php'));
$packageClassPathAndFilename = @file_exists($alternativeClassPathAndFilename) ? $alternativeClassPathAndFilename : $packageClassPathAndFilename;
if (@file_exists($packageClassPathAndFilename)) {
require_once $packageClassPathAndFilename;
if (substr($packagePath, 0, strlen(PATH_typo3)) === PATH_typo3 && strpos($packageKey, '.') === FALSE) {
//TODO Remove this exception once the systextension are renamed to proper Flow naming scheme packages
$packageClassName = 'TYPO3\\CMS\\' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($packageKey) . '\\Package';
} else {
$packageClassName = str_replace('.', '\\', $packageKey) . '\\Package';
}
if (!class_exists($packageClassName, FALSE)) {
throw new \TYPO3\Flow\Package\Exception\CorruptPackageException(sprintf('The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class called "%s".', $packageKey, $packageClassPathAndFilename, $packageClassName), 1327587092);
}
} else {
$emConfPath = Files::concatenatePaths(array($packagePath, 'ext_emconf.php'));
$packageClassName = @file_exists($emConfPath) ? 'TYPO3\\CMS\\Core\\Package\\Package' : 'TYPO3\\Flow\\Package\\Package';
}
/** @var $package \TYPO3\Flow\Package\PackageInterface */
$package = new $packageClassName($this->packageManager, $packageKey, $packagePath, $classesPath, $manifestPath);
return $package;
}
示例13: modelIsReturnedCorrectlyForLocaleImplicatingChaining
/**
* @test
*/
public function modelIsReturnedCorrectlyForLocaleImplicatingChaining()
{
$localeImplementingChaining = new \TYPO3\Flow\I18n\Locale('de_DE');
$cldrModel = $this->cldrRepository->getModelForLocale($localeImplementingChaining);
$this->assertAttributeContains(\TYPO3\Flow\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/root.xml')), 'sourcePaths', $cldrModel);
$this->assertAttributeContains(\TYPO3\Flow\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/de_DE.xml')), 'sourcePaths', $cldrModel);
$this->assertAttributeContains(\TYPO3\Flow\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/de.xml')), 'sourcePaths', $cldrModel);
}
示例14: configureTemporaryDirectory
/**
* Sets the temporaryDirectory as static variable for the lock class.
*
* @throws LockNotAcquiredException
* @throws \TYPO3\Flow\Utility\Exception
* return void;
*/
protected function configureTemporaryDirectory()
{
if (Bootstrap::$staticObjectManager === null || !Bootstrap::$staticObjectManager->isRegistered(\TYPO3\Flow\Utility\Environment::class)) {
throw new LockNotAcquiredException('Environment object could not be accessed', 1386680952);
}
$environment = Bootstrap::$staticObjectManager->get('TYPO3\\Flow\\Utility\\Environment');
$temporaryDirectory = Files::concatenatePaths([$environment->getPathToTemporaryDirectory(), 'Lock']);
Files::createDirectoryRecursively($temporaryDirectory);
self::$temporaryDirectory = $temporaryDirectory;
}
示例15: resolveView
/**
* Resolve view object. Falls back to TYPO3.Ice package templates
* if current package does not contain a template for current request.
*
* @return \TYPO3\Flow\Mvc\View\ViewInterface the resolved view
*/
public function resolveView()
{
$view = parent::resolveView();
if (!$view->canRender($this->controllerContext) && $this->request->getFormat() === 'html') {
$templateFileName = \TYPO3\Flow\Utility\Files::concatenatePaths(array($this->packageManager->getPackage('TYPO3.Ice')->getPackagePath(), 'Resources', 'Private', 'Templates', 'Standard', 'Index.html'));
// Fallback to TYPO3.Ice template if file exists
if (file_exists($templateFileName)) {
$view->setTemplatePathAndFilename($templateFileName);
}
}
return $view;
}