本文整理汇总了PHP中Sonata\BlockBundle\Model\BlockInterface::setSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockInterface::setSetting方法的具体用法?PHP BlockInterface::setSetting怎么用?PHP BlockInterface::setSetting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\BlockBundle\Model\BlockInterface
的用法示例。
在下文中一共展示了BlockInterface::setSetting方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* {@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);
}
示例2: preUpdate
/**
* {@inheritdoc}
*/
public function preUpdate(BlockInterface $block)
{
$block->setSetting('galleryId', is_object($block->getSetting('galleryId')) ? $block->getSetting('galleryId')->getId() : null);
}
示例3: load
/**
* {@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')));
}
}
示例4: load
/**
* {@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);
}
示例5: resolveIds
/**
* @param BlockInterface $block
*/
private function resolveIds(BlockInterface $block)
{
$block->setSetting('collectionId', is_object($block->getSetting('collectionId')) ? $block->getSetting('collectionId')->getId() : null);
}
示例6: load
/**
* {@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);
}
示例7: load
/**
* {@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);
}
示例8: load
/**
* {@inheritdoc}
*/
public function load(BlockInterface $block)
{
$currentLoggedUser = $this->manager->fetchCurrentLoggedUser('login');
$block->setSetting('currentLoggedUser', $currentLoggedUser);
}
示例9: load
/**
* {@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);
}