本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\Write::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Write::delete方法的具体用法?PHP Write::delete怎么用?PHP Write::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\Write
的用法示例。
在下文中一共展示了Write::delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleDisable
/**
* @param \Magento\Framework\Filesystem\Directory\Write $flagDir
* @param OutputInterface $output
* @param null $offOption
*/
protected function handleDisable(\Magento\Framework\Filesystem\Directory\Write $flagDir, OutputInterface $output, $offOption = null)
{
$flagDir->delete(MaintenanceMode::FLAG_FILENAME);
$output->writeln(self::DISABLED_MESSAGE);
if ($offOption === 'd') {
// Also delete IP flag file
$flagDir->delete(MaintenanceMode::IP_FILENAME);
$output->writeln(self::DELETED_IP_MESSAGE);
}
}
示例2: beforeDispatch
/**
* Clear temporary directories
*
* @param \Magento\Install\Controller\Index\Index $subject
* @param \Magento\Framework\App\RequestInterface $request
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeDispatch(\Magento\Install\Controller\Index\Index $subject, \Magento\Framework\App\RequestInterface $request)
{
if (!$this->appState->isInstalled()) {
foreach ($this->varDirectory->read() as $dir) {
if ($this->varDirectory->isDirectory($dir)) {
try {
$this->varDirectory->delete($dir);
} catch (FilesystemException $exception) {
$this->logger->log($exception->getMessage());
}
}
}
}
}
示例3: _deleteFilesRecursively
/**
* Delete all files in a directory recursively
*
* @param string $targetDir
* @return void
*/
protected function _deleteFilesRecursively($targetDir)
{
if ($this->_directory->isExist($targetDir)) {
foreach ($this->_directory->read($targetDir) as $path) {
$this->_directory->delete($path);
}
}
}
示例4: deleteDirectory
/**
* Delete directory
*
* @param string $path
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function deleteDirectory($path)
{
$rootCmp = rtrim($this->_helper->getStorageRoot(), '/');
$pathCmp = rtrim($path, '/');
if ($rootCmp == $pathCmp) {
throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t delete root directory %1 right now.', $path));
}
return $this->mediaWriteDirectory->delete($path);
}
示例5: deleteFile
/**
* Delete file (and its thumbnail if exists) from storage
*
* @param string $target File path to be deleted
* @return $this
*/
public function deleteFile($target)
{
$relativePath = $this->_directory->getRelativePath($target);
if ($this->_directory->isFile($relativePath)) {
$this->_directory->delete($relativePath);
}
$this->_coreFileStorageDb->deleteFile($target);
$thumb = $this->getThumbnailPath($target, true);
$relativePathThumb = $this->_directory->getRelativePath($thumb);
if ($thumb) {
if ($this->_directory->isFile($relativePathThumb)) {
$this->_directory->delete($relativePathThumb);
}
$this->_coreFileStorageDb->deleteFile($thumb);
}
return $this;
}
示例6: compactValue
/**
* Export attribute value to entity model
*
* @param array|string $value
* @return $this
*/
public function compactValue($value)
{
if ($this->getIsAjaxRequest()) {
return $this;
}
$attribute = $this->getAttribute();
$original = $this->getEntity()->getData($attribute->getAttributeCode());
$toDelete = false;
if ($original) {
if (!$attribute->getIsRequired() && !empty($value['delete'])) {
$toDelete = true;
}
if (!empty($value['tmp_name'])) {
$toDelete = true;
}
}
$destinationFolder = $attribute->getEntity()->getEntityTypeCode();
// unlink entity file
if ($toDelete) {
$this->getEntity()->setData($attribute->getAttributeCode(), '');
$file = $destinationFolder . $original;
if ($this->_directory->isExist($file)) {
$this->_directory->delete($file);
}
}
if (!empty($value['tmp_name'])) {
try {
$uploader = new \Magento\Framework\File\Uploader($value);
$uploader->setFilesDispersion(true);
$uploader->setFilenamesCaseSensitivity(false);
$uploader->setAllowRenameFiles(true);
$uploader->save($this->_directory->getAbsolutePath($destinationFolder), $value['name']);
$fileName = $uploader->getUploadedFileName();
$this->getEntity()->setData($attribute->getAttributeCode(), $fileName);
} catch (\Exception $e) {
$this->_logger->logException($e);
}
}
return $this;
}
示例7: tearDown
protected function tearDown()
{
$this->varDirectory->delete('generation');
unset($this->_generator);
}
示例8: tearDown
protected function tearDown()
{
$this->varDirectory->delete('generation');
set_include_path($this->_includePath);
unset($this->_generator);
}
示例9: tearDownAfterClass
public static function tearDownAfterClass()
{
self::$_varDirectory->delete(self::$_varDirectory->getRelativePath(self::$_tmpDir));
}