本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\WriteInterface::read方法的典型用法代码示例。如果您正苦于以下问题:PHP WriteInterface::read方法的具体用法?PHP WriteInterface::read怎么用?PHP WriteInterface::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\WriteInterface
的用法示例。
在下文中一共展示了WriteInterface::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _deleteExpiredImagesForWebsite
/**
* Delete Expired Captcha Images for specific website
*
* @param \Magento\Captcha\Helper\Data $helper
* @param \Magento\Store\Model\Website|null $website
* @param \Magento\Store\Model\Store|null $store
* @return void
*/
protected function _deleteExpiredImagesForWebsite(\Magento\Captcha\Helper\Data $helper, \Magento\Store\Model\Website $website = null, \Magento\Store\Model\Store $store = null)
{
$expire = time() - $helper->getConfig('timeout', $store) * 60;
$imageDirectory = $this->_mediaDirectory->getRelativePath($helper->getImgDir($website));
foreach ($this->_mediaDirectory->read($imageDirectory) as $filePath) {
if ($this->_mediaDirectory->isFile($filePath) && pathinfo($filePath, PATHINFO_EXTENSION) == 'png' && $this->_mediaDirectory->stat($filePath)['mtime'] < $expire) {
$this->_mediaDirectory->delete($filePath);
}
}
}
示例2:
/**
* Return content of backup file
*
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function &getFile()
{
if (!$this->exists()) {
throw new \Magento\Framework\Exception\LocalizedException(__('The backup file does not exist.'));
}
return $this->varDirectory->read($this->_getFilePath());
}