当前位置: 首页>>代码示例>>PHP>>正文


PHP GeneralUtility::writeFile方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::writeFile方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::writeFile方法的具体用法?PHP GeneralUtility::writeFile怎么用?PHP GeneralUtility::writeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Utility\GeneralUtility的用法示例。


在下文中一共展示了GeneralUtility::writeFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: importCommand

 /**
  * Import command
  *
  * @param string $icsCalendarUri
  * @param int    $pid
  */
 public function importCommand($icsCalendarUri = null, $pid = null)
 {
     if ($icsCalendarUri === null || !filter_var($icsCalendarUri, FILTER_VALIDATE_URL)) {
         $this->enqueueMessage('You have to enter a valid URL to the iCalendar ICS', 'Error', FlashMessage::ERROR);
         return;
     }
     if (!MathUtility::canBeInterpretedAsInteger($pid)) {
         $this->enqueueMessage('You have to enter a valid PID for the new created elements', 'Error', FlashMessage::ERROR);
         return;
     }
     // fetch external URI and write to file
     $this->enqueueMessage('Start to checkout the calendar: ' . $icsCalendarUri, 'Calendar', FlashMessage::INFO);
     $relativeIcalFile = 'typo3temp/ical.' . GeneralUtility::shortMD5($icsCalendarUri) . '.ical';
     $absoluteIcalFile = GeneralUtility::getFileAbsFileName($relativeIcalFile);
     $content = GeneralUtility::getUrl($icsCalendarUri);
     GeneralUtility::writeFile($absoluteIcalFile, $content);
     // get Events from file
     $icalEvents = $this->getIcalEvents($absoluteIcalFile);
     $this->enqueueMessage('Found ' . sizeof($icalEvents) . ' events in the given calendar', 'Items', FlashMessage::INFO);
     $events = $this->prepareEvents($icalEvents);
     $this->enqueueMessage('Found ' . sizeof($events) . ' events in ' . $icsCalendarUri, 'Items', FlashMessage::INFO);
     /** @var Dispatcher $signalSlotDispatcher */
     $signalSlotDispatcher = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
     $this->enqueueMessage('Send the ' . __CLASS__ . '::importCommand signal for each event.', 'Signal', FlashMessage::INFO);
     foreach ($events as $event) {
         $arguments = ['event' => $event, 'commandController' => $this, 'pid' => $pid, 'handled' => false];
         $signalSlotDispatcher->dispatch(__CLASS__, 'importCommand', $arguments);
     }
 }
开发者ID:kaptankorkut,项目名称:calendarize,代码行数:35,代码来源:ImportCommandController.php

示例2: importCommand

 /**
  * Import command
  *
  * @param string $icsCalendarUri
  * @param int    $pid
  */
 public function importCommand($icsCalendarUri = NULL, $pid = NULL)
 {
     if ($icsCalendarUri === NULL || !filter_var($icsCalendarUri, FILTER_VALIDATE_URL)) {
         $this->enqueueMessage('You have to enter a valid URL to the iCalendar ICS', 'Error', FlashMessage::ERROR);
     }
     if (!MathUtility::canBeInterpretedAsInteger($pid)) {
         $this->enqueueMessage('You have to enter a valid PID for the new created elements', 'Error', FlashMessage::ERROR);
     }
     // fetch external URI and write to file
     $this->enqueueMessage('Start to checkout the calendar: ' . $icsCalendarUri, 'Calendar', FlashMessage::INFO);
     $relativeIcalFile = 'typo3temp/ical.' . GeneralUtility::shortMD5($icsCalendarUri) . '.ical';
     $absoluteIcalFile = GeneralUtility::getFileAbsFileName($relativeIcalFile);
     $content = GeneralUtility::getUrl($icsCalendarUri);
     GeneralUtility::writeFile($absoluteIcalFile, $content);
     // get Events from file
     $icalEvents = $this->getIcalEvents($absoluteIcalFile);
     $this->enqueueMessage('Found ' . sizeof($icalEvents) . ' events in the given calendar', 'Items', FlashMessage::INFO);
     $events = $this->prepareEvents($icalEvents);
     $this->enqueueMessage('This is just a first draft. There are same missing fields. Will be part of the next release', 'Items', FlashMessage::ERROR);
     return;
     foreach ($events as $event) {
         $eventObject = $this->eventRepository->findOneByImportId($event['uid']);
         if ($eventObject instanceof Event) {
             // update
             $eventObject->setTitle($event['title']);
             $eventObject->setDescription($this->nl2br($event['description']));
             $this->eventRepository->update($eventObject);
             $this->enqueueMessage('Update Event Meta data: ' . $eventObject->getTitle(), 'Update');
         } else {
             // create
             $eventObject = new Event();
             $eventObject->setPid($pid);
             $eventObject->setImportId($event['uid']);
             $eventObject->setTitle($event['title']);
             $eventObject->setDescription($this->nl2br($event['description']));
             $configuration = new Configuration();
             $configuration->setType(Configuration::TYPE_TIME);
             $configuration->setFrequency(Configuration::FREQUENCY_NONE);
             /** @var \DateTime $startDate */
             $startDate = clone $event['start'];
             $startDate->setTime(0, 0, 0);
             $configuration->setStartDate($startDate);
             /** @var \DateTime $endDate */
             $endDate = clone $event['end'];
             $endDate->setTime(0, 0, 0);
             $configuration->setEndDate($endDate);
             $startTime = $this->dateTimeToDaySeconds($event['start']);
             if ($startTime > 0) {
                 $configuration->setStartTime($startTime);
                 $configuration->setEndTime($this->dateTimeToDaySeconds($event['end']));
                 $configuration->setAllDay(FALSE);
             } else {
                 $configuration->setAllDay(TRUE);
             }
             $eventObject->addCalendarize($configuration);
             $this->eventRepository->add($eventObject);
             $this->enqueueMessage('Add Event: ' . $eventObject->getTitle(), 'Add');
         }
     }
 }
开发者ID:sirdiego,项目名称:calendarize,代码行数:66,代码来源:ImportCommandController.php

示例3: writeFontFile

 /**
  * Writes the GD font file
  *
  * @param \SJBR\SrFreecap\Domain\Model\Font the object to be stored
  * @return \SJBR\SrFreecap\Domain\Repository\FontRepository $this
  */
 public function writeFontFile(\SJBR\SrFreecap\Domain\Model\Font $font)
 {
     $relativeFileName = 'uploads/' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($this->extensionKey) . '/' . $font->getGdFontFilePrefix() . '_' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($font->getGdFontData()) . '.gdf';
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_site . $relativeFileName, $font->getGdFontData())) {
         $font->setGdFontFileName($relativeFileName);
     }
     return $this;
 }
开发者ID:olek07,项目名称:GiGaBonus,代码行数:14,代码来源:FontRepository.php

示例4: writeClassLoadingInformation

 /**
  * Puts all information compiled by the ClassLoadingInformationGenerator to files
  */
 public static function writeClassLoadingInformation()
 {
     self::ensureAutoloadInfoDirExists();
     $classInfoFiles = ClassLoadingInformationGenerator::buildAutoloadInformationFiles();
     GeneralUtility::writeFile(PATH_site . self::AUTOLOAD_INFO_DIR . self::AUTOLOAD_CLASSMAP_FILENAME, $classInfoFiles['classMapFile']);
     GeneralUtility::writeFile(PATH_site . self::AUTOLOAD_INFO_DIR . self::AUTOLOAD_PSR4_FILENAME, $classInfoFiles['psr-4File']);
     $classAliasMapFile = ClassLoadingInformationGenerator::buildClassAliasMapFile();
     GeneralUtility::writeFile(PATH_site . self::AUTOLOAD_INFO_DIR . self::AUTOLOAD_CLASSALIASMAP_FILENAME, $classAliasMapFile);
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:12,代码来源:ClassLoadingInformation.php

示例5: saveExtensionConfiguration

 /**
  * @param \EBT\ExtensionBuilder\Domain\Model\Extension $extension
  */
 public function saveExtensionConfiguration(\EBT\ExtensionBuilder\Domain\Model\Extension $extension)
 {
     $extensionBuildConfiguration = $this->configurationManager->getConfigurationFromModeler();
     $extensionBuildConfiguration['log'] = array('last_modified' => date('Y-m-d h:i'), 'extension_builder_version' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExtensionVersion('extension_builder'), 'be_user' => $GLOBALS['BE_USER']->user['realName'] . ' (' . $GLOBALS['BE_USER']->user['uid'] . ')');
     $encodeOptions = 0;
     // option JSON_PRETTY_PRINT is available since PHP 5.4.0
     if (defined('JSON_PRETTY_PRINT')) {
         $encodeOptions |= JSON_PRETTY_PRINT;
     }
     \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile($extension->getExtensionDir() . \EBT\ExtensionBuilder\Configuration\ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE, json_encode($extensionBuildConfiguration, $encodeOptions));
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:14,代码来源:ExtensionRepository.php

示例6: writeFileAndCreateFolder

 /**
  * Write a file and create the target folder, if the folder do not exists
  *
  * @param string $absoluteFileName
  * @param string $content
  *
  * @return bool
  * @throws Exception
  */
 public static function writeFileAndCreateFolder($absoluteFileName, $content)
 {
     $dir = PathUtility::dirname($absoluteFileName) . '/';
     if (!is_dir($dir)) {
         GeneralUtility::mkdir_deep($dir);
     }
     if (is_file($absoluteFileName) && !is_writable($absoluteFileName)) {
         throw new Exception('The autoloader try to add same content to ' . $absoluteFileName . ' but the file is not writable for the autoloader. Please fix it!', 234627835);
     }
     return GeneralUtility::writeFile($absoluteFileName, $content);
 }
开发者ID:sirdiego,项目名称:autoloader,代码行数:20,代码来源:FileUtility.php

示例7: createHtaccessFile

 /**
  * Create .htaccess file.
  */
 public function createHtaccessFile()
 {
     $htAccessFile = GeneralUtility::getFileAbsFileName(".htaccess");
     if (file_exists($htAccessFile)) {
         $this->addMessage(FlashMessage::NOTICE, '.htaccess not created', ' File .htaccess exists already in the root directory.');
         return;
     }
     $htAccessContent = GeneralUtility::getUrl(PATH_site . 'typo3_src/_.htaccess');
     GeneralUtility::writeFile($htAccessFile, $htAccessContent, TRUE);
     $this->addMessage(FlashMessage::OK, '.htaccess file created', 'File .htaccess was created in the root directory.');
 }
开发者ID:mrmoree,项目名称:vkmh_typo3,代码行数:14,代码来源:InstallService.php

示例8: createFakeExtension

 /**
  * Creates a fake extension with a given table definition.
  *
  * @param string $tableDefinition SQL script to create the extension's tables
  * @throws \RuntimeException
  * @return void
  */
 protected function createFakeExtension($tableDefinition)
 {
     // Prepare a fake extension configuration
     $ext_tables = GeneralUtility::tempnam('ext_tables');
     if (!GeneralUtility::writeFile($ext_tables, $tableDefinition)) {
         throw new \RuntimeException('Can\'t write temporary ext_tables file.');
     }
     $this->temporaryFiles[] = $ext_tables;
     $GLOBALS['TYPO3_LOADED_EXT'] = array('test_dbal' => array('ext_tables.sql' => $ext_tables));
     // Append our test table to the list of existing tables
     $this->subject->initialize();
 }
开发者ID:KarlDennisMatthaei1923,项目名称:PierraaDesign,代码行数:19,代码来源:DatabaseConnectionTest.php

示例9: lockCommand

 /**
  * Locks backend access for all users by writing a lock file that is checked when the backend is accessed.
  *
  * @param string $redirectUrl URL to redirect to when the backend is accessed
  */
 public function lockCommand($redirectUrl = NULL)
 {
     if (@is_file(PATH_typo3conf . 'LOCK_BACKEND')) {
         $this->outputLine('A lockfile already exists. Overwriting it...');
     }
     \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_typo3conf . 'LOCK_BACKEND', (string) $redirectUrl);
     if ($redirectUrl === NULL) {
         $this->outputLine('Wrote lock file to \'typo3conf/LOCK_BACKEND\'');
     } else {
         $this->outputLine('Wrote lock file to \'typo3conf/LOCK_BACKEND\' with instruction to redirect to: \'' . $redirectUrl . '\'');
     }
 }
开发者ID:Outdoorsman,项目名称:typo3_console,代码行数:17,代码来源:BackendCommandController.php

示例10: toArray

 /**
  * Get the ICS events in an array
  *
  * @param string $paramUrl
  *
  * @return array
  */
 function toArray($paramUrl)
 {
     $tempFileName = GeneralUtility::getFileAbsFileName('typo3temp/calendarize_temp_' . GeneralUtility::shortMD5($paramUrl));
     if (filemtime($tempFileName) < time() - 60 * 60) {
         $icsFile = GeneralUtility::getUrl($paramUrl);
         GeneralUtility::writeFile($tempFileName, $icsFile);
     }
     $backend = new ICalParser();
     if ($backend->parseFromFile($tempFileName)) {
         return $backend->getEvents();
     }
     return array();
 }
开发者ID:sirdiego,项目名称:calendarize,代码行数:20,代码来源:IcsReaderService.php

示例11: dumpClassLoadingInformation

 /**
  * Puts all information compiled by the ClassLoadingInformationGenerator to files
  */
 public static function dumpClassLoadingInformation()
 {
     self::ensureAutoloadInfoDirExists();
     $composerClassLoader = static::getClassLoader();
     $activeExtensionPackages = static::getActiveExtensionPackages();
     /** @var ClassLoadingInformationGenerator  $generator */
     $generator = GeneralUtility::makeInstance(ClassLoadingInformationGenerator::class, $composerClassLoader, $activeExtensionPackages, PATH_site, self::isTestingContext());
     $classInfoFiles = $generator->buildAutoloadInformationFiles();
     GeneralUtility::writeFile(self::getClassLoadingInformationDirectory() . self::AUTOLOAD_CLASSMAP_FILENAME, $classInfoFiles['classMapFile']);
     GeneralUtility::writeFile(self::getClassLoadingInformationDirectory() . self::AUTOLOAD_PSR4_FILENAME, $classInfoFiles['psr-4File']);
     $classAliasMapFile = $generator->buildClassAliasMapFile();
     GeneralUtility::writeFile(self::getClassLoadingInformationDirectory() . self::AUTOLOAD_CLASSALIASMAP_FILENAME, $classAliasMapFile);
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:16,代码来源:ClassLoadingInformation.php

示例12: toArray

 /**
  * Get the ICS events in an array
  *
  * @param string $paramUrl
  *
  * @return array
  */
 function toArray($paramUrl)
 {
     $tempFileName = $this->getCheckedCacheFolder() . GeneralUtility::shortMD5($paramUrl);
     if (!is_file($tempFileName) || filemtime($tempFileName) < time() - DateTimeUtility::SECONDS_HOUR) {
         $icsFile = GeneralUtility::getUrl($paramUrl);
         GeneralUtility::writeFile($tempFileName, $icsFile);
     }
     $backend = new ICalParser();
     if ($backend->parseFromFile($tempFileName)) {
         return $backend->getEvents();
     }
     return [];
 }
开发者ID:kaptankorkut,项目名称:calendarize,代码行数:20,代码来源:IcsReaderService.php

示例13: 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;
 }
开发者ID:xperseguers,项目名称:t3ext-doodle,代码行数:23,代码来源:DoodleUtility.php

示例14: cli_main

    /**
     * CLI engine
     *
     * @param array $argv Command line arguments
     * @return string
     * @todo Define visibility
     */
    public function cli_main($argv)
    {
        // Force user to admin state and set workspace to "Live":
        $GLOBALS['BE_USER']->user['admin'] = 1;
        $GLOBALS['BE_USER']->setWorkspace(0);
        // Print help
        $analysisType = (string) $this->cli_args['_DEFAULT'][1];
        if (!$analysisType) {
            $this->cli_validateArgs();
            $this->cli_help();
            die;
        }
        // Analysis type:
        switch ((string) $analysisType) {
            case 'setBElock':
                if (@is_file(PATH_typo3conf . 'LOCK_BACKEND')) {
                    $this->cli_echo('A lockfile already exists. Overwriting it...
');
                }
                $lockFileContent = $this->cli_argValue('--redirect');
                \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_typo3conf . 'LOCK_BACKEND', $lockFileContent);
                $this->cli_echo('Wrote lock-file to \'' . PATH_typo3conf . 'LOCK_BACKEND\' with content \'' . $lockFileContent . '\'');
                break;
            case 'clearBElock':
                if (@is_file(PATH_typo3conf . 'LOCK_BACKEND')) {
                    unlink(PATH_typo3conf . 'LOCK_BACKEND');
                    if (@is_file(PATH_typo3conf . 'LOCK_BACKEND')) {
                        $this->cli_echo('ERROR: Could not remove lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\'!!
', 1);
                    } else {
                        $this->cli_echo('Removed lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\'
');
                    }
                } else {
                    $this->cli_echo('No lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\' was found; hence no lock can be removed.\'
');
                }
                break;
            default:
                $this->cli_echo('Unknown toolkey, \'' . $analysisType . '\'');
        }
        $this->cli_echo(LF);
    }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:50,代码来源:AdminCommand.php

示例15: createDefaultHtaccessFile

 /**
  * Creates .htaccess file inside the root directory
  *
  * @param string $htaccessFile Path of .htaccess file
  * @return void
  */
 public function createDefaultHtaccessFile()
 {
     $htaccessFile = GeneralUtility::getFileAbsFileName(".htaccess");
     if (file_exists($htaccessFile)) {
         /**
          * Add Flashmessage that there is already an .htaccess file and we are not going to override this.
          */
         $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'There is already an Apache .htaccess file in the root directory, please make sure that the url rewritings are set properly.<br>' . 'An example configuration is located at: <strong>typo3conf/ext/bootstrap_package/Configuration/Apache/.htaccess</strong>', 'Apache .htaccess file already exists', FlashMessage::NOTICE, TRUE);
         FlashMessageQueue::addMessage($message);
         return;
     }
     $htaccessContent = GeneralUtility::getUrl(ExtensionManagementUtility::extPath($this->extKey) . '/Configuration/Apache/.htaccess');
     GeneralUtility::writeFile($htaccessFile, $htaccessContent, TRUE);
     /**
      * Add Flashmessage that the example htaccess file was placed in the root directory
      */
     $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'For RealURL and optimization purposes an example .htaccess file was placed in your root directory. <br>' . ' Please check if the RewriteBase correctly set for your environment. ', 'Apache example .htaccess was placed in the root directory.', FlashMessage::OK, TRUE);
     FlashMessageQueue::addMessage($message);
 }
开发者ID:woehrlag,项目名称:Intranet,代码行数:25,代码来源:InstallService.php


注:本文中的TYPO3\CMS\Core\Utility\GeneralUtility::writeFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。