本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::mkdir方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::mkdir方法的具体用法?PHP GeneralUtility::mkdir怎么用?PHP GeneralUtility::mkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*/
public function __construct()
{
// we check for existence of our targetDirectory
if (!is_dir(PATH_site . $this->targetDirectory)) {
GeneralUtility::mkdir(PATH_site . $this->targetDirectory);
}
// if enabled, we check whether we should auto-create the .htaccess file
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['generateApacheHtaccess']) {
// check whether .htaccess exists
$htaccessPath = PATH_site . $this->targetDirectory . '.htaccess';
if (!file_exists($htaccessPath)) {
GeneralUtility::writeFile($htaccessPath, $this->htaccessTemplate);
}
}
// decide whether we should create gzipped versions or not
$compressionLevel = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['compressionLevel'];
// we need zlib for gzencode()
if (extension_loaded('zlib') && $compressionLevel) {
$this->createGzipped = TRUE;
// $compressionLevel can also be TRUE
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($compressionLevel)) {
$this->gzipCompressionLevel = (int) $compressionLevel;
}
}
$this->setInitialPaths();
}
示例2: __construct
/**
* Constructor:
* initializes locking, check input parameters and set variables accordingly.
*
* @param string $id ID to identify this lock in the system
* @param string $method Define which locking method to use. Defaults to "flock".
* @throws \InvalidArgumentException
* @throws \Exception
*/
public function __construct($id, $method = null)
{
// Force ID to be string
$id = (string) $id;
if (!$method) {
$method = $GLOBALS['TYPO3_CONF_VARS']['SYS']['extbase_hijax']['lockingMode'];
}
$this->method = $method;
switch ($this->method) {
case 'flock':
$genTempPath = PATH_site . 'typo3temp' . DIRECTORY_SEPARATOR . 'extbase_hijax' . DIRECTORY_SEPARATOR;
if (!is_dir($genTempPath)) {
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($genTempPath);
}
$path = PATH_site . 'typo3temp' . DIRECTORY_SEPARATOR . 'extbase_hijax' . DIRECTORY_SEPARATOR . 'locks' . DIRECTORY_SEPARATOR;
if (!is_dir($path)) {
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($path);
}
$this->id = md5($id);
$this->resource = $path . $this->id;
break;
case 'semaphore':
$this->id = abs(crc32($id));
if (($this->resource = sem_get($this->id, 1)) === FALSE) {
throw new \Exception('Unable to get semaphore', 1313828196);
}
break;
case 'disable':
break;
default:
throw new \InvalidArgumentException('No such method "' . $method . '"', 1294586097);
}
}
示例3: flushProcessedFilesCommand
/**
* Flush all processed files to be used for debugging mainly.
*
* @return void
*/
public function flushProcessedFilesCommand()
{
foreach ($this->getStorageRepository()->findAll() as $storage) {
// This only works for local driver
if ($storage->getDriverType() === 'Local') {
$this->outputLine();
$this->outputLine(sprintf('%s (%s)', $storage->getName(), $storage->getUid()));
$this->outputLine('--------------------------------------------');
$this->outputLine();
#$storage->getProcessingFolder()->delete(TRUE); // will not work
// Well... not really FAL friendly but straightforward for Local drivers.
$processedDirectoryPath = PATH_site . $storage->getProcessingFolder()->getPublicUrl();
$fileIterator = new FilesystemIterator($processedDirectoryPath, FilesystemIterator::SKIP_DOTS);
$numberOfProcessedFiles = iterator_count($fileIterator);
GeneralUtility::rmdir($processedDirectoryPath, TRUE);
GeneralUtility::mkdir($processedDirectoryPath);
// recreate the directory.
$message = sprintf('Done! Removed %s processed file(s).', $numberOfProcessedFiles);
$this->outputLine($message);
// Remove the record as well.
$record = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('count(*) AS numberOfProcessedFiles', 'sys_file_processedfile', 'storage = ' . $storage->getUid());
$this->getDatabaseConnection()->exec_DELETEquery('sys_file_processedfile', 'storage = ' . $storage->getUid());
$message = sprintf('Done! Removed %s records from "sys_file_processedfile".', $record['numberOfProcessedFiles']);
$this->outputLine($message);
}
}
// Remove possible remaining "sys_file_processedfile"
$query = 'TRUNCATE sys_file_processedfile';
$this->getDatabaseConnection()->sql_query($query);
}
示例4: getFileSystemStatus
/**
* Checks for several directories being writable.
*
* @return Status Indicates status of the file system
*/
protected function getFileSystemStatus()
{
$languageService = $this->getLanguageService();
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_writable');
$message = '';
$severity = Status::OK;
// Requirement level
// -1 = not required, but if it exists may be writable or not
// 0 = not required, if it exists the dir should be writable
// 1 = required, don't has to be writable
// 2 = required, has to be writable
$checkWritable = array('typo3temp/' => 2, 'typo3temp/assets/' => 2, 'typo3temp/assets/compressed/' => 2, 'typo3temp/assets/images/' => 0, 'typo3temp/assets/css/' => 2, 'typo3temp/assets/js/' => 2, 'typo3temp/assets/_processed_/' => 0, 'typo3temp/var/' => 2, 'typo3temp/var/transient/' => 2, 'typo3temp/var/charset/' => 2, 'typo3temp/var/locks/' => 2, 'typo3conf/' => 2, 'typo3conf/ext/' => 0, 'typo3conf/l10n/' => 0, 'uploads/' => 2, 'uploads/pics/' => 0, 'uploads/media/' => 0, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0);
if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall']) {
$checkWritable[TYPO3_mainDir . 'ext/'] = -1;
}
foreach ($checkWritable as $relPath => $requirementLevel) {
if (!@is_dir(PATH_site . $relPath)) {
// If the directory is missing, try to create it
GeneralUtility::mkdir(PATH_site . $relPath);
}
if (!@is_dir(PATH_site . $relPath)) {
if ($requirementLevel > 0) {
// directory is required
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_missingDirectory');
$message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
$severity = Status::ERROR;
} else {
$message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExist'), $relPath);
if ($requirementLevel == 0) {
$message .= ' ' . $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldAlsoBeWritable');
}
$message .= '<br />';
if ($severity < Status::WARNING) {
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_nonExistingDirectory');
$severity = Status::WARNING;
}
}
} else {
if (!is_writable(PATH_site . $relPath)) {
switch ($requirementLevel) {
case 0:
$message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldBeWritable'), PATH_site . $relPath) . '<br />';
if ($severity < Status::WARNING) {
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_recommendedWritableDirectory');
$severity = Status::WARNING;
}
break;
case 2:
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_requiredWritableDirectory');
$message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryMustBeWritable'), PATH_site . $relPath) . '<br />';
$severity = Status::ERROR;
break;
default:
}
}
}
}
return GeneralUtility::makeInstance(Status::class, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_fileSystem'), $value, $message, $severity);
}
示例5: render
/**
* Render Link to Captcha Image
*
* @return string
*/
public function render()
{
$string = $this->getStringForCaptcha();
if (!is_dir(dirname($this->getCaptchaImage())) && !GeneralUtility::mkdir(GeneralUtility::getFileAbsFileName(dirname($this->getCaptchaImage())))) {
return 'Error: Folder ' . dirname($this->getCaptchaImage()) . '/ don\'t exists';
}
return $this->createImage($string);
}
示例6: createFakeExtension
/**
* Creates a fake extension inside typo3temp/. No configuration is created,
* just the folder
*
* @return string The extension key
*/
protected function createFakeExtension()
{
$extKey = strtolower(uniqid('testing'));
$absExtPath = PATH_site . 'typo3temp/' . $extKey . '/';
$relPath = 'typo3temp/' . $extKey . '/';
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($absExtPath);
$this->fakedExtensions[$extKey] = array('siteRelPath' => $relPath);
return $extKey;
}
示例7: getLanguageDirectory
/**
* @return string
*/
protected function getLanguageDirectory()
{
// Create language file dynamically
$languageDirectory = PATH_site . 'typo3temp/vidi';
if (!is_dir($languageDirectory)) {
GeneralUtility::mkdir($languageDirectory);
}
return $languageDirectory;
}
示例8: getFileSystemStatus
/**
* Checks for several directories being writable.
*
* @return tx_reports_reports_status_Status An tx_reports_reports_status_Status object indicating the status of the file system
*/
protected function getFileSystemStatus()
{
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_writable');
$message = '';
$severity = \TYPO3\CMS\Reports\Status::OK;
// Requirement level
// -1 = not required, but if it exists may be writable or not
// 0 = not required, if it exists the dir should be writable
// 1 = required, don't has to be writable
// 2 = required, has to be writable
$checkWritable = array('typo3temp/' => 2, 'typo3temp/pics/' => 2, 'typo3temp/temp/' => 2, 'typo3temp/llxml/' => 2, 'typo3temp/cs/' => 2, 'typo3temp/GB/' => 2, 'typo3temp/locks/' => 2, 'typo3conf/' => 2, 'typo3conf/ext/' => 0, 'typo3conf/l10n/' => 0, TYPO3_mainDir . 'ext/' => -1, 'uploads/' => 2, 'uploads/pics/' => 0, 'uploads/media/' => 0, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0);
foreach ($checkWritable as $relPath => $requirementLevel) {
if (!@is_dir(PATH_site . $relPath)) {
// If the directory is missing, try to create it
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir(PATH_site . $relPath);
}
if (!@is_dir(PATH_site . $relPath)) {
if ($requirementLevel > 0) {
// directory is required
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_missingDirectory');
$message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
$severity = \TYPO3\CMS\Reports\Status::ERROR;
} else {
$message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryDoesNotExist'), $relPath);
if ($requirementLevel == 0) {
$message .= ' ' . $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryShouldAlsoBeWritable');
}
$message .= '<br />';
if ($severity < \TYPO3\CMS\Reports\Status::WARNING) {
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_nonExistingDirectory');
$severity = \TYPO3\CMS\Reports\Status::WARNING;
}
}
} else {
if (!is_writable(PATH_site . $relPath)) {
switch ($requirementLevel) {
case 0:
$message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryShouldBeWritable'), PATH_site . $relPath) . '<br />';
if ($severity < \TYPO3\CMS\Reports\Status::WARNING) {
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_recommendedWritableDirectory');
$severity = \TYPO3\CMS\Reports\Status::WARNING;
}
break;
case 2:
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_requiredWritableDirectory');
$message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryMustBeWritable'), PATH_site . $relPath) . '<br />';
$severity = \TYPO3\CMS\Reports\Status::ERROR;
break;
}
}
}
}
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_fileSystem'), $value, $message, $severity);
}
示例9: createFakeExtension
/**
* Creates a fake extension inside typo3temp/. No configuration is created,
* just the folder
*
* @param bool $extkeyOnly
* @return string The extension key
*/
protected function createFakeExtension($extkeyOnly = FALSE)
{
$extKey = strtolower(uniqid('testing'));
$absExtPath = PATH_site . 'typo3conf/ext/' . $extKey . '/';
$relPath = 'typo3conf/ext/' . $extKey . '/';
$this->fakedExtensions[$extKey] = array('siteRelPath' => $relPath, 'siteAbsPath' => $absExtPath);
if ($extkeyOnly === TRUE) {
return $extKey;
}
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($absExtPath);
return $extKey;
}
示例10: initializeEnvironment
/**
* Initialize some properties
*
* @param array $objects
* @return void
*/
protected function initializeEnvironment(array $objects)
{
/** @var \Fab\Vidi\Domain\Model\Content $object */
$object = reset($objects);
$this->temporaryDirectory = PATH_site . 'typo3temp/' . uniqid() . '/';
GeneralUtility::mkdir($this->temporaryDirectory);
// Compute file name and path variable
$this->exportFileNameAndPath = $this->temporaryDirectory . $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']);
// Compute file name and path variable for zip
$zipFileName = $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']) . '.zip';
$this->zipFileNameAndPath = $this->temporaryDirectory . $zipFileName;
}
示例11: createFakeExtension
/**
* Creates a fake extension inside typo3temp/. No configuration is created,
* just the folder
*
* @param bool $extkeyOnly
* @return string The extension key
*/
protected function createFakeExtension($extkeyOnly = false)
{
$extKey = strtolower($this->getUniqueId('testing'));
$absExtPath = PATH_site . 'typo3temp/ext-' . $extKey . '/';
$relPath = 'typo3temp/ext-' . $extKey . '/';
$this->fakedExtensions[$extKey] = array('siteRelPath' => $relPath, 'siteAbsPath' => $absExtPath);
if ($extkeyOnly === true) {
return $extKey;
}
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($absExtPath);
$this->testFilesToDelete[] = PATH_site . 'typo3temp/ext-' . $extKey;
return $extKey;
}
示例12: _cleanupDirectory
/**
* Cleanup sitemap directory
*/
protected function _cleanupDirectory()
{
if (empty($this->_sitemapDir)) {
throw new \Exception('Basedir not set');
}
$fullPath = PATH_site . '/' . $this->_sitemapDir;
if (!is_dir($fullPath)) {
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($fullPath);
}
foreach (new \DirectoryIterator($fullPath) as $file) {
if ($file->isFile() && !$file->isDot()) {
$fileName = $file->getFilename();
unlink($fullPath . '/' . $fileName);
}
}
}
示例13: setUp
public function setUp()
{
parent::setUp();
$this->objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
if (!class_exists('PhpParser\\Parser')) {
throw new UnknownClassException('PhpParser not found!!');
}
$this->fixturesPath = __DIR__ . '/Fixtures/';
$testTargetDir = 'testDir';
vfsStream::setup($testTargetDir);
$dummyExtensionDir = vfsStream::url($testTargetDir) . '/';
$yamlParser = new \EBT\ExtensionBuilder\Utility\SpycYAMLParser();
$settings = $yamlParser->YAMLLoadString(file_get_contents($this->fixturesPath . 'Settings/settings1.yaml'));
$this->extension = $this->getMock(\EBT\ExtensionBuilder\Domain\Model\Extension::class, array('getExtensionDir'));
$this->extension->setVendorName('EBT');
$this->extension->setExtensionKey('dummy');
$this->extension->expects($this->any())->method('getExtensionDir')->will($this->returnValue($dummyExtensionDir));
if (is_dir($dummyExtensionDir)) {
GeneralUtility::mkdir($dummyExtensionDir, TRUE);
}
$this->extension->setSettings($settings);
// get instances to inject in Mocks
$configurationManager = $this->objectManager->get(\EBT\ExtensionBuilder\Configuration\ConfigurationManager::class);
$this->parserService = new \EBT\ExtensionBuilder\Service\Parser(new \PhpParser\Lexer());
$this->printerService = $this->objectManager->get(\EBT\ExtensionBuilder\Service\Printer::class);
$localizationService = $this->objectManager->get(\EBT\ExtensionBuilder\Service\LocalizationService::class);
$this->classBuilder = $this->objectManager->get(\EBT\ExtensionBuilder\Service\ClassBuilder::class);
$this->classBuilder->initialize($this->extension);
$this->roundTripService = $this->getAccessibleMock(\EBT\ExtensionBuilder\Service\RoundTrip::class, array('dummy'));
$this->inject($this->roundTripService, 'configurationManager', $configurationManager);
$this->inject($this->roundTripService, 'parserService', $this->parserService);
$this->roundTripService->initialize($this->extension);
$this->fileGenerator = $this->getAccessibleMock(\EBT\ExtensionBuilder\Service\FileGenerator::class, array('dummy'));
$this->inject($this->fileGenerator, 'objectManager', $this->objectManager);
$this->inject($this->fileGenerator, 'printerService', $this->printerService);
$this->inject($this->fileGenerator, 'localizationService', $localizationService);
$this->inject($this->fileGenerator, 'classBuilder', $this->classBuilder);
$this->inject($this->fileGenerator, 'roundTripService', $this->roundTripService);
$this->codeTemplateRootPath = PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/';
$this->modelClassTemplatePath = $this->codeTemplateRootPath . 'Classes/Domain/Model/Model.phpt';
$this->fileGenerator->setSettings(array('codeTemplateRootPath' => $this->codeTemplateRootPath, 'extConf' => array('enableRoundtrip' => '1')));
$this->fileGenerator->_set('codeTemplateRootPath', __DIR__ . '/../Resources/Private/CodeTemplates/Extbase/');
$this->fileGenerator->_set('enableRoundtrip', true);
$this->fileGenerator->_set('extension', $this->extension);
}
示例14: initializePollRepository
/**
* Initializes a poll repository.
*
* @return PollRepository
*/
public static function initializePollRepository()
{
$settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['doodle']);
/** @var \Causal\DoodleClient\Client $doodleClient */
$doodleClient = GeneralUtility::makeInstance('Causal\\DoodleClient\\Client', $settings['username'], $settings['password']);
$cookiePath = PATH_site . 'typo3temp/tx_doodle/';
if (!is_dir($cookiePath)) {
GeneralUtility::mkdir($cookiePath);
}
if (!is_file($cookiePath . '/.htaccess')) {
GeneralUtility::writeFile($cookiePath . '/.htaccess', 'Deny from all');
}
$doodleClient->setCookiePath($cookiePath)->connect();
/** @var \Causal\Doodle\Domain\Repository\PollRepository $pollRepository */
$pollRepository = GeneralUtility::makeInstance('Causal\\Doodle\\Domain\\Repository\\PollRepository');
$pollRepository->setDoodleClient($doodleClient);
return $pollRepository;
}
示例15: __construct
/**
* @param string $subject ID to identify this lock in the system
* @throws LockCreateException if the lock could not be created
*/
public function __construct($subject)
{
// Tests if the directory for simple locks is available.
// If not, the directory will be created. The lock path is usually
// below typo3temp, typo3temp itself should exist already
$path = PATH_site . self::FILE_LOCK_FOLDER;
if (!is_dir($path)) {
// Not using mkdir_deep on purpose here, if typo3temp itself
// does not exist, this issue should be solved on a different
// level of the application.
if (!GeneralUtility::mkdir($path)) {
throw new LockCreateException('Cannot create directory ' . $path, 1395140007);
}
}
if (!is_writable($path)) {
throw new LockCreateException('Cannot write to directory ' . $path, 1396278700);
}
$this->filePath = $path . 'simple_' . md5((string) $subject);
}