<?php
namespace CorporateTrainingBundle\Controller;
use AppBundle\Common\ArrayToolkit;
use AppBundle\Controller\BaseController;
use CorporateTrainingBundle\Biz\HomePage\Service\HomePageService;
use CorporateTrainingBundle\Biz\IndustryTemplate\Service\IndustryTemplateSyncRecordService;
class HomeDefaultController extends BaseController
{
public function indexAction()
{
$homePageComponents = $this->getHomePageService()->findComponentOrderBySeqAsc();
$config = $this->getHomePageService()->getHomePageComponentConfig();
$blocks = !empty($config['blocks']) ? $config['blocks'] : [];
$blockCodes = ArrayToolkit::column($blocks, 'code');
return $this->render(
$this->isMobileClient() ? 'default/index-mobile.html.twig' : 'default/index.html.twig',
[
'homePageComponents' => $homePageComponents,
'blockCodes' => $blockCodes,
'editing' => false,
'time' => time(),
'isShowIndustryTemp' => $this->getIndustryTemplateSyncRecordService()->canSyncTemplate(),
]
);
}
/**
* @return HomePageService
*/
protected function getHomePageService()
{
return $this->createService('HomePage:HomePageService');
}
/**
* @return IndustryTemplateSyncRecordService
*/
protected function getIndustryTemplateSyncRecordService()
{
return $this->getBiz()->service('CorporateTrainingBundle:IndustryTemplate:IndustryTemplateSyncRecordService');
}
}