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


PHP WriteInterface::writeFile方法代码示例

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


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

示例1: _hideBackupsForApache

 /**
  * Create .htaccess file and deny backups directory access from web
  *
  * @return void
  */
 protected function _hideBackupsForApache()
 {
     $filename = '.htaccess';
     if (!$this->_varDirectory->isFile($filename)) {
         $this->_varDirectory->writeFile($filename, 'deny from all');
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:Collection.php

示例2: createFile

 /**
  * Write down contents to a temporary file and return its absolute path
  *
  * @param string $relativePath
  * @param string $contents
  * @return string
  */
 public function createFile($relativePath, $contents)
 {
     $filePath = $this->config->getLessMaterializationRelativePath() . '/' . $relativePath;
     if (!$this->tmpDirectory->isExist($filePath)) {
         $this->tmpDirectory->writeFile($filePath, $contents);
     }
     return $this->tmpDirectory->getAbsolutePath($filePath);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Temporary.php

示例3: downloadDb

 /**
  * @param string $dbCode
  * @throws LocalizedException
  */
 protected function downloadDb($dbCode)
 {
     $contents = $this->loadDbContent($this->getDbUrl($dbCode));
     $this->directory->writeFile($this->getDbArchiveFilePath($dbCode), $contents);
     if (!$this->directory->isExist($this->getDbArchiveFilePath($dbCode))) {
         throw new LocalizedException(__('Cannot save db file.'));
     }
 }
开发者ID:ytorbyk,项目名称:magento2-geo-ip2,代码行数:12,代码来源:Updater.php

示例4: lockProcess

 /**
  * @inheritdoc
  * @throws FileSystemException
  */
 public function lockProcess($lockName)
 {
     $this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->lockFilePath = $this->getFilePath($lockName);
     while ($this->isProcessLocked()) {
         sleep(1);
     }
     $this->tmpDirectory->writeFile($this->lockFilePath, time());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:LockerProcess.php

示例5: minify

 /**
  * Minify template file
  *
  * @param string $file
  * @return void
  */
 public function minify($file)
 {
     $file = $this->rootDirectory->getRelativePath($file);
     $content = preg_replace('#(?<!]]>)\\s+</#', '</', preg_replace('#((?:<\\?php\\s+(?!echo|print|if|elseif|else)[^\\?]*)\\?>)\\s+#', '$1 ', preg_replace('#(?<!' . implode('|', $this->inlineHtmlTags) . ')\\> \\<#', '><', preg_replace('#(?ix)(?>[^\\S ]\\s*|\\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:textarea|pre|script)\\b))*+)' . '(?:<(?>textarea|pre|script)\\b|\\z))#', ' ', preg_replace('#(?<!:|\\\\|\'|")//(?!\\s*\\<\\!\\[)(?!\\s*]]\\>)[^\\n\\r]*#', '', preg_replace('#(?<!:)//[^\\n\\r]*(\\s\\?\\>)#', '$1', preg_replace('#//[^\\n\\r]*(\\<\\?php)[^\\n\\r]*(\\s\\?\\>)[^\\n\\r]*#', '', $this->rootDirectory->readFile($file))))))));
     if (!$this->htmlDirectory->isExist()) {
         $this->htmlDirectory->create();
     }
     $this->htmlDirectory->writeFile($file, rtrim($content));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Minifier.php

示例6: lockProcess

 /**
  * @inheritdoc
  * @throws FileSystemException
  */
 public function lockProcess($lockName)
 {
     if ($this->getState()->getMode() == State::MODE_PRODUCTION) {
         return;
     }
     $this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
     $this->lockFilePath = $this->getFilePath($lockName);
     while ($this->isProcessLocked()) {
         usleep(1000);
     }
     $this->tmpDirectory->writeFile($this->lockFilePath, time());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:LockerProcess.php

示例7: preProcess

 /**
  * Perform necessary preprocessing and materialization when the specified asset is requested
  *
  * Returns an array of two elements:
  * - directory code where the file is supposed to be found
  * - relative path to the file
  *
  * Automatically caches the obtained successful results or returns false if source file was not found
  *
  * @param LocalInterface $asset
  * @return array|bool
  */
 private function preProcess(LocalInterface $asset)
 {
     $sourceFile = $this->findSourceFile($asset);
     if (!$sourceFile) {
         return false;
     }
     $dirCode = \Magento\Framework\App\Filesystem::ROOT_DIR;
     $path = $this->rootDir->getRelativePath($sourceFile);
     $cacheId = $path . ':' . $asset->getPath();
     $cached = $this->cache->load($cacheId);
     if ($cached) {
         return unserialize($cached);
     }
     $chain = new \Magento\Framework\View\Asset\PreProcessor\Chain($asset, $this->rootDir->readFile($path), $this->getContentType($path));
     $preProcessors = $this->preProcessorPool->getPreProcessors($chain->getOrigContentType(), $chain->getTargetContentType());
     foreach ($preProcessors as $processor) {
         $processor->process($chain);
     }
     $chain->assertValid();
     if ($chain->isChanged()) {
         $dirCode = \Magento\Framework\App\Filesystem::VAR_DIR;
         $path = self::TMP_MATERIALIZATION_DIR . '/source/' . $asset->getPath();
         $this->varDir->writeFile($path, $chain->getContent());
     }
     $result = array($dirCode, $path);
     $this->cache->save(serialize($result), $cacheId);
     return $result;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:40,代码来源:Source.php

示例8: preProcess

    /**
     * Perform necessary preprocessing and materialization when the specified asset is requested
     *
     * Returns an array of two elements:
     * - directory code where the file is supposed to be found
     * - relative path to the file
     *
     * Automatically caches the obtained successful results or returns false if source file was not found
     *
     * @param LocalInterface $asset
     * @return array|bool
     */
    private function preProcess(LocalInterface $asset)
    {
        $sourceFile = $this->findSourceFile($asset);
        $dirCode = DirectoryList::ROOT;
        $path = $this->rootDir->getRelativePath($sourceFile);
        $cacheId = $path . ':' . $asset->getPath();
        $cached = $this->cache->load($cacheId);
        if ($cached) {
            return unserialize($cached);
        }

        $origContent = $path ? $this->rootDir->readFile($path) : '';
        $origContentType = $this->getContentType($path) ?: $asset->getContentType();

        $chain = $this->chainFactory->create(
            [
                'asset' => $asset,
                'origContent' => $origContent,
                'origContentType' => $origContentType,
                'origAssetPath' => $path
            ]
        );

        $this->preProcessorPool->process($chain);
        $chain->assertValid();
        if ($chain->isChanged()) {
            $dirCode = DirectoryList::VAR_DIR;
            $path = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath();
            $this->varDir->writeFile($path, $chain->getContent());
        }
        $result = [$dirCode, $path];
        $this->cache->save(serialize($result), $cacheId);
        return $result;
    }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:46,代码来源:Source.php

示例9: preProcess

    /**
     * Perform necessary preprocessing and materialization when the specified asset is requested
     *
     * Returns an array of two elements:
     * - directory code where the file is supposed to be found
     * - relative path to the file
     *
     * Automatically caches the obtained successful results or returns false if source file was not found
     *
     * @param LocalInterface $asset
     * @return array|bool
     */
    private function preProcess(LocalInterface $asset)
    {
        $sourceFile = $this->findSourceFile($asset);
        if ($sourceFile !== false) {
            $path = $this->rootDir->getRelativePath($sourceFile);
        } else {
            // No original file, the resulting file may be generated by a pre-processor
            $path = false;
        }
        $cacheId = $path . ':' . $asset->getPath();
        $cached = $this->cache->load($cacheId);
        if ($cached) {
            return unserialize($cached);
        }

        $chain = $this->createChain($asset, $path);
        $this->preProcessorPool->process($chain);
        $chain->assertValid();
        $dirCode = DirectoryList::ROOT;
        if ($chain->isChanged()) {
            $dirCode = DirectoryList::VAR_DIR;
            $path = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath();
            $this->varDir->writeFile($path, $chain->getContent());
        }
        $result = [$dirCode, $path];
        $this->cache->save(serialize($result), $cacheId);
        return $result;
    }
开发者ID:nja78,项目名称:magento2,代码行数:40,代码来源:Source.php

示例10: _createCertFile

 /**
  * Create physical certificate file based on DB data
  *
  * @param string $file
  * @return void
  */
 protected function _createCertFile($file)
 {
     if ($this->varDirectory->isDirectory(self::BASEPATH_PAYPAL_CERT)) {
         $this->_removeOutdatedCertFile();
     }
     $this->varDirectory->writeFile($file, $this->encryptor->decrypt($this->getContent()));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Cert.php

示例11: preProcess

    /**
     * Perform necessary preprocessing and materialization when the specified asset is requested
     *
     * Returns an array of two elements:
     * - directory where the file is supposed to be found
     * - relative path to the file
     *
     * returns false if source file was not found
     *
     * @param LocalInterface $asset
     * @return array|bool
     */
    private function preProcess(LocalInterface $asset)
    {
        $sourceFile = $this->findSourceFile($asset);
        $dir = $this->rootDir->getAbsolutePath();
        $path = '';
        if ($sourceFile) {
            $path = basename($sourceFile);
            $dir = dirname($sourceFile);
        }

        $chain = $this->createChain($asset, $dir, $path);
        $this->preProcessorPool->process($chain);
        $chain->assertValid();
        if ($chain->isChanged()) {
            $dir = $this->varDir->getAbsolutePath();
            $path = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath();
            $this->varDir->writeFile($path, $chain->getContent());
        }
        if (empty($path)) {
            $result = false;
        } else {
            $result = [$dir, $path];
        }
        return $result;
    }
开发者ID:rafaelstz,项目名称:magento2,代码行数:37,代码来源:Source.php

示例12: setFile

 /**
  * Set the backup file content
  *
  * @param string &$content
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function setFile(&$content)
 {
     if (!$this->hasData('time') || !$this->hasData('type') || !$this->hasData('path')) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the order of creation for a new backup.'));
     }
     $this->varDirectory->writeFile($this->_getFilePath(), $content);
     return $this;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:15,代码来源:Backup.php

示例13: _initFilesystem

 /**
  * Directory structure initializing
  *
  * @return void
  */
 protected function _initFilesystem()
 {
     $this->_mediaDirectory->create($this->_path);
     $this->_mediaDirectory->create($this->_quotePath);
     $this->_mediaDirectory->create($this->_orderPath);
     // Directory listing and hotlink secure
     $path = $this->_path . '/.htaccess';
     if (!$this->_mediaDirectory->isFile($path)) {
         $this->_mediaDirectory->writeFile($path, "Order deny,allow\nDeny from all");
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:File.php

示例14: move

 /**
  * Proceed moving a file from TMP to destination folder
  *
  * @param string $fileName
  * @return array
  */
 public function move($fileName)
 {
     if (preg_match('/\\bhttps?:\\/\\//i', $fileName, $matches)) {
         $url = str_replace($matches[0], '', $fileName);
         $read = $this->_readFactory->create($url, DriverPool::HTTP);
         $fileName = preg_replace('/[^a-z0-9\\._-]+/i', '', $fileName);
         $this->_directory->writeFile($this->_directory->getRelativePath($this->getTmpDir() . '/' . $fileName), $read->readAll());
     }
     $filePath = $this->_directory->getRelativePath($this->getTmpDir() . '/' . $fileName);
     $this->_setUploadFile($filePath);
     $result = $this->save($this->getDestDir());
     $result['name'] = self::getCorrectFileName($result['name']);
     return $result;
 }
开发者ID:kid17,项目名称:magento2,代码行数:20,代码来源:Uploader.php

示例15: setAddresses

 /**
  * Sets list of allowed IP addresses
  *
  * @param string $addresses
  * @return bool
  * @throws \InvalidArgumentException
  */
 public function setAddresses($addresses)
 {
     $addresses = (string) $addresses;
     if (empty($addresses)) {
         if ($this->flagDir->isExist(self::IP_FILENAME)) {
             return $this->flagDir->delete(self::IP_FILENAME);
         }
         return true;
     }
     if (!preg_match('/^[^\\s,]+(,[^\\s,]+)*$/', $addresses)) {
         throw new \InvalidArgumentException("One or more IP-addresses is expected (comma-separated)\n");
     }
     $result = $this->flagDir->writeFile(self::IP_FILENAME, $addresses);
     return false !== $result ? true : false;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:MaintenanceMode.php


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