vendor/dvdw/platform-choice/src/Storefront/Controller/ProfileController.php line 42

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Dvdw\PlatformChoice\Storefront\Controller;
  3. use Dvdw\PlatformChoice\System\SalesChannel\Struct\DashboardDomainExtension;
  4. use Shopware\Core\Checkout\Customer\CustomerEntity;
  5. use Shopware\Core\Content\ProductExport\Exception\SalesChannelDomainNotFoundException;
  6. use Shopware\Core\Framework\Routing\Annotation\Since;
  7. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  8. use Shopware\Storefront\Controller\AccountProfileController;
  9. use Shopware\Storefront\Controller\StorefrontController;
  10. use Shopware\Storefront\Framework\Routing\Annotation\NoStore;
  11. use Symfony\Component\HttpFoundation\RedirectResponse;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. /**
  16.  * @Route(defaults={"_routeScope"={"storefront"}})
  17.  */
  18. class ProfileController extends StorefrontController
  19. {
  20.     private AccountProfileController $decorated;
  21.     public function __construct(
  22.         AccountProfileController $decorated
  23.     )
  24.     {
  25.         $this->decorated $decorated;
  26.     }
  27.     public function getDecorated(): AccountProfileController
  28.     {
  29.         return $this->decorated;
  30.     }
  31.     /**
  32.      * @Since("6.0.0.0")
  33.      * @Route("/account", name="frontend.account.home.page", methods={"GET"}, defaults={"_loginRequired"=true})
  34.      * @NoStore
  35.      */
  36.     public function index(Request $requestSalesChannelContext $contextCustomerEntity $customer): Response
  37.     {
  38.         return $this->profileOverview($request$context);
  39.     }
  40.     /**
  41.      * @Since("6.0.0.0")
  42.      * @Route("/account/profile", name="frontend.account.profile.page", methods={"GET"}, defaults={"_loginRequired"=true})
  43.      * @NoStore
  44.      */
  45.     public function profileOverview(Request $requestSalesChannelContext $context): Response
  46.     {
  47.         $url $this->getDashboardDomain($context);
  48.         return new RedirectResponse(rtrim($url'/') . '/account/profile');
  49.     }
  50.     private function getDashboardDomain(SalesChannelContext $context): string
  51.     {
  52.         /** @var DashboardDomainExtension|null $dashboardDomain */
  53.         $dashboardDomain $context->getExtension(DashboardDomainExtension::KEY);
  54.         if ($dashboardDomain === null) {
  55.             throw new SalesChannelDomainNotFoundException('Dashboard');
  56.         }
  57.         return $dashboardDomain->getDomain();
  58.     }
  59. }