/**
  * {@inheritdoc}
  */
 public function load(BlockInterface $block)
 {
     $userManager = $this->container->get('fos_user.user_manager');
     $settings = $block->getSettings();
     $userRegistrations = $userManager->fetchRegistrationCount(isset($settings['fetchCountRecord']) ? $settings['fetchCountRecord'] : 5);
     $block->setSetting('userRegistrations', $userRegistrations);
 }
 /**
  * {@inheritdoc}
  */
 public function preUpdate(BlockInterface $block)
 {
     $block->setSetting('galleryId', is_object($block->getSetting('galleryId')) ? $block->getSetting('galleryId')->getId() : null);
 }
 /**
  * {@inheritdoc}
  */
 public function load(BlockInterface $block)
 {
     if (is_numeric($block->getSetting('pageId', null))) {
         $cmsManager = $this->cmsManagerSelector->retrieve();
         $site = $block->getPage()->getSite();
         $block->setSetting('pageId', $cmsManager->getPage($site, $block->getSetting('pageId')));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function load(BlockInterface $block)
 {
     $gender = $this->manager->fetchGenderCount();
     $genderChart = [];
     $genderList = [];
     foreach ($gender as $data) {
         switch ($data['gender']) {
             case 'u':
                 $genderList[] = ['gender' => $this->translator->trans('gender_unknown', [], 'SonataUserBundle'), 'total' => $data['total']];
                 $genderChart[$this->translator->trans('gender_unknown', [], 'SonataUserBundle')] = array($data['total']);
                 break;
             case 'm':
                 $genderList[] = ['gender' => $this->translator->trans('gender_male', [], 'SonataUserBundle'), 'total' => $data['total']];
                 $genderChart[$this->translator->trans('gender_male', [], 'SonataUserBundle')] = array($data['total']);
                 break;
             case 'f':
                 $genderList[] = ['gender' => $this->translator->trans('gender_female', [], 'SonataUserBundle'), 'total' => $data['total']];
                 $genderChart[$this->translator->trans('gender_female', [], 'SonataUserBundle')] = array($data['total']);
                 break;
         }
     }
     $totalGender = $this->manager->fetchGenderCountTotal();
     $block->setSetting('genderList', $genderList);
     $block->setSetting('genderChart', json_encode($genderChart));
     $block->setSetting('genderTotal', $totalGender);
 }
 /**
  * @param BlockInterface $block
  */
 private function resolveIds(BlockInterface $block)
 {
     $block->setSetting('collectionId', is_object($block->getSetting('collectionId')) ? $block->getSetting('collectionId')->getId() : null);
 }
 /**
  * {@inheritdoc}
  */
 public function load(BlockInterface $block)
 {
     foreach ($block->getTranslations() as $trans) {
         $sharedBlock = $trans->getSetting('blockId', null);
         if (is_int($sharedBlock)) {
             $sharedBlock = $this->blockManager->findOneBy(array('id' => $sharedBlock));
         }
         $trans->setSetting('blockId', $sharedBlock);
     }
     $sharedBlock = $block->getSetting('blockId', null);
     if (is_int($sharedBlock)) {
         $sharedBlock = $this->blockManager->findOneBy(array('id' => $sharedBlock));
     }
     $block->setSetting('blockId', $sharedBlock);
 }
 /**
  * {@inheritdoc}
  */
 public function load(BlockInterface $block)
 {
     $weekBefore = new \DateInterval('P6D');
     $beginDate = new \DateTime();
     $beginDate->sub($weekBefore);
     $beginDate->setTime(0, 0);
     $endDate = new \DateTime();
     $userLogsByDayGender = $this->manager->fetchUserLogsByDayCountGender($beginDate->format('Y-m-d'), 'login');
     $userLogsByDay = $this->manager->fetchUserLogsByDayCount($beginDate->format('Y-m-d'), 'login');
     $block->setSetting('startDate', $beginDate->format("Y-m-d"));
     $block->setSetting('endDate', $endDate->format("Y-m-d"));
     $interval = new \DateInterval('P1D');
     $daterange = new \DatePeriod($beginDate, $interval, $endDate);
     $dateIndex = [];
     foreach ($daterange as $date) {
         $dateIndex[] = $date->format("Y-m-d");
     }
     $userLogsWeekx = [];
     $userLogsWeekDataU = [];
     $userLogsWeekDataM = [];
     $userLogsWeekDataF = [];
     $userLogsWeekDataTotal = [];
     $userLogsWeekx[] = 'x';
     $userLogsWeekData[] = 'data';
     foreach ($dateIndex as $index => $date) {
         $idx = new \DateTime($date);
         $longIdx = new \DateTime($date);
         $userLogsWeekx[$index] = $idx->format("m-d");
         $userLogsWeekDataU[$index] = "0";
         $userLogsWeekDataM[$index] = "0";
         $userLogsWeekDataF[$index] = "0";
         $userLogsWeekDataTotal[$longIdx->format("F d, Y")]['total'] = "0";
         $userLogsWeekDataTotal[$longIdx->format("F d, Y")]['f'] = "0";
         $userLogsWeekDataTotal[$longIdx->format("F d, Y")]['m'] = "0";
         $userLogsWeekDataTotal[$longIdx->format("F d, Y")]['u'] = "0";
         foreach ($userLogsByDayGender as $key => $log) {
             if ($log['logDate'] === $date) {
                 if ($log['gender'] === 'f') {
                     $userLogsWeekDataTotal[$longIdx->format("F d, Y")]['f'] = $log['logDateCount'];
                     $userLogsWeekDataF[$index] = $log['logDateCount'];
                 } elseif ($log['gender'] === 'm') {
                     $userLogsWeekDataM[$index] = $log['logDateCount'];
                     $userLogsWeekDataTotal[$longIdx->format("F d, Y")]['m'] = $log['logDateCount'];
                 } else {
                     $userLogsWeekDataU[$index] = $log['logDateCount'];
                     $userLogsWeekDataTotal[$longIdx->format("F d, Y")]['u'] = $log['logDateCount'];
                 }
             }
         }
         foreach ($userLogsByDay as $key => $log) {
             if ($log['logDate'] === $date) {
                 $userLogsWeekDataTotal[$longIdx->format("F d, Y")]['total'] = $log['logDateCount'];
             }
         }
     }
     $userLogsWeek['x'] = $userLogsWeekx;
     $userLogsWeek['dataU'] = $userLogsWeekDataU;
     $userLogsWeek['dataM'] = $userLogsWeekDataM;
     $userLogsWeek['dataF'] = $userLogsWeekDataF;
     $block->setSetting('logsPerDay', json_encode($userLogsWeek));
     $block->setSetting('logsPerDayTotal', $userLogsWeekDataTotal);
 }
 /**
  * {@inheritdoc}
  */
 public function load(BlockInterface $block)
 {
     $currentLoggedUser = $this->manager->fetchCurrentLoggedUser('login');
     $block->setSetting('currentLoggedUser', $currentLoggedUser);
 }
 /**
  * {@inheritdoc}
  */
 public function load(BlockInterface $block)
 {
     $ageBrackets = $this->collectionManager->findByContext($this->context);
     $ageBracket = $this->manager->fetchAgeBracketCount();
     $dataAgeBracketList = [];
     $dataAgeBracketChart = [];
     $dataAgeBracketBar = [];
     //PieChart Data & List Data
     foreach ($ageBrackets as $idx => $bracket) {
         $dataAgeBracketChart[$bracket->getName()] = array(0);
         $dataAgeBracketList[$idx] = ['age' => $bracket->getName(), 'total' => 0];
         foreach ($ageBracket as $age) {
             if ($bracket->getName() == $age['name']) {
                 $dataAgeBracketChart[$bracket->getName()] = array($age['ageBracketCount']);
                 $dataAgeBracketList[$idx] = ['age' => $bracket->getName(), 'total' => $age['ageBracketCount']];
             }
         }
     }
     $ageByGender = $this->manager->fetchAgeBracketCountByGender();
     //LineGraph Data
     $ageX = [];
     $ageU = [];
     $ageF = [];
     $ageM = [];
     foreach ($ageBrackets as $idx => $bracket) {
         $ageX[$idx] = $bracket->getName();
         $ageU[$idx] = "0";
         $ageM[$idx] = "0";
         $ageF[$idx] = "0";
         foreach ($ageByGender as $age) {
             if ($bracket->getName() == $age['name']) {
                 switch ($age['gender']) {
                     case 'u':
                         $ageU[$idx] = $age['ageBracketCount'];
                         break;
                     case 'm':
                         $ageM[$idx] = $age['ageBracketCount'];
                         break;
                     case 'f':
                         $ageF[$idx] = $age['ageBracketCount'];
                         break;
                 }
             }
         }
     }
     $dataAgeBracketBar['x'] = $ageX;
     $dataAgeBracketBar['dataU'] = $ageU;
     $dataAgeBracketBar['dataM'] = $ageM;
     $dataAgeBracketBar['dataF'] = $ageF;
     $ageBracketTotal = $this->manager->fetchAgeBracketCountTotal();
     $block->setSetting('ageBracketList', $dataAgeBracketList);
     $block->setSetting('ageBracketBar', json_encode($dataAgeBracketBar));
     $block->setSetting('ageBracketChart', json_encode($dataAgeBracketChart));
     $block->setSetting('ageBracketTotal', $ageBracketTotal);
 }