src/Controller/BaseSite/Site/IndexController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller\BaseSite\Site;
  3. use App\Entity\LeadNumbers;
  4. use App\Form\BaseSite\Site\LeadSupportFormType;
  5. use App\Repository\BaseSite\Plan\FeatureRepository;
  6. use App\Repository\BaseSite\Plan\PlanRepository;
  7. use App\Repository\Website\Product\ProductRepository;
  8. use App\Repository\Website\Website\WebsiteRepository;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  11. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  12. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. class IndexController extends AbstractController
  16. {
  17.     #[Route(path'/'name'base_home'host'poooshe.com')]
  18.     public function index(Request $requestWebsiteRepository $shopRepositoryProductRepository $productRepositoryPlanRepository $planRepositoryFeatureRepository $featureRepository)
  19.     {
  20.         $themes = [];
  21.         $path getcwd() . '/themes';
  22.         $directories = [];
  23.         foreach (scandir($path) as $item) {
  24.             if ($item === '.' || $item === '..') {
  25.                 continue;
  26.             }
  27.             if (is_dir($path DIRECTORY_SEPARATOR $item)) {
  28.                 $directories[] = $item;
  29.             }
  30.         }
  31.         foreach ($directories as $directory) {
  32.             $themes[$directory] = [
  33.                 'data' => json_decode(file_get_contents($path '/' $directory '/data.json'
  34. //                    . DIRECTORY_SEPARATOR . $directory
  35.                 ), true),
  36.                 'screenshotDir' => 'themes/' $directory '/screenshot.png',
  37.             ];
  38.         }
  39.         $allFeatures array_map(function ($feature) {
  40.             return [
  41.                 'title'   => $feature->getName(),
  42.                 'icon'    => $feature->getIcon(),      // یا فیلد واقعی
  43.             ];
  44.         }, $featureRepository->findBy(['active' => 1]));
  45.         $groups = [];
  46.         $total count($allFeatures);
  47. // اول ۶ تای اول → دوتا ۳تایی
  48.         if ($total >= 3) {
  49.             $groups[] = array_slice($allFeatures03);
  50.         }
  51.         if ($total >= 6) {
  52.             $groups[] = array_slice($allFeatures33);
  53.         }
  54. // بعدش → ۸تایی ۸تایی
  55.         $offset 6;
  56.         while ($offset $total) {
  57.             $groups[] = array_slice($allFeatures$offset8);
  58.             $offset += 8;
  59.         }
  60.         return $this->render('base_site/site/v3/index.html.twig', [
  61.             'themes'   => $themes,
  62.             'featuresBoxed' => $groups,
  63.             'features' => $allFeatures,
  64.             'latestBlogs' => []
  65.         ]);
  66.     }
  67.     #[Route(path'/'name'redorectCloudfolder_IR'host'cloudfolder.ir')]
  68.     public function redorectCloudfolder_IR(Request $requestWebsiteRepository $shopRepositoryProductRepository $productRepository)
  69.     {
  70.         return $this->redirect('https://poooshe.com'308);
  71.     }
  72.     #[Route(path'/'name'redorectPoooshe_IR'host'poooshe.ir')]
  73.     public function redorectPoooshe_IR(Request $requestWebsiteRepository $shopRepositoryProductRepository $productRepository)
  74.     {
  75.         return $this->redirect('https://poooshe.com'308);
  76.     }
  77.     #[Route(path'/check'name'check')]
  78.     public function check(Request $requestWebsiteRepository $shopRepositoryProductRepository $productRepository)
  79.     {
  80.         return $this->render('check.html.twig', []);
  81.     }
  82.     #[Route(path'/beta'name'beta')]
  83.     public function beta(Request           $request,
  84.                          FeatureRepository $featureRepository,
  85.                          WebsiteRepository $shopRepositoryProductRepository $productRepository)
  86.     {
  87.         $themes = [];
  88.         $path getcwd() . '/themes';
  89.         $directories = [];
  90.         foreach (scandir($path) as $item) {
  91.             if ($item === '.' || $item === '..') {
  92.                 continue;
  93.             }
  94.             if (is_dir($path DIRECTORY_SEPARATOR $item)) {
  95.                 $directories[] = $item;
  96.             }
  97.         }
  98.         foreach ($directories as $directory) {
  99.             $themes[$directory] = [
  100.                 'data' => json_decode(file_get_contents($path '/' $directory '/data.json'
  101. //                    . DIRECTORY_SEPARATOR . $directory
  102.                 ), true),
  103.                 'screenshotDir' => 'themes/' $directory '/screenshot.png',
  104.             ];
  105.         }
  106.         $allFeatures array_map(function ($feature) {
  107.             return [
  108.                 'title' => $feature->getName(),
  109.                 'icon' => $feature->getIcon(),      // یا فیلد واقعی
  110.             ];
  111.         }, $featureRepository->findBy(['active' => 1]));
  112.         $groups = [];
  113.         $total count($allFeatures);
  114. // اول ۶ تای اول → دوتا ۳تایی
  115.         if ($total >= 3) {
  116.             $groups[] = array_slice($allFeatures03);
  117.         }
  118.         if ($total >= 6) {
  119.             $groups[] = array_slice($allFeatures33);
  120.         }
  121. // بعدش → ۸تایی ۸تایی
  122.         $offset 6;
  123.         while ($offset $total) {
  124.             $groups[] = array_slice($allFeatures$offset8);
  125.             $offset += 8;
  126.         }
  127.         return $this->render('base_site/site/v3/index.html.twig', [
  128.             'themes' => $themes,
  129.             'featuresBoxed' => $groups,
  130.             'features' => $allFeatures,
  131.             'latestBlogs' => []
  132.         ]);
  133.     }
  134. }