本文整理汇总了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;
}