mirror of
https://github.com/flextype/flextype.git
synced 2025-08-10 07:06:45 +02:00
feat(media): remove media functionality for now, possible we should use imagekit instead
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (https://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
emitter()->addListener('onEntriesMove', static function (): void {
|
||||
|
||||
if (! entries()->registry()->get('collection.options.actions.copy.enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id = entries()->registry()->get('copy.id');
|
||||
$newID = entries()->registry()->get('copy.newID');
|
||||
|
||||
$mediaResourceDirectoryCurrentLocation = PATH['project'] . registry()->get('flextype.settings.media.upload.directory') . '/' . $id;
|
||||
$mediaResourceDirectoryNewLocation = PATH['project'] . registry()->get('flextype.settings.media.upload.directory') . '/' . $newID;
|
||||
|
||||
if (filesystem()->directory($mediaResourceDirectoryCurrentLocation)->exists()) {
|
||||
filesystem()->directory($mediaResourceDirectoryCurrentLocation)->copy($mediaResourceDirectoryNewLocation);
|
||||
}
|
||||
});
|
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (https://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
emitter()->addListener('onEntriesCreate', static function (): void {
|
||||
|
||||
if (! entries()->registry()->get('collection.options.actions.create.enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id = entries()->registry()->get('create.id');
|
||||
$data = entries()->registry()->get('create.data');
|
||||
|
||||
$data['resource'] = $data['resource'] ?? '';
|
||||
|
||||
if (is_array($data['resource'])) {
|
||||
|
||||
$media = upload($data['resource'], $id);
|
||||
|
||||
if ($media->name) {
|
||||
|
||||
$uploadDirectory = strings(PATH['project'] . '/' . registry()->get('flextype.settings.upload.directory') . '/' . $id)->reduceSlashes()->toString();
|
||||
$mediaFile = $uploadDirectory . '/media.' . filesystem()->file($media->name)->extension();
|
||||
filesystem()->file($uploadDirectory . '/' . $media->name)->move($mediaFile);
|
||||
|
||||
$data['resource'] = strings($id . '/media.' . filesystem()->file($media->name)->extension())->reduceSlashes()->toString();
|
||||
} else {
|
||||
$data['resource'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
entries()->registry()->set('create.data', array_merge(entries()->registry()->get('create.data'), $data));
|
||||
});
|
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (https://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
emitter()->addListener('onEntriesMove', static function (): void {
|
||||
|
||||
if (! entries()->registry()->get('collection.options.actions.delete.enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id = entries()->registry()->get('move.id');
|
||||
|
||||
$mediaResourceDirectoryCurrentLocation = PATH['project'] . registry()->get('flextype.settings.media.upload.directory') . '/' . $id;
|
||||
|
||||
if (filesystem()->directory($mediaResourceDirectoryCurrentLocation)->exists()) {
|
||||
filesystem()->directory($mediaResourceDirectoryCurrentLocation)->delete();
|
||||
}
|
||||
});
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (https://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
emitter()->addListener('onEntriesMove', static function (): void {
|
||||
|
||||
if (! entries()->registry()->get('collection.options.actions.move.enabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id = entries()->registry()->get('move.id');
|
||||
$newID = entries()->registry()->get('move.newID');
|
||||
|
||||
$mediaResourceDirectoryCurrentLocation = PATH['project'] . registry()->get('flextype.settings.media.upload.directory') . '/' . $id;
|
||||
$mediaResourceDirectoryNewLocation = PATH['project'] . registry()->get('flextype.settings.media.upload.directory') . '/' . $newID;
|
||||
|
||||
if (filesystem()->directory($mediaResourceDirectoryCurrentLocation)->exists()) {
|
||||
filesystem()->directory($mediaResourceDirectoryCurrentLocation)->move($mediaResourceDirectoryNewLocation);
|
||||
}
|
||||
});
|
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (https://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
namespace Flextype\Parsers\Shortcodes;
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
use function arrays;
|
||||
use function flextype;
|
||||
use function parsers;
|
||||
use function registry;
|
||||
|
||||
// Shortcode: [media_files_fetch id="media-id" field="field-name" default="default-value"]
|
||||
parsers()->shortcodes()->addHandler('media_files_fetch', static function (ShortcodeInterface $s) {
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.media.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return arrays(flextype('media')->files()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
|
||||
});
|
@@ -168,61 +168,6 @@ entries:
|
||||
state:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Tokens/Items/StateField.php"
|
||||
media:
|
||||
pattern: media
|
||||
filename: media
|
||||
extension: yaml
|
||||
serializer: yaml
|
||||
fields:
|
||||
modified_at:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/ModifiedAtField.php"
|
||||
created_at:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/CreatedAtField.php"
|
||||
created_by:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/CreatedByField.php"
|
||||
uuid:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/UuidField.php"
|
||||
id:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/IdField.php"
|
||||
media_item:
|
||||
pattern: media/(.*)
|
||||
filename: media
|
||||
extension: yaml
|
||||
serializer: yaml
|
||||
actions:
|
||||
create:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Actions/Media/CreateAction.php"
|
||||
move:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Actions/Media/MoveAction.php"
|
||||
copy:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Actions/Media/CopyAction.php"
|
||||
delete:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Actions/Media/DeleteAction.php"
|
||||
fields:
|
||||
modified_at:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/ModifiedAtField.php"
|
||||
created_at:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/CreatedAtField.php"
|
||||
created_by:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/CreatedByField.php"
|
||||
uuid:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/UuidField.php"
|
||||
id:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Entries/Fields/Default/IdField.php"
|
||||
|
||||
|
||||
# Cache
|
||||
@@ -494,7 +439,7 @@ serializers:
|
||||
native: true
|
||||
flags: 0
|
||||
encode:
|
||||
inline: 5
|
||||
inline: 10
|
||||
indent: 2
|
||||
flags: 0
|
||||
frontmatter:
|
||||
@@ -568,9 +513,6 @@ parsers:
|
||||
shortcodes:
|
||||
cache: true
|
||||
shortcodes:
|
||||
media:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Parsers/Shortcodes/MediaShortcode.php"
|
||||
entries:
|
||||
enabled: true
|
||||
path: "/src/flextype/core/Parsers/Shortcodes/EntriesShortcode.php"
|
||||
|
Reference in New Issue
Block a user