本文整理汇总了PHP中TYPO3\CMS\Core\Utility\PathUtility::isAbsolutePath方法的典型用法代码示例。如果您正苦于以下问题:PHP PathUtility::isAbsolutePath方法的具体用法?PHP PathUtility::isAbsolutePath怎么用?PHP PathUtility::isAbsolutePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\PathUtility
的用法示例。
在下文中一共展示了PathUtility::isAbsolutePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLogFile
/**
* Sets the path to the log file.
*
* @param string $relativeLogFile path to the log file, relative to PATH_site
* @return WriterInterface
* @throws \InvalidArgumentException
*/
public function setLogFile($relativeLogFile)
{
$logFile = $relativeLogFile;
// Skip handling if logFile is a stream resource. This is used by unit tests with vfs:// directories
if (FALSE === strpos($logFile, '://') && !PathUtility::isAbsolutePath($logFile)) {
$logFile = GeneralUtility::getFileAbsFileName($logFile);
if ($logFile === NULL) {
throw new \InvalidArgumentException('Log file path "' . $relativeLogFile . '" is not valid!', 1326411176);
}
}
$this->logFile = $logFile;
$this->openLogFile();
return $this;
}
示例2: getAbsolutePath
public static function getAbsolutePath($path)
{
if (\TYPO3\CMS\Core\Utility\PathUtility::isAbsolutePath($path)) {
return $path;
}
if (strpos($path, self::EXT_PREFIX) === 0) {
$relativePath = substr($path, strlen(self::EXT_PREFIX));
if (file_exists(PATH_site . self::RELATIVE_EXT_PATH . $relativePath)) {
return PATH_site . self::RELATIVE_EXT_PATH . $relativePath;
} elseif (file_exists(PATH_site . self::RELATIVE_SYSEXT_PATH . $relativePath)) {
return PATH_site . self::RELATIVE_SYSEXT_PATH . $relativePath;
}
}
if (file_exists(PATH_site . $path)) {
return PATH_site . $path;
}
throw new \InvalidArgumentException("Path '{$path}' can not be converted to an absolute path!", 1456179408);
}
示例3: setLinkToPhpFile
/**
* Set a class loader cache content
*
* @TODO: Rename method
* @param string $entryIdentifier
* @param string $filePath
* @throws \InvalidArgumentException
* @internal This is not an API method
*/
public function setLinkToPhpFile($entryIdentifier, $filePath)
{
if ($entryIdentifier === '') {
throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1364205170);
}
if (!PathUtility::isAbsolutePath($filePath)) {
throw new \InvalidArgumentException('Only absolute paths are allowed for the class loader, given path was: ' . $filePath, 1381923089);
}
if (!@file_exists($filePath)) {
throw new \InvalidArgumentException('The specified file path (' . $filePath . ') must exist.', 1364205235);
}
if (strtolower(substr($filePath, -4)) !== '.php') {
throw new \InvalidArgumentException('The specified file (' . $filePath . ') must be a php file.', 1364205377);
}
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier (' . $entryIdentifier . ') must not contain a path segment.', 1364205166);
}
$this->set($entryIdentifier, sprintf($this->requireFileTemplate, $filePath));
}
示例4: activateVersion
/**
* Activate a core version
*
* @param string $version A version to activate
* @return bool TRUE on success
*/
public function activateVersion($version)
{
$newCoreLocation = @realPath($this->symlinkToCoreFiles . '/../') . '/typo3_src-' . $version;
$messages = array();
$success = true;
if (!is_dir($newCoreLocation)) {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('New TYPO3 CMS core not found');
$messages[] = $message;
} elseif (!is_link($this->symlinkToCoreFiles)) {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('TYPO3 CMS core source directory (typo3_src) is not a link');
$messages[] = $message;
} else {
$isCurrentCoreSymlinkAbsolute = PathUtility::isAbsolutePath(readlink($this->symlinkToCoreFiles));
$unlinkResult = unlink($this->symlinkToCoreFiles);
if (!$unlinkResult) {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('Removing old symlink failed');
$messages[] = $message;
} else {
if (!$isCurrentCoreSymlinkAbsolute) {
$newCoreLocation = $this->getRelativePath($newCoreLocation);
}
$symlinkResult = symlink($newCoreLocation, $this->symlinkToCoreFiles);
if ($symlinkResult) {
GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive();
} else {
$success = false;
/** @var $message StatusInterface */
$message = $this->objectManager->get(ErrorStatus::class);
$message->setTitle('Linking new TYPO3 CMS core failed');
$messages[] = $message;
}
}
}
$this->messages = $messages;
return $success;
}
示例5: getRelativeFolder
/**
* Get relative path from absolute path, but don't touch if it's already a relative path
*
* @param string $path
* @return string
*/
public static function getRelativeFolder($path)
{
if (PathUtility::isAbsolutePath($path)) {
$path = PathUtility::getRelativePathTo($path);
}
return $path;
}
示例6: ensureAbsolutePath
/**
* Guarantees that $reference is turned into a
* correct, absolute path. The input can be a
* relative path or a FILE: or EXT: reference
* but cannot be a FAL resource identifier.
*
* @param mixed $reference
* @return string
*/
protected function ensureAbsolutePath($reference)
{
if (false === is_array($reference)) {
$filename = PathUtility::isAbsolutePath($reference) ? $reference : GeneralUtility::getFileAbsFileName($reference);
} else {
foreach ($reference as &$subValue) {
$subValue = $this->ensureAbsolutePath($subValue);
}
return $reference;
}
return $filename;
}