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

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