src/Controller/Render/PanelNavbarController.php line 302

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Render;
  3. use App\Entity\Generic\User;
  4. use App\Entity\Server\Hetzner\DataCenter;
  5. use App\Entity\Server\Hetzner\Image;
  6. use App\Entity\Server\Hetzner\Server;
  7. use App\Entity\Server\Hetzner\ServerType;
  8. use App\Entity\Telegram\AgentPublicBot\Bot;
  9. use App\Repository\Generic\UserRepository;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Security\Core\Security;
  14. class PanelNavbarController extends AbstractController
  15. {
  16.     public Security $security;
  17.     public User $user;
  18.     public array $userNavs;
  19.     public array $adminMegaNavs;
  20.     public EntityManagerInterface $entityManager;
  21.     public $currentRoute;
  22.     public function __construct(Security $securityUserRepository $userRepository EntityManagerInterface $entityManager)
  23.     {
  24.         $this->entityManager $entityManager;
  25.         /**
  26.          * @var User $user
  27.          */
  28.         $user $security->getUser();
  29.         $this->user $user;
  30.         $this->userNavs = [
  31.             [
  32.                 'isMega' => false,
  33.                 'path' => 'app_user_dashboard',
  34.                 'label' => 'داشبورد کاربری',
  35.                 'icon' => 'custom-status-up',
  36.                 'subRoutes' => [
  37.                 ]
  38.             ],
  39.             [
  40.                 'isMega' => true,
  41.                 'path' => 'app_panel_user_vpn_service_index',
  42.                 'label' => 'سرویس VPN',
  43.                 'icon' => 'custom-lock-outline',
  44.                 'megaRoutes' => [
  45.                     [
  46.                         'label' => 'خرید سرویس',
  47.                         'path' => 'app_panel_user_vpn_service_new',
  48.                         'icon' => '',
  49.                     ],
  50.                     [
  51.                         'label' => 'لیست سرویس ها',
  52.                         'path' => 'app_panel_user_vpn_service_index',
  53.                         'icon' => '',
  54.                     ],
  55.                     [
  56.                         'label' => 'ربات تلگرام فروش',
  57.                         'path' => 'app_user_agent_bot_index',
  58.                         'icon' => '',
  59.                     ],
  60.                     [
  61.                         'label' => 'وبسایت فروش',
  62.                         'path' => 'app_panel_user_domains_index',
  63.                         'icon' => '',
  64.                     ],
  65.                 ],
  66.                 'subRoutes' => [
  67. //                Domain
  68.                     'app_panel_user_domains_index',
  69.                     'app_panel_user_domains_new',
  70.                     'app_panel_user_domains_edit',
  71.                     'app_panel_user_domains_informations',
  72.                     'app_panel_user_domains_archive',
  73.                     'app_panel_user_domains_delete',
  74.                     'app_panel_user_domains_charge',
  75.                     'app_config_panel_settings',
  76. //                Telegram Bot
  77.                     'app_user_agent_bot_index',
  78.                     'app_user_agent_bot_edit',
  79.                     'app_user_agent_bot_price',
  80.                     'app_user_agent_bot_archive',
  81.                     'app_user_agent_bot_delete',
  82.                 ]
  83.             ],
  84.             [
  85.                 'isMega' => false,
  86.                 'path' => 'app_user_wallet_summary',
  87.                 'label' => 'حسابداری',
  88.                 'icon' => 'custom-dollar-square',
  89.                 'subRoutes' => [
  90.                 ]
  91.             ],
  92.             [
  93.                 'isMega' => false,
  94.                 'path' => 'app_user_wallet_charge_new',
  95.                 'label' => 'شارژ کیف پول',
  96.                 'icon' => 'custom-dollar-square',
  97.                 'subRoutes' => [
  98.                 ]
  99.             ]
  100.         ];
  101.         $this->adminMegaNavs = [
  102.             [
  103.                 'isMega' => false,
  104.                 'path' => 'app_admin_dashboard',
  105.                 'icon' => '',
  106.                 'label' => 'داشبورد مدیریت',
  107.                 'subRoutes' => [
  108.                 ],
  109.             ],
  110.             [
  111.                 'isMega' => false,
  112.                 'path' => 'app_panel_admin_domains_index',
  113.                 'icon' => '',
  114.                 'label' => 'دامنه های شخصی',
  115.                 'subRoutes' => [
  116. //                    'app_panel_admin_campaign_index',
  117. //                    'app_panel_admin_campaign_new',
  118.                 ]
  119.             ],
  120.             [
  121.                 'isMega' => false,
  122.                 'path' => 'app_panel_admin_campaign_index',
  123.                 'icon' => '',
  124.                 'label' => 'کمپین تبلیغاتی',
  125.                 'subRoutes' => [
  126.                 ],
  127.             ],
  128.             [
  129.                 'isMega' => true,
  130.                 'path' => '',
  131.                 'icon' => '',
  132.                 'label' => 'تحلیل سیستم',
  133.                 'megaRoutes' => [
  134.                     [
  135.                         'label' => 'تحلیل ورودی',
  136.                         'path' => 'app_admin_analytics_income',
  137.                         'icon' => '',
  138.                     ],
  139.                     [
  140.                         'label' => 'ثبت هزینه',
  141.                         'path' => 'app_panel_admin_cost_index',
  142.                         'icon' => '',
  143.                     ],
  144.                     [
  145.                         'label' => 'تحلیل هزینه',
  146.                         'path' => 'app_admin_analytics_cost',
  147.                         'icon' => '',
  148.                     ],
  149.                     [
  150.                         'label' => 'تحلیل مصرف سرور',
  151.                         'path' => 'app_admin_analytics_server_usage',
  152.                         'icon' => '',
  153.                     ],
  154.                     [
  155.                         'label' => 'تحلیل سالانه',
  156.                         'path' => 'app_admin_analytics_annual_income',
  157.                         'icon' => '',
  158.                     ],
  159.                 ],
  160.                 'subRoutes' => [
  161.                     'app_admin_analytics_income',
  162.                     'app_admin_analytics_cost',
  163.                     'app_admin_analytics_annual_income',
  164.                 ]
  165.             ],
  166.             [
  167.                 'isMega' => true,
  168.                 'path' => '',
  169.                 'icon' => '',
  170.                 'label' => 'کاربران',
  171.                 'megaRoutes' => [
  172.                     [
  173.                         'label' => 'ثبت نماینده',
  174.                         'path' => 'app_panel_admin_users_new',
  175.                         'icon' => '',
  176.                     ],
  177.                     [
  178.                         'label' => 'مدیریت کاربر ها',
  179.                         'path' => 'app_panel_admin_users_index',
  180.                         'icon' => '',
  181.                     ],
  182.                 ],
  183.                 'subRoutes' => [
  184.                     'app_panel_admin_users_index',
  185.                     'app_panel_admin_users_new',
  186.                     'app_panel_admin_users_edit',
  187.                     'app_panel_admin_users_archive',
  188.                     'app_panel_admin_users_delete',
  189.                     'app_panel_admin_users_analytics',
  190.                     'app_panel_admin_users_charge',
  191.                     'app_admin_telegram',
  192.                 ]
  193.             ],
  194.         ];
  195.         $this->adminMegaNavs[] = [
  196.             'isMega' => false,
  197.             'path' => 'app_admin_settings',
  198.             'icon' => '',
  199.             'label' => 'تنظیمات مدیریت',
  200.             'subRoutes' => [
  201.             ]
  202.         ];
  203.         $this->adminMegaNavs[] = [
  204.             'isMega' => true,
  205.             'path' => '',
  206.             'icon' => '',
  207.             'label' => 'VPN',
  208.             'megaRoutes' => [
  209.                 [
  210.                     'label' => 'سرویس ها',
  211.                     'path' => 'app_panel_admin_vpn_service_index',
  212.                     'icon' => '',
  213.                 ],
  214.                 [
  215.                     'label' => 'V2ray',
  216.                     'path' => 'app_panel_admin_vpn_v2ray_servers_index',
  217.                     'icon' => '',
  218.                 ],
  219.                 [
  220.                     'label' => 'OC',
  221.                     'path' => 'app_panel_admin_vpn_ocserv_servers_index',
  222.                     'icon' => '',
  223.                 ],
  224.                 [
  225.                     'label' => 'Open',
  226.                     'path' => 'app_panel_admin_vpn_openvpn_servers_index',
  227.                     'icon' => '',
  228.                 ],
  229.             ],
  230.             'subRoutes' => [
  231.                 'app_khan_vpn_panel_users',
  232.                 'app_khan_vpn_panel_wallet_summary',
  233.                 'app_khan_vpn_panel_analytics'
  234.             ]
  235.         ];
  236.         $this->adminMegaNavs[] = [
  237.             'isMega' => true,
  238.             'path' => '',
  239.             'icon' => '',
  240.             'label' => 'ServerSell',
  241.             'megaRoutes' => [
  242.                 [
  243.                     'label' => 'ایمیج ها',
  244.                     'path' => 'app_panel_admin_server_hetzner_image_index',
  245.                     'icon' => '',
  246.                 ],
  247.                 [
  248.                     'label' => 'نوع سرور ها',
  249.                     'path' => 'app_panel_admin_server_hetzner_server_type_index',
  250.                     'icon' => '',
  251.                 ],
  252.                 [
  253.                     'label' => 'دیتاسنتر ها',
  254.                     'path' => 'app_panel_admin_server_hetzner_data_center_index',
  255.                     'icon' => '',
  256.                 ],
  257.                 [
  258.                     'label' => 'خرید سرور',
  259.                     'path' => 'app_panel_user_server_location',
  260.                     'icon' => '',
  261.                 ],
  262.                 [
  263.                     'label' => 'لیست سرور',
  264.                     'path' => 'app_panel_user_server_hetzner_server_index',
  265.                     'icon' => '',
  266.                 ],
  267.             ],
  268.             'subRoutes' => [
  269.             ]
  270.         ];
  271.     }
  272.     public function renderDesktopSideBar($routeName): Response
  273.     {
  274.         return $this->render'panel/modules/generic/_sidebar.html.twig', [
  275.             'userNavs' => $this->userNavs,
  276.             'adminMegaNavs' => $this->adminMegaNavs,
  277.             'routeName' => $routeName
  278.         ]);
  279.     }
  280.     public function renderMobileSideBar($routeName): Response
  281.     {
  282.         return $this->render'panel/modules/generic/_sidebar_mobile.html.twig', [
  283.             'userNavs' => $this->userNavs,
  284.             'adminMegaNavs' => $this->adminMegaNavs,
  285.             'routeName' => $routeName
  286.         ]);
  287.     }
  288.     public function renderTelegramManagementNavbar($routeNameBot $bot null)
  289.     {
  290.         $routes = [
  291.             [
  292.                 'name' => $bot->getDescription(),
  293.                 'path' => 'app_telegram_agent_public_bot_management_general'
  294.             ],
  295.             [
  296.                 'name' => 'ویرایش ربات',
  297.                 'path' => 'app_telegram_agent_public_bot_management_edit'
  298.             ],
  299.             [
  300.                 'name' => 'قیف فروش',
  301.                 'path' => 'app_telegram_agent_public_bot_management_marketing'
  302.             ],
  303.             [
  304.                 'name' => 'تحلیل فروش',
  305.                 'path' => 'app_telegram_agent_public_bot_management_analytics'
  306.             ],
  307.             [
  308.                 'name' => 'قیمت گذاری بسته ها برای فروش',
  309.                 'path' => 'app_telegram_agent_public_bot_management_price'
  310.             ],
  311.             [
  312.                 'name' => 'کاربران ربات',
  313.                 'path' => 'app_telegram_agent_public_bot_management_users'
  314.             ],
  315.             [
  316.                 'name' => 'پیام همگانی',
  317.                 'path' => 'app_telegram_agent_public_bot_management_notification'
  318.             ],
  319.             [
  320.                 'name' => 'کمپین های ربات',
  321.                 'path' => 'app_telegram_agent_public_bot_management_campaigns',
  322.             ],
  323.             [
  324.                 'name' => 'سرویس های ربات',
  325.                 'path' => 'app_panel_user_vpn_service_index',
  326.             ],
  327.         ];
  328.         return $this->render'panel/modules/generic/_agent_telegram_management.html.twig', [
  329.             'routeName' => $routeName,
  330.             'bot' => $bot,
  331.             'routes' => $routes
  332.         ]);
  333.     }
  334.     public function renderHetznerFormBreadCrumb($route)
  335.     {
  336.         $datacenter null;
  337.         if ($route->get('datacenter') && $this->entityManager->getRepository(DataCenter::class)->find($route->get('datacenter'))){
  338.             $datacenter $this->entityManager->getRepository(DataCenter::class)->find($route->get('datacenter'));
  339.         }
  340.         if ($route->get('datacenter') && $this->entityManager->getRepository(\App\Entity\Server\ManageIt\DataCenter::class)->find($route->get('datacenter'))){
  341.             $datacenter $this->entityManager->getRepository(\App\Entity\Server\ManageIt\DataCenter::class)->find($route->get('datacenter'));
  342.         }
  343.         $image null;
  344.         if ($route->get('image') && $this->entityManager->getRepository(Image::class)->find($route->get('image'))){
  345.             $image $this->entityManager->getRepository(Image::class)->find($route->get('image'));
  346.         }
  347.         if ($route->get('image') && $this->entityManager->getRepository(\App\Entity\Server\ManageIt\Image::class)->find($route->get('image'))){
  348.             $image $this->entityManager->getRepository(\App\Entity\Server\ManageIt\Image::class)->find($route->get('image'));
  349.         }
  350.         $serverType null;
  351.         if ($route->get('serverType') && $this->entityManager->getRepository(ServerType::class)->find($route->get('serverType'))){
  352.             $serverType $this->entityManager->getRepository(ServerType::class)->find($route->get('serverType'));
  353.         }
  354.         if ($route->get('serverType') && $this->entityManager->getRepository(\App\Entity\Server\ManageIt\ServerType::class)->find($route->get('serverType'))){
  355.             $serverType $this->entityManager->getRepository(\App\Entity\Server\ManageIt\ServerType::class)->find($route->get('serverType'));
  356.         }
  357.         return $this->render('panel/modules/generic/_hetzner_bread_crumb.html.twig', [
  358.             'userNavs' => $this->userNavs,
  359.             'adminMegaNavs' => $this->adminMegaNavs,
  360.             'datacenter' => $datacenter,
  361.             'image' => $image,
  362.             'serverType' => $serverType,
  363.             'routeName' => $route->get('_route')
  364.         ]);
  365.     }
  366.     public function renderManageItFormBreadCrumb($route)
  367.     {
  368.         $datacenter null;
  369.         if ($route->get('datacenter') && $this->entityManager->getRepository(DataCenter::class)->find($route->get('datacenter'))){
  370.             $datacenter $this->entityManager->getRepository(DataCenter::class)->find($route->get('datacenter'));
  371.         }
  372.         if ($route->get('datacenter') && $this->entityManager->getRepository(\App\Entity\Server\ManageIt\DataCenter::class)->find($route->get('datacenter'))){
  373.             $datacenter $this->entityManager->getRepository(\App\Entity\Server\ManageIt\DataCenter::class)->find($route->get('datacenter'));
  374.         }
  375.         $image null;
  376.         if ($route->get('image') && $this->entityManager->getRepository(Image::class)->find($route->get('image'))){
  377.             $image $this->entityManager->getRepository(Image::class)->find($route->get('image'));
  378.         }
  379.         if ($route->get('image') && $this->entityManager->getRepository(\App\Entity\Server\ManageIt\Image::class)->find($route->get('image'))){
  380.             $image $this->entityManager->getRepository(\App\Entity\Server\ManageIt\Image::class)->find($route->get('image'));
  381.         }
  382.         $serverType null;
  383.         if ($route->get('serverType') && $this->entityManager->getRepository(ServerType::class)->find($route->get('serverType'))){
  384.             $serverType $this->entityManager->getRepository(ServerType::class)->find($route->get('serverType'));
  385.         }
  386.         if ($route->get('serverType') && $this->entityManager->getRepository(\App\Entity\Server\ManageIt\ServerType::class)->find($route->get('serverType'))){
  387.             $serverType $this->entityManager->getRepository(\App\Entity\Server\ManageIt\ServerType::class)->find($route->get('serverType'));
  388.         }
  389.         return $this->render('panel/modules/generic/_manageit_bread_crumb.html.twig', [
  390.             'userNavs' => $this->userNavs,
  391.             'adminMegaNavs' => $this->adminMegaNavs,
  392.             'datacenter' => $datacenter,
  393.             'image' => $image,
  394.             'serverType' => $serverType,
  395.             'routeName' => $route->get('_route')
  396.         ]);
  397.     }
  398.     public function renderListServerBreadCrumb($route)
  399.     {
  400.         return $this->render('panel/modules/generic/_list_server_bread_crumb.html.twig', [
  401.             'userNavs' => $this->userNavs,
  402.             'adminMegaNavs' => $this->adminMegaNavs,
  403.             'routeName' => $route->get('_route')
  404.         ]);
  405.     }
  406.     public function renderHetznerManageBreadCrumb($route Server $server)
  407.     {
  408.         return $this->render('panel/modules/generic/_hetzner_manage_bread_crumb.html.twig', [
  409.             'server' => $server,
  410.             'routeName' => $route->get('_route')
  411.         ]);
  412.     }
  413. }