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


PHP FileManager::write方法代码示例

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


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

示例1: writeCallToSourceFile

 /**
  * Modify class source
  *
  * @param \Includes\Decorator\DataStructure\Graph\Classes $node Current node
  *
  * @return void
  */
 protected function writeCallToSourceFile(\Includes\Decorator\DataStructure\Graph\Classes $node)
 {
     $path = LC_DIR_CACHE_CLASSES . $node->getPath();
     $content = \Includes\Utils\FileManager::read($path);
     $content .= PHP_EOL . '// Call static constructor' . PHP_EOL;
     $content .= '\\' . $node->getClass() . '::' . static::STATIC_CONSTRUCTOR_METHOD . '();';
     \Includes\Utils\FileManager::write($path, $content);
 }
开发者ID:kingsj,项目名称:core,代码行数:15,代码来源:Main.php

示例2: logInfo

 /**
  * Add info to a log file
  *
  * @param string  $message   Error message
  * @param integer $code      Error code
  * @param string  $backtrace Stack trace OPTIONAL
  *
  * @return void
  */
 protected static function logInfo($message, $code, $backtrace = null)
 {
     if (!isset($backtrace)) {
         ob_start();
         debug_print_backtrace();
         $backtrace = ob_get_contents();
         ob_end_clean();
     }
     $message = date('[d-M-Y H:i:s]') . ' Error (code: ' . $code . '): ' . $message . PHP_EOL;
     // Add additional info
     $parts = array('Server API: ' . PHP_SAPI);
     if (isset($_SERVER)) {
         if (isset($_SERVER['REQUEST_METHOD'])) {
             $parts[] = 'Request method: ' . $_SERVER['REQUEST_METHOD'];
         }
         if (isset($_SERVER['REQUEST_URI'])) {
             $parts[] = 'URI: ' . $_SERVER['REQUEST_URI'];
         }
     }
     $message .= implode(';' . PHP_EOL, $parts) . ';' . PHP_EOL;
     $message .= 'Backtrace: ' . PHP_EOL . $backtrace . PHP_EOL . PHP_EOL;
     \Includes\Utils\FileManager::write(static::getLogFile(), $message, FILE_APPEND);
 }
开发者ID:kingsj,项目名称:core,代码行数:32,代码来源:ErrorHandler.php

示例3: getFilePointer

    /**
     * Get file pointer
     * This dedicates to greatest developer of all time, Maxim Shamaev. Because getFilename() is not enough for name combining.
     *
     * @return resource
     */
    protected function getFilePointer()
    {
        if (!isset($this->filePointer)) {
            $name = $this->getFilename();
            $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->generator->getOptions()->dir);
            if (is_writable($dir)) {
                if (!\Includes\Utils\FileManager::isExists($dir . LC_DS . '.htaccess')) {
                    // Try to create .htaccess file to protect directory
                    $out = <<<OUT
Options -Indexes

Deny from all

OUT;
                    \Includes\Utils\FileManager::write($dir . LC_DS . '.htaccess', $out);
                }
                $this->filePath = $dir . LC_DS . $name;
                $this->filePointer = @fopen($dir . LC_DS . $name, 'ab');
            } else {
                $this->generator->addError(static::t('Directory does not have permissions to write'), static::t('Directory X does not have permissions to write. Please set necessary permissions to directory X.', array('path' => $dir)));
            }
        }
        return $this->filePointer;
    }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:30,代码来源:Categories.php

示例4: saveHashesForInstalledFiles

 /**
  * Save hashes for current version
  *
  * @return void
  */
 protected function saveHashesForInstalledFiles()
 {
     $data = $this->loadHashesForInstalledFiles();
     if (is_array($data)) {
         \Includes\Utils\FileManager::write($this->getCurrentVersionHashesFilePath(), '<?php' . PHP_EOL . '$data = ' . var_export($data, true) . ';');
     }
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:12,代码来源:AEntry.php

示例5: saveFile

 /**
  * Save schema to file
  *
  * @return void
  */
 protected static function saveFile()
 {
     $string = implode(';', static::$schema);
     \Includes\Utils\FileManager::write(static::getDBSchemaFilePath(), $string);
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:10,代码来源:DBSchemaManager.php

示例6: doSave

 /**
  * Save cell data
  *
  * @param string  $id       Cell id
  * @param mixed   $data     Cell data
  * @param integer $lifeTime Cell TTL OPTIONAL
  *
  * @return boolean
  */
 protected function doSave($id, $data, $lifeTime = 0)
 {
     $lifeTime = max(0, intval($lifeTime));
     if ($lifeTime) {
         $lifeTime += LC_START_TIME;
     }
     $lifeTime = strval($lifeTime);
     return \Includes\Utils\FileManager::write($this->getPathById($id), $this->header . str_repeat(' ', $this->ttlLength - strlen($lifeTime)) . $lifeTime . serialize($data));
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:18,代码来源:FileCache.php

示例7: makeLESSResourcePath

 /**
  * Create a main less file for the provided less files collection
  *
  * @param array $lessFiles LESS files structures array
  *
  * @return string LESS file name
  */
 protected function makeLESSResourcePath($lessFiles)
 {
     $filePath = $this->getCacheDir('screen') . $this->getUniqueName($lessFiles) . '.less';
     if (!is_file($filePath)) {
         $content = '';
         foreach ($lessFiles as $resource) {
             $resourcePath = \Includes\Utils\FileManager::makeRelativePath($this->getCacheDir('screen'), $resource['file']);
             $content .= "\r\n" . '@import "' . str_replace('/', LC_DS, $resourcePath) . '";' . "\r\n";
         }
         \Includes\Utils\FileManager::mkdirRecursive(dirname($filePath));
         \Includes\Utils\FileManager::write($filePath, $content);
     }
     return $filePath;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:21,代码来源:LessParser.php

示例8: divideCSVFile

 /**
  * Divide large CSV file into several parts and return list of part files
  *
  * @param \SplFileObject $file File object
  *
  * @return array
  */
 public function divideCSVFile($file)
 {
     $result = array();
     $outputFileFormat = basename($file->getRealPath());
     $f = fopen($file->getRealPath(), 'rb');
     // Part file index
     $fi = 1;
     // Row index
     $i = 0;
     $ip = 0;
     // Delta (sum of rows in all previous part files)
     $delta = 0;
     $content = '';
     $pendingContent = '';
     $columns = $this->getKeyColumns();
     // Subdirectory of tmp dir to write CSV part files
     $subDir = time();
     while (true) {
         $fields = fgetcsv($f, 0, ',', '"');
         if (false !== $fields && 1 === count($fields) && null === $fields[0]) {
             // Skip blank lines
             continue;
         }
         if (null === $header) {
             // Initialize header
             $this->processHeaderRow(array($fields));
             $header = $this->getCSVString($fields);
             continue;
         }
         $save = false;
         if (false !== $fields) {
             // Get current row content
             $currentRow = $this->getCSVString($fields);
             $isSubrow = true;
             if (!empty($prevFields)) {
                 // Check if next line is subrow of current
                 $isEmpty = true;
                 foreach ($columns as $column) {
                     $prevKey = $this->getColumnValue($column, $prevFields);
                     $isEmpty = $isEmpty && !(bool) $prevKey;
                     if (!$isEmpty && $prevKey !== $this->getColumnValue($column, $fields)) {
                         $isSubrow = false;
                         break;
                     }
                 }
                 $isSubrow = $isEmpty ? false : $isSubrow;
             } else {
                 $isSubrow = false;
             }
             if (!$isSubrow) {
                 $prevFields = $fields;
             }
             // Prepare content
             if ($isSubrow) {
                 // Current row is a subrow or one of previous rows - add this to $pendingContent
                 $pendingContent .= $currentRow;
                 $ip++;
             } else {
                 // Current row is a complete row - merge $pendingContent into $content...
                 $content .= $pendingContent;
                 $i += $ip;
                 // ...then initialize $pendingContent with current row value
                 $pendingContent = $currentRow;
                 $ip = 1;
             }
             if ($i >= static::MAX_PART_FILE_ROWS && $content) {
                 $save = true;
             }
         }
         if ($save || false === $fields) {
             $outputFile = LC_DIR_TMP . $subDir . LC_DS . preg_replace('/(\\.csv)$/', sprintf('.part-%02d.csv', $fi++), $outputFileFormat);
             if (!\Includes\Utils\FileManager::write($outputFile, $header . $content)) {
                 \XLite\Logger::getInstance()->log('Cannot write file ' . $outputFile);
                 $result = array();
                 break;
             }
             $result[] = array('file' => $outputFile, 'delta' => $delta);
             $delta += $i;
             $i = 0;
             $content = '';
         }
         if (false === $fields) {
             break;
         }
     }
     // while
     return $result;
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:95,代码来源:AProcessor.php

示例9: writeData

 /**
  * Put prepared code into the files
  *
  * @return void
  */
 protected function writeData()
 {
     foreach ($this->replacements as $file => $code) {
         \Includes\Utils\FileManager::write($file = \Includes\Decorator\ADecorator::getCacheClassesDir() . $file, \Includes\Decorator\Utils\Tokenizer::addCodeToClassBody($file, $code));
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:11,代码来源:Main.php

示例10: writeData

 /**
  * Put prepared code into the files
  *
  * @return void
  */
 protected function writeData()
 {
     foreach ($this->replacements as $file => $code) {
         \Includes\Utils\FileManager::write($file = LC_DIR_CACHE_CLASSES . $file, \Includes\Decorator\Utils\Tokenizer::addCodeToClassBody($file, $code));
     }
 }
开发者ID:kingsj,项目名称:core,代码行数:11,代码来源:Main.php

示例11: saveTrackingFile

 /**
  * Save tracking file
  *
  * @param \XLite\Core\CommonCell $data    File data
  * @param string                 $docType Document type
  * @param boolean                $flush   Flag - flush changes or not (OPTIONAL)
  *
  * @return void
  */
 protected function saveTrackingFile($data, $docType, $flush = true)
 {
     // Save file to temporary location
     $filePath = LC_DIR_TMP . 't' . strtolower($docType) . $this->getShipment()->getId() . '_' . $data->filename;
     \Includes\Utils\FileManager::write($filePath, base64_decode($data->image));
     $file = $this->getFileByDocType($docType);
     if (!isset($file)) {
         $file = new \XLite\Module\XC\CanadaPost\Model\Order\Parcel\Shipment\Tracking\File();
         $file->setDocType($docType);
         \XLite\Core\Database::getEM()->persist($file);
         $this->addFile($file);
     }
     $file->loadFromLocalFile($filePath);
     $file->setMime($data->mimeType);
     if ($flush) {
         \XLite\Core\Database::getEM()->flush();
     }
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:27,代码来源:Tracking.php

示例12: logInfo

 /**
  * Add info to a log file
  *
  * @param string  $message   Error message
  * @param integer $code      Error code
  * @param string  $backtrace Stack trace OPTIONAL
  *
  * @return void
  */
 protected static function logInfo($message, $code, $backtrace = null)
 {
     if (!isset($backtrace) && 'cli' != PHP_SAPI) {
         ob_start();
         if (defined('DEBUG_BACKTRACE_IGNORE_ARGS')) {
             debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
         } else {
             debug_print_backtrace();
         }
         $backtrace = ob_get_contents();
         ob_end_clean();
     }
     $message = date('[d-M-Y H:i:s]') . ' Error (code: ' . $code . '): ' . $message . PHP_EOL;
     // Add additional info
     $parts = array('Server API: ' . PHP_SAPI);
     if (!empty($_SERVER)) {
         if (isset($_SERVER['REQUEST_METHOD'])) {
             $parts[] = 'Request method: ' . $_SERVER['REQUEST_METHOD'];
         }
         if (isset($_SERVER['REQUEST_URI'])) {
             $parts[] = 'URI: ' . $_SERVER['REQUEST_URI'];
         }
     }
     $message .= implode(';' . PHP_EOL, $parts) . ';' . PHP_EOL;
     if ($backtrace && $code != static::ERROR_CLOSED) {
         $message .= 'Backtrace: ' . PHP_EOL . $backtrace . PHP_EOL . PHP_EOL;
     }
     \Includes\Utils\FileManager::write(static::getLogFile($code), $message, FILE_APPEND);
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:38,代码来源:ErrorHandler.php

示例13: correctTagsOnElement

 /**
  * Correct (if needed) class doc block comment. Works for one element from the queue
  *
  * @param \Includes\Decorator\DataStructure\Graph\Classes $node Current node
  *
  * @return void
  */
 protected function correctTagsOnElement(\Includes\Decorator\DataStructure\Graph\Classes $node)
 {
     $path = LC_DIR_CACHE_CLASSES . $node->getPath();
     \Includes\Utils\FileManager::write($path, \Includes\Decorator\Utils\Tokenizer::getSourceCode($path, null, null, null, call_user_func_array(array($node, 'addLinesToDocBlock'), $this->getTagsToAdd($node)), $node->isDecorator() ? 'abstract' : null));
 }
开发者ID:kingsj,项目名称:core,代码行数:12,代码来源:ADocBlock.php

示例14: writeRecord

 /**
  * Write record 
  * 
  * @param string $string String
  *  
  * @return void
  */
 protected function writeRecord($string)
 {
     if (!isset($this->fileIndex)) {
         $this->fileIndex = 1;
         \Includes\Utils\FileManager::write($this->getSitemapPath(), $this->getHead());
     }
     \Includes\Utils\FileManager::write($this->getSitemapPath(), $string, FILE_APPEND);
     $this->emptyFile = false;
     if ($this->needSwitch()) {
         \Includes\Utils\FileManager::write($this->getSitemapPath(), $this->getFooter(), FILE_APPEND);
         $this->fileIndex++;
         \Includes\Utils\FileManager::write($this->getSitemapPath(), $this->getHead(), FILE_APPEND);
         $this->emptyFile = true;
     }
 }
开发者ID:kingsj,项目名称:core,代码行数:22,代码来源:SitemapGenerator.php

示例15: resizeIcon

 /**
  * Resize icon
  *
  * @param integer $width  Destination width
  * @param integer $height Destination height
  * @param string  $path   Write path
  *
  * @return array
  */
 protected function resizeIcon($width, $height, $path)
 {
     $operator = new \XLite\Core\ImageOperator($this);
     list($newWidth, $newHeight, $result) = $operator->resizeDown($width, $height);
     return false !== $result && \Includes\Utils\FileManager::write($path, $operator->getImage()) ? array($newWidth, $newHeight) : null;
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:15,代码来源:Image.php


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