Skip to content

Commit

Permalink
Merge branch 'feature/delete_files'
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsiegrist committed May 16, 2024
2 parents 646d75c + 597b87a commit 824c3d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/app_assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'assetsDir' => 'resources' . DS . 'assets' . DS,
'displayField' => 'title',
'Behaviors' => [],
'deleteFile' => false,
],
'ImageAsset' => [
// driver can be 'imagick' or 'gd'
Expand Down
11 changes: 10 additions & 1 deletion src/Model/Table/AssetsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Assets\Model\Table;

use ArrayObject;
use Cake\Core\Configure;
use Cake\Datasource\EntityInterface;
use Cake\Event\EventInterface;
Expand All @@ -11,6 +12,7 @@
use Cake\ORM\Table;
use Cake\Validation\Validator;
use Laminas\Diactoros\UploadedFile;
use Nette\Utils\FileSystem;

/**
* Assets Model
Expand Down Expand Up @@ -124,11 +126,18 @@ public function validationDefault(Validator $validator): Validator
* @param \ArrayObject $options Options passed to the event
* @return \Cake\ORM\Query
*/
public function beforeFind(EventInterface $e, Query $query, \ArrayObject $options)
public function beforeFind(EventInterface $e, Query $query, ArrayObject $options)
{
return $query->orderDesc('modified');
}

public function afterDelete(EventInterface $e, EntityInterface $entity, ArrayObject $options)

Check failure on line 134 in src/Model/Table/AssetsTable.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

Method Assets\Model\Table\AssetsTable::afterDelete() has no return type specified.
{
if (Configure::read('AssetsPlugin.AssetsTable.deleteFile') === true) {
FileSystem::delete(ROOT . DS . $entity->directory . $entity->filename);

Check failure on line 137 in src/Model/Table/AssetsTable.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

Access to an undefined property Cake\Datasource\EntityInterface::$directory.

Check failure on line 137 in src/Model/Table/AssetsTable.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

Access to an undefined property Cake\Datasource\EntityInterface::$filename.
}
}

/**
* @return string
*/
Expand Down

0 comments on commit 824c3d1

Please sign in to comment.