本文整理匯總了PHP中Magento\Framework\Filesystem\Directory\Write::isReadable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Write::isReadable方法的具體用法?PHP Write::isReadable怎麽用?PHP Write::isReadable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Filesystem\Directory\Write
的用法示例。
在下文中一共展示了Write::isReadable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: check
/**
* Check var/generation read and write access
*
* @return bool
*/
public function check()
{
$initParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM);
$filesystemDirPaths = isset($initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : [];
$directoryList = new DirectoryList(BP, $filesystemDirPaths);
$generationDirectoryPath = $directoryList->getPath(DirectoryList::GENERATION);
$driverPool = new DriverPool();
$fileWriteFactory = new WriteFactory($driverPool);
/** @var \Magento\Framework\Filesystem\DriverInterface $driver */
$driver = $driverPool->getDriver(DriverPool::FILE);
$directoryWrite = new Write($fileWriteFactory, $driver, $generationDirectoryPath);
if ($directoryWrite->isExist()) {
if ($directoryWrite->isDirectory() || $directoryWrite->isReadable()) {
try {
$probeFilePath = $generationDirectoryPath . DIRECTORY_SEPARATOR . uniqid(mt_rand()) . 'tmp';
$fileWriteFactory->create($probeFilePath, DriverPool::FILE, 'w');
$driver->deleteFile($probeFilePath);
} catch (\Exception $e) {
return false;
}
} else {
return false;
}
} else {
try {
$directoryWrite->create();
} catch (\Exception $e) {
return false;
}
}
return true;
}
示例2: loadPackagesForUpdateFromCache
/**
* Load composer packages available for update from cache
*
* @return bool|string
*/
private function loadPackagesForUpdateFromCache()
{
if ($this->directory->isExist($this->pathToCacheFile) && $this->directory->isReadable($this->pathToCacheFile)) {
try {
$data = $this->directory->readFile($this->pathToCacheFile);
return json_decode($data, true);
} catch (\Magento\Framework\Exception\FileSystemException $e) {
}
}
return false;
}
示例3: _createThumbnail
/**
* Create thumbnail for image and save it to thumbnails directory
*
* @param string $source
* @return bool|string Resized filepath or false if errors were occurred
*/
public function _createThumbnail($source)
{
if (self::TYPE_IMAGE != $this->_helper->getStorageType() || !$this->mediaWriteDirectory->isFile($source) || !$this->mediaWriteDirectory->isReadable($source)) {
return false;
}
$thumbnailDir = $this->_helper->getThumbnailDirectory($source);
$thumbnailPath = $thumbnailDir . '/' . pathinfo($source, PATHINFO_BASENAME);
try {
$this->mediaWriteDirectory->isExist($thumbnailDir);
$image = $this->_imageFactory->create();
$image->open($this->mediaWriteDirectory->getAbsolutePath($source));
$image->keepAspectRatio(true);
$image->resize(self::THUMBNAIL_WIDTH, self::THUMBNAIL_HEIGHT);
$image->save($this->mediaWriteDirectory->getAbsolutePath($thumbnailPath));
} catch (\Magento\Framework\Exception\FileSystemException $e) {
$this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
return false;
}
if ($this->mediaWriteDirectory->isFile($thumbnailPath)) {
return $thumbnailPath;
}
return false;
}