add utils
This commit is contained in:
parent
abd6d0056a
commit
d580af9691
6
docs/utils/cache.md
Normal file
6
docs/utils/cache.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Cache Manager
|
||||||
|
|
||||||
|
* Service: `App\Core\Cache\SymfonyCacheManager`
|
||||||
|
* Methods:
|
||||||
|
* `cleanRouting()`: clear the cache of routes
|
||||||
|
* `cleanAll(OutputInterface $output = null)`: clean and warmup all cache
|
1
docs/utils/doctrine.md
Normal file
1
docs/utils/doctrine.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Doctrine
|
21
docs/utils/file_attribute.md
Normal file
21
docs/utils/file_attribute.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# File attribute
|
||||||
|
|
||||||
|
`App\Core\File\FileAttribute::handleFile` transforms a file path to an instance of `Symfony\Component\HttpFoundation\File\File`. You can specify another class if needed.
|
||||||
|
If the path is `null` or if the file does not exist, it returns `null`.
|
||||||
|
|
||||||
|
```
|
||||||
|
use App\Core\File\FileAttribute;
|
||||||
|
use App\Foo\Bar;
|
||||||
|
|
||||||
|
$path = 'path/to/file';
|
||||||
|
$file = FileAttribute::handleFile($path); // returns an instance of File
|
||||||
|
|
||||||
|
$path = 'path/to/removed_file';
|
||||||
|
$file = FileAttribute::handleFile($path); // returns null
|
||||||
|
|
||||||
|
$path = null;
|
||||||
|
$file = FileAttribute::handleFile($path); // returns null
|
||||||
|
|
||||||
|
$path = 'path/to/file';
|
||||||
|
$file = FileAttribute::handleFile($path, Bar::class); // returns an instance of Bar
|
||||||
|
```
|
38
docs/utils/file_handler.md
Normal file
38
docs/utils/file_handler.md
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# File upload handler
|
||||||
|
|
||||||
|
`App\Core\Form\FileUploadHandler` is a service and helps you to upload a file. See example below.
|
||||||
|
|
||||||
|
```
|
||||||
|
use App\Core\Form\FileUploadHandler;
|
||||||
|
use App\Entity\Foo;
|
||||||
|
use App\Form\FooType;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
public function upload(Request $request, FileUploadHandler $fileUpload)
|
||||||
|
{
|
||||||
|
$entity = new Foo();
|
||||||
|
$form = $this->createForm(FooType::class, $foo);
|
||||||
|
|
||||||
|
if ($request->isMethod('POST')) {
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isValid()) {
|
||||||
|
$fileDirectory = 'uploads/';
|
||||||
|
$keepOriginalFilename = false;
|
||||||
|
|
||||||
|
$fileUpload->handleForm(
|
||||||
|
$form->get('image')->getData(), // Symfony\Component\HttpFoundation\File\UploadedFile or null
|
||||||
|
$fileDirectory,
|
||||||
|
// optional
|
||||||
|
function ($filename) use ($entity, $fileDirectory) {
|
||||||
|
$entity->setImage($fileDirectory.$filename);
|
||||||
|
},
|
||||||
|
// optional
|
||||||
|
$keepOriginalFilename
|
||||||
|
);
|
||||||
|
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
1
docs/utils/mail.md
Normal file
1
docs/utils/mail.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Mail
|
1
docs/utils/slug.md
Normal file
1
docs/utils/slug.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Slug
|
|
@ -32,6 +32,13 @@ nav:
|
||||||
- TinyMCE: utils/editors/tinymce.md
|
- TinyMCE: utils/editors/tinymce.md
|
||||||
- GrapesJS: utils/editors/grapesjs.md
|
- GrapesJS: utils/editors/grapesjs.md
|
||||||
- Editor.js: utils/editors/editorjs.md
|
- Editor.js: utils/editors/editorjs.md
|
||||||
|
- Utils:
|
||||||
|
- Cache Manager: utils/cache.md
|
||||||
|
- Doctrine: utils/doctrine.md
|
||||||
|
- File upload handler: utils/file_handler.md
|
||||||
|
- File attribute: utils/file_attribute.md
|
||||||
|
- Mail notifier: utils/mail.md
|
||||||
|
- Slug: utils/slug.md
|
||||||
- Users:
|
- Users:
|
||||||
- Users: users.md
|
- Users: users.md
|
||||||
- Tasks:
|
- Tasks:
|
||||||
|
|
Loading…
Reference in a new issue