How to override Aimeos\Controller\Common\Media add() function.
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
How to override Aimeos\Controller\Common\Media add() function.
Hi,
I'm on using Laravel 9, Aimeos 2022.x and PHP 8.1 on linux
I need to customize the behavior of the add() function in the Aimeos\Controller\Common\Media class using extension. However, I'm unsure about the correct approach to override this function.
Specifically, I want to extend the functionality of the add() method in order to perform blurhash of $file when adding a new media item.
I'm on using Laravel 9, Aimeos 2022.x and PHP 8.1 on linux
I need to customize the behavior of the add() function in the Aimeos\Controller\Common\Media class using extension. However, I'm unsure about the correct approach to override this function.
Specifically, I want to extend the functionality of the add() method in order to perform blurhash of $file when adding a new media item.
Re: How to override Aimeos\Controller\Common\Media add() function.
You can create your own common media controller class with a new name (e.g. "Mymedia") and extend from the "Standard" class:
Then, configure the new class to be used:
How to add configuration depends on the use framework. For Laravel it's in ./config/shop.php:
Code: Select all
<?php
namespace Aimeos\Controller\Common\Media;
class Mymedia extends Standard
{
public function add( \Aimeos\MShop\Media\Item\Iface $item, \Psr\Http\Message\UploadedFileInterface $file ) : \Aimeos\MShop\Media\Item\Iface
{
// own implementation
}
}
Code: Select all
controller/common/media/name = Mymedia
Code: Select all
'controller' => [
'common' => [
'media' => [
'name' => 'Mymedia'
]
]
]
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star