當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Directory\WriteInterface類代碼示例

本文整理匯總了PHP中Magento\Framework\Filesystem\Directory\WriteInterface的典型用法代碼示例。如果您正苦於以下問題:PHP WriteInterface類的具體用法?PHP WriteInterface怎麽用?PHP WriteInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了WriteInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 protected function setUp()
 {
     $this->stream = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\File\\WriteInterface');
     $this->dir = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
     $this->dir->expects($this->any())->method('openFile')->with(self::DEBUG_FILE, 'a')->will($this->returnValue($this->stream));
     $filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $filesystem->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->dir));
     $this->object = new File($filesystem, self::DEBUG_FILE);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:9,代碼來源:FileTest.php

示例2: tearDown

    /**
     * Clear state file
     */
    protected function tearDown()
    {
        $this->filesystem->expects($this->any())->method('getDirectoryWrite')->willReturn($this->writeInterface);
        $this->writeInterface->expects($this->any())->method('openFile')->willReturnSelf($this->absolutePath);

        $this->state->clearState();
    }
開發者ID:rafaelstz,項目名稱:magento2,代碼行數:10,代碼來源:StateTest.php

示例3: getCsvFile

 /**
  * Returns CSV file
  *
  * @return array
  * @throws LocalizedException
  */
 public function getCsvFile()
 {
     $component = $this->filter->getComponent();
     $name = md5(microtime());
     $file = 'export/' . $component->getName() . $name . '.csv';
     $this->filter->prepareComponent($component);
     $this->filter->applySelectionOnTargetProvider();
     $dataProvider = $component->getContext()->getDataProvider();
     $fields = $this->metadataProvider->getFields($component);
     $options = $this->metadataProvider->getOptions();
     $this->directory->create('export');
     $stream = $this->directory->openFile($file, 'w+');
     $stream->lock();
     $stream->writeCsv($this->metadataProvider->getHeaders($component));
     $i = 1;
     $searchCriteria = $dataProvider->getSearchCriteria()->setCurrentPage($i)->setPageSize($this->pageSize);
     $totalCount = (int) $dataProvider->getSearchResult()->getTotalCount();
     while ($totalCount > 0) {
         $items = $dataProvider->getSearchResult()->getItems();
         foreach ($items as $item) {
             $this->metadataProvider->convertDate($item, $component->getName());
             $stream->writeCsv($this->metadataProvider->getRowData($item, $fields, $options));
         }
         $searchCriteria->setCurrentPage(++$i);
         $totalCount = $totalCount - $this->pageSize;
     }
     $stream->unlock();
     $stream->close();
     return ['type' => 'filename', 'value' => $file, 'rm' => true];
 }
開發者ID:uibar,項目名稱:lavinia2,代碼行數:36,代碼來源:ConvertToCsv.php

示例4: 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

示例5: testPublish

 public function testPublish()
 {
     $this->staticDirRead->expects($this->once())->method('isExist')->with('some/file.ext')->will($this->returnValue(false));
     $materializationStrategy = $this->getMock('Magento\\Framework\\App\\View\\Asset\\MaterializationStrategy\\StrategyInterface', [], [], '', false);
     $this->rootDirWrite->expects($this->once())->method('getRelativePath')->with('/root/some/file.ext')->will($this->returnValue('some/file.ext'));
     $this->materializationStrategyFactory->expects($this->once())->method('create')->with($this->getAsset())->will($this->returnValue($materializationStrategy));
     $materializationStrategy->expects($this->once())->method('publishFile')->with($this->rootDirWrite, $this->staticDirWrite, 'some/file.ext', 'some/file.ext')->will($this->returnValue(true));
     $this->assertTrue($this->object->publish($this->getAsset()));
 }
開發者ID:IlyaGluschenko,項目名稱:protection,代碼行數:9,代碼來源:PublisherTest.php

示例6: testMergeMtimeUnchanged

 public function testMergeMtimeUnchanged()
 {
     $this->targetDir->expects($this->once())->method('isExist')->with('merged/result.txt.dat')->will($this->returnValue(true));
     $this->targetDir->expects($this->once())->method('readFile')->with('merged/result.txt.dat')->will($this->returnValue('11'));
     $assets = $this->getAssetsToMerge();
     $this->mergerMock->expects($this->never())->method('merge');
     $this->targetDir->expects($this->never())->method('writeFile');
     $this->checksum->merge($assets, $this->resultAsset);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:9,代碼來源:ChecksumTest.php

示例7: 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

示例8: log

 /**
  * {@inheritdoc}
  */
 public function log($str)
 {
     $str = '## ' . date('Y-m-d H:i:s') . "\r\n" . $str;
     $stream = $this->dir->openFile($this->debugFile, 'a');
     $stream->lock();
     $stream->write($str);
     $stream->unlock();
     $stream->close();
 }
開發者ID:IlyaGluschenko,項目名稱:test001,代碼行數:12,代碼來源:File.php

示例9: execute

 /**
  * Flash ISM_BaseRunner cache
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $dir = $this->_mediaDirectory->getAbsolutePath(Upload::UPLOAD_POST_IMAGE_DIR . 'cache/');
     if (is_dir($dir)) {
         $dir = $this->_mediaDirectory->getDriver()->readDirectory($dir);
         foreach ($dir as $file) {
             $this->_mediaDirectory->delete(Upload::UPLOAD_POST_IMAGE_DIR . 'cache/' . basename($file));
         }
     }
 }
開發者ID:swnsma,項目名稱:practice,代碼行數:16,代碼來源:FlushAllCache.php

示例10: _generateRow

 /**
  * Get backup-specific data from model for each row
  *
  * @param string $filename
  * @return array
  */
 protected function _generateRow($filename)
 {
     $row = parent::_generateRow($filename);
     foreach ($this->_backup->load($row['basename'], $this->_varDirectory->getAbsolutePath($this->_path))->getData() as $key => $value) {
         $row[$key] = $value;
     }
     $row['size'] = $this->_varDirectory->stat($this->_varDirectory->getRelativePath($filename))['size'];
     $row['id'] = $row['time'] . '_' . $row['type'];
     return $row;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:16,代碼來源:Collection.php

示例11: testMergeCss

 public function testMergeCss()
 {
     $this->resultAsset->expects($this->exactly(3))->method('getPath')->will($this->returnValue('foo/result'));
     $this->resultAsset->expects($this->any())->method('getContentType')->will($this->returnValue('css'));
     $assets = $this->prepareAssetsToMerge(['one', 'two']);
     $this->cssUrlResolver->expects($this->exactly(2))->method('relocateRelativeUrls')->will($this->onConsecutiveCalls('1', '2'));
     $this->cssUrlResolver->expects($this->once())->method('aggregateImportDirectives')->with('12')->will($this->returnValue('1020'));
     $this->writeDir->expects($this->once())->method('writeFile')->with('foo/result', '1020');
     $this->object->merge($assets, $this->resultAsset);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:10,代碼來源:DirectTest.php

示例12: getFile

 /**
  * Get file handler by process ID
  *
  * @param string $processId
  * @return File
  */
 public function getFile($processId)
 {
     if (!isset($this->_fileHandlers[$processId])) {
         $this->_varDirectory->create('locks');
         $fileName = 'locks/index_process_' . $processId . '.lock';
         $stream = $this->_varDirectory->openFile($fileName, 'w+');
         $stream->write(date('r'));
         $this->_fileHandlers[$processId] = $this->_fileFactory->create(array('streamHandler' => $stream));
     }
     return $this->_fileHandlers[$processId];
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:17,代碼來源:Storage.php

示例13: testCreateRequireJsAssetDevMode

 public function testCreateRequireJsAssetDevMode()
 {
     $this->config->expects($this->once())->method('getConfigFileRelativePath')->will($this->returnValue('requirejs/file.js'));
     $this->fileSystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue($this->dir));
     $this->assetRepo->expects($this->once())->method('createArbitrary')->with('requirejs/file.js', '')->will($this->returnValue($this->asset));
     $this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER));
     $this->dir->expects($this->never())->method('isExist');
     $data = 'requirejs config data';
     $this->config->expects($this->once())->method('getConfig')->will($this->returnValue($data));
     $this->dir->expects($this->once())->method('writeFile')->with('requirejs/file.js', $data);
     $this->assertSame($this->asset, $this->object->createRequireJsConfigAsset());
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:12,代碼來源:FileManagerTest.php

示例14: isProcessLocked

 /**
  * Check whether generation process has already locked
  *
  * @return bool
  * @throws FileSystemException
  */
 private function isProcessLocked()
 {
     if ($this->tmpDirectory->isExist($this->lockFilePath)) {
         $lockTime = (int) $this->tmpDirectory->readFile($this->lockFilePath);
         if (time() - $lockTime >= self::MAX_LOCK_TIME) {
             $this->tmpDirectory->delete($this->lockFilePath);
             return false;
         }
         return true;
     }
     return false;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:18,代碼來源:LockerProcess.php

示例15: testBeforeSave

 public function testBeforeSave()
 {
     $value = 'filename.jpg';
     $tmpMediaPath = 'tmp/image/' . $value;
     $this->imageBackend->setScope('store');
     $this->imageBackend->setScopeId(1);
     $this->imageBackend->setValue([['url' => 'http://magento2.com/pub/media/tmp/image/' . $value, 'file' => $value, 'size' => 234234]]);
     $this->imageConfig->expects($this->exactly(2))->method('getTmpMediaPath')->with($value)->willReturn($tmpMediaPath);
     $this->mediaDirectory->expects($this->once())->method('copyFile')->with($tmpMediaPath, 'image/store/1/' . $value)->willReturn(true);
     $this->mediaDirectory->expects($this->once())->method('delete')->with($tmpMediaPath);
     $this->imageBackend->beforeSave();
     $this->assertEquals('store/1/filename.jpg', $this->imageBackend->getValue());
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:13,代碼來源:ImageTest.php


注:本文中的Magento\Framework\Filesystem\Directory\WriteInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。