Installation Add the bundle to your Laravel project via Composer:
composer require elao/cms-slot-bundle
Ensure it’s enabled in config/bundles.php (Symfony) or config/app.php (Laravel) under Elao\CmsSlotBundle\ElaoCmsSlotBundle.
Configuration Publish the default config:
php artisan vendor:publish --tag=elao-cms-slot-config
Update config/elao_cms_slot.php to match your TinyMCE, File Manager, and Image Manager plugin paths.
First Use Case Integrate the bundle into a TinyMCE editor instance:
tinymce.init({
selector: '#my-editor',
plugins: 'filemanager imagemanager',
filemanager_callback: (field_name, url, type, win) => {
// Handle file/image selection
},
imagemanager_callback: (field_name, url, type, win) => {
// Handle image selection
}
});
Ensure your backend routes handle the filemanager and imagemanager callbacks (e.g., via Symfony’s elao_cms_slot routes).
Editor Initialization
Use the bundle’s Symfony routes (elao_cms_slot_filemanager, elao_cms_slot_imagemanager) as callbacks in TinyMCE:
tinymce.init({
selector: '#editor',
plugins: 'filemanager imagemanager',
filemanager_url: '/filemanager', // Route from bundle
imagemanager_url: '/imagemanager' // Route from bundle
});
Backend Handling
Extend the bundle’s controllers (ElaoCmsSlotBundle:FileManager/ImageManager) to customize file/image handling:
// app/Http/Controllers/CustomFileManagerController.php
namespace App\Http\Controllers;
use Elao\CmsSlotBundle\Controller\FileManagerController;
class CustomFileManagerController extends FileManagerController {
protected function getAllowedMimeTypes() {
return ['image/jpeg', 'image/png', 'application/pdf'];
}
}
Update routes in routes/web.php:
use App\Http\Controllers\CustomFileManagerController;
Route::get('/custom-filemanager', [CustomFileManagerController::class, 'index']);
Asset Management
Override default asset paths (e.g., TinyMCE plugins) in elao_cms_slot.php:
'tinymce_plugin_path' => '/vendor/tinymce/tinymce/plugins',
'filemanager_plugin_path' => '/vendor/elao/filemanager',
Laravel-Specific Adaptations Use Laravel’s service container to bind custom services (e.g., storage adapters):
// config/app.php
'bindings' => [
Elao\CmsSlotBundle\Service\FileManager::class => App\Services\CustomFileManager::class,
];
Route Conflicts
The bundle’s default routes (/filemanager, /imagemanager) may clash with existing routes. Solution: Override routes entirely or use route prefixes:
Route::prefix('admin')->group(function () {
Route::get('/filemanager', [CustomController::class, 'index']);
});
Plugin Path Assumptions
The bundle assumes TinyMCE and manager plugins are in default paths. Solution: Always verify and update elao_cms_slot.php paths.
CSRF Token Mismatch Symfony’s CSRF protection may block AJAX requests from TinyMCE. Solution: Exclude routes or use meta tags:
<meta name="csrf-token" content="{{ csrf_token() }}">
In JavaScript:
headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content }
Archived Package Risks The package is archived (no active maintenance). Solution:
Check Console Logs
TinyMCE errors often appear in browser console. Enable debug mode in elao_cms_slot.php:
'debug' => env('APP_DEBUG', false),
Verify Plugin Loading Ensure TinyMCE plugins are loaded before initialization:
tinymce.init({
// ...
setup: function(editor) {
console.log('Plugins loaded:', editor.plugins);
}
});
Storage Permissions File uploads may fail due to storage permissions. Solution:
chmod -R 775 storage/app/public
Custom File/Image Handlers
Extend Elao\CmsSlotBundle\Service\FileManager or ImageManager to add logic:
public function handleUpload($file, $path) {
// Custom logic (e.g., rename, resize)
return parent::handleUpload($file, $path);
}
Dynamic Plugin Configuration Use Laravel’s view composers to inject dynamic TinyMCE settings:
View::composer('*', function ($view) {
$view->with('tinymceSettings', [
'filemanager_title' => 'Custom File Manager',
'imagemanager_title' => 'Custom Image Manager'
]);
});
Event Listeners Listen for bundle events (if documented) or create custom events:
Event::listen('elao.cms_slot.file.uploaded', function ($event) {
// Post-upload logic
});
How can I help you explore Laravel packages today?