/** * Sets the path to the log file. * * @param string $relativeLogFile path to the log file, relative to PATH_site * @return WriterInterface * @throws InvalidLogWriterConfigurationException */ 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 InvalidLogWriterConfigurationException('Log file path "' . $relativeLogFile . '" is not valid!', 1444374805); } } $this->logFile = $logFile; $this->openLogFile(); return $this; }
/** * 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; }
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); }
/** * 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)); }
/** * 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; }
/** * 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; }
/** * 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; }