本文整理汇总了PHP中Gaufrette\Filesystem::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::delete方法的具体用法?PHP Filesystem::delete怎么用?PHP Filesystem::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gaufrette\Filesystem
的用法示例。
在下文中一共展示了Filesystem::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preUpload
/**
* Update attachment entity before upload
*
* @param File $entity
*/
public function preUpload(File $entity)
{
if ($entity->isEmptyFile()) {
if ($this->filesystem->has($entity->getFilename())) {
$this->filesystem->delete($entity->getFilename());
}
$entity->setFilename(null);
$entity->setExtension(null);
$entity->setOriginalFilename(null);
}
if ($entity->getFile() !== null && $entity->getFile()->isFile()) {
$entity->setOwner($this->securityFacadeLink->getService()->getLoggedUser());
$file = $entity->getFile();
if ($entity->getFilename() !== null && $this->filesystem->has($entity->getFilename())) {
$this->filesystem->delete($entity->getFilename());
}
$entity->setExtension($file->guessExtension());
if ($file instanceof UploadedFile) {
$entity->setOriginalFilename($file->getClientOriginalName());
$entity->setMimeType($file->getClientMimeType());
$entity->setFileSize($file->getClientSize());
} else {
$entity->setOriginalFilename($file->getFileName());
$entity->setMimeType($file->getMimeType());
$entity->setFileSize($file->getSize());
}
$entity->setFilename(uniqid() . '.' . $entity->getExtension());
if ($this->filesystem->getAdapter() instanceof MetadataSupporter) {
$this->filesystem->getAdapter()->setMetadata($entity->getFilename(), ['contentType' => $entity->getMimeType()]);
}
}
}
示例2: deleteFile
/**
* delete the given file
*
* @param string $file
*/
public function deleteFile($file)
{
if (!$this->filesystem->has($file)) {
return;
}
$this->filesystem->delete($file);
$this->cacheManager->remove($file);
}
示例3: clearCache
/**
* {@inheritDoc}
*/
public function clearCache($maxAge)
{
$delTime = time() - (int) $maxAge;
$num = 0;
foreach ($this->temporaryFilesystem->keys() as $key) {
if (!$this->temporaryFilesystem->getAdapter()->isDirectory($key)) {
if ($delTime > $this->temporaryFilesystem->mtime($key)) {
$this->temporaryFilesystem->delete($key);
$num++;
}
}
}
return $num;
}
示例4: shouldDeleteFile
/**
* @test
* @group functional
*/
public function shouldDeleteFile()
{
$this->filesystem->write('foo', 'Some content');
$this->assertTrue($this->filesystem->has('foo'));
$this->filesystem->delete('foo');
$this->assertFalse($this->filesystem->has('foo'));
}
示例5: shouldWorkWithHiddenFiles
/**
* @test
* @group functional
*/
public function shouldWorkWithHiddenFiles()
{
$this->filesystem->write('.foo', 'hidden');
$this->assertTrue($this->filesystem->has('.foo'));
$this->assertContains('.foo', $this->filesystem->keys());
$this->filesystem->delete('.foo');
$this->assertFalse($this->filesystem->has('.foo'));
}
示例6: shouldWrtieToSameFile
/**
* @test
* @group functional
*/
public function shouldWrtieToSameFile()
{
$FileObjectA = $this->filesystem->createFile('somefile');
$FileObjectA->setContent('ABC');
$FileObjectB = $this->filesystem->createFile('somefile');
$FileObjectB->setContent('DEF');
$this->assertEquals('DEF', $FileObjectB->getContent());
$this->filesystem->delete('somefile');
}
示例7: delete
/**
* Delete a file
* @param AbstractProductMedia $media
*/
protected function delete(AbstractProductMedia $media)
{
if ($media->getFilename() !== "" && $this->fileExists($media)) {
$this->filesystem->delete($media->getFilename());
}
$media->setOriginalFilename(null);
$media->setFilename(null);
$media->setFilepath(null);
$media->setMimeType(null);
}
示例8: cleanup
public function cleanup(UserProfile $prop)
{
if ($prop->getProperty()->getFieldType() === ProfileProperty::TYPE_FILE) {
/*$fileName = str_replace($this->getBaseFileUrl() . '/', '', $prop->getPropertyValue());
if ( is_file($this->getBaseFilePath() . '/' . $fileName) ) {
echo 'maybe removing ' . $this->getBaseFilePath() . '/' . $fileName;
@unlink($this->getBaseFilePath() . '/' . $fileName);
}*/
$fileKey = AbstractUploader::extractKey($prop->getPropertyValue(), $this->awsBucket);
if ($fileKey && $this->filesystem->has($fileKey)) {
$this->filesystem->delete($fileKey);
}
}
}
示例9: remove
/**
* Delete an image from the remote.
*
* @param Image $image
*
* @return $this
*/
public function remove(Image $image)
{
$this->filesystem->delete($image->getKey());
$this->untag($image->getKey());
return $this;
}
示例10: remove
/**
* {@inheritdoc}
*/
public function remove($path)
{
return $this->filesystem->delete($path);
}
示例11: deleteImage
/**
* Deletes an image.
*
* @param string $imagePath
*
* @return boolean
*/
public function deleteImage($imagePath)
{
return $this->files->delete($imagePath);
}
示例12: delete
public function delete($id)
{
$this->assertHasObject($id);
$this->filesystem->delete($id);
}
示例13: remove
/**
* {@inheritdoc}
*/
public function remove($path)
{
$path = $this->stripLeadingSlash($path);
if (!$this->getAdapter()->isDirectory($path)) {
parent::delete($path);
return;
}
$keys = $this->listKeys($path);
foreach ($keys['keys'] as $tmp) {
parent::delete($tmp);
}
// sort array according after directory depth (DESC)
$directories = array_unique($keys['dirs']);
usort($directories, function ($left, $right) {
$depthLeft = substr_count($left, '/');
$depthRight = substr_count($right, '/');
if ($depthLeft == $depthRight) {
return 0;
} else {
return $depthLeft > $depthRight ? -1 : +1;
}
});
foreach ($directories as $tmp) {
parent::delete($tmp);
}
if ($path != '' && $this->exists($path)) {
parent::delete($path);
}
}
示例14: remove
/**
* {@inheritdoc}
*/
public function remove($name)
{
return $this->filesystem->delete($name);
}
示例15:
function it_does_not_remove(Filesystem $filesystem)
{
$filesystem->delete('media-name')->shouldBeCalled()->willReturn(false);
$this->remove('media-name')->shouldReturn(false);
}