overwrite base class
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- VirtualSpy
- Advanced
- Posts: 122
- Joined: 05 Jul 2022, 07:55
overwrite base class
laravel version 9.36.4 , Aimeos version 2022.10.3 and PHP version 8.1.3 (Win)
can i overwrite this file from extension without this
because i want to remove 404 and variables from sprintf and pass my message in it from this
can i overwrite
Code: Select all
vendor\aimeos\aimeos-core\src\MShop\Common\Manager\Base.php
Code: Select all
Warning: Ambiguous class resolution, "Aimeos\MShop\Common\Manager\Base" was found 2x: in "D:/laragon/www/myshop/vendor/aimeos-extensions/extcliqnshop/src/MShop/Common/Manager/Base.php" and "D:\laragon\www\myshop\vendor/aimeos/aimeos-core/src\MShop\Common\Manager\Base.php", the first will be used.
Code: Select all
*/
protected function getItemBase( string $key, string $id, array $ref, ?bool $default ) : \Aimeos\MShop\Common\Item\Iface
{
$criteria = $this->object()->filter( $default )->add( [$key => $id] )->slice( 0, 1 );
if( ( $item = $this->object()->search( $criteria, $ref )->first() ) ) {
return $item;
}
$msg = $this->context()->translate( 'mshop', 'Item with ID "%2$s" in "%1$s" not found' );
throw new \Aimeos\MShop\Exception( sprintf( $msg, $key, $id ), 404 );
}
Last edited by VirtualSpy on 13 Dec 2022, 10:09, edited 1 time in total.
Re: overwrite base calss
In PHP it's not possible to overwrite base classes but you can overwrite the translation and use another message string:
https://aimeos.org/docs/latest/laravel/ ... anslations
https://aimeos.org/docs/latest/laravel/ ... anslations
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
- VirtualSpy
- Advanced
- Posts: 122
- Joined: 05 Jul 2022, 07:55
Re: overwrite base calss
but i want to change or remove 404 code from Exception.....please tell me how can i changeaimeos wrote: ↑13 Dec 2022, 09:48 In PHP it's not possible to overwrite base classes but you can overwrite the translation and use another message string:
https://aimeos.org/docs/latest/laravel/ ... anslations
Re: overwrite base class
You can replace the Exception decorator for the HTML client with your own implementation and handle 404 error code differently:
https://github.com/aimeos/ai-client-htm ... ptions.php
https://github.com/aimeos/ai-client-htm ... ptions.php
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