[SOLVED ✅ ]How can i redirect on Aimeos\Base\View\Iface?
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!
[SOLVED ✅ ]How can i redirect on Aimeos\Base\View\Iface?
I modified vendor/aimeos/ai-client-html/src/Client/Html/Checkout/Standard/Standard.php to force users to login before checkout, but I'm getting the error:
Aimeos\Client\Html\Checkout\Standard\Standard::data(): Return value must be of type Aimeos\Base\View\Iface, Illuminate\Http\RedirectResponse returned
Aimeos\Client\Html\Checkout\Standard\Standard::data(): Return value must be of type Aimeos\Base\View\Iface, Illuminate\Http\RedirectResponse returned
Code: Select all
public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface
{
$context = $this->context();
$basketCntl = \Aimeos\Controller\Frontend::create( $context, 'basket' );
$view->standardBasket = $basketCntl->get();
++if (!$context->user()){
++ return Redirect::to('login');
++}
......
Last edited by alababdiy on 01 Nov 2023, 08:49, edited 1 time in total.
Re: How can i redirect on Aimeos\Base\View\Iface?
You will burn in (developer) hell if you modify files from the ./vendor/ directory. This is strictly forbidden!
The correct solution is to implement a Laravel middleware which checks for the route including if the user is logged in and redirects the user to the login page if not:
https://laravel.com/docs/10.x/middleware#main-content
The correct solution is to implement a Laravel middleware which checks for the route including if the user is logged in and redirects the user to the login page if not:
https://laravel.com/docs/10.x/middleware#main-content
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
Re: How can i redirect on Aimeos\Base\View\Iface?
Thanks for reminding me about modifying files from the ./vendor/ directory.
I just modified the files for testing, and I will overwrite them again on extension.
I tried a regular Laravel redirect, but I'm still getting the same error:
code:
I just modified the files for testing, and I will overwrite them again on extension.
I tried a regular Laravel redirect, but I'm still getting the same error:
Code: Select all
[2023-10-31 09:31:15] local.ERROR: Aimeos\Client\Html\Checkout\Standard\Standard::data(): Return value must be of type Aimeos\Base\View\Iface, Illuminate\Http\RedirectResponse returned
Code: Select all
$context = $this->getContext();
if (!$context->user())
** return redirect('login');**