本文整理汇总了PHP中Sonata\BlockBundle\Model\BlockInterface类的典型用法代码示例。如果您正苦于以下问题:PHP BlockInterface类的具体用法?PHP BlockInterface怎么用?PHP BlockInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlockInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
public function execute(BlockInterface $block, Response $response = null)
{
// merge settings
$settings = array_merge($this->getDefaultSettings(), $block->getSettings());
$media = $settings['mediaId'];
return $this->renderResponse('SonataMediaBundle:Block:block_feature_media.html.twig', array('media' => $media, 'block' => $block, 'settings' => $settings), $response);
}
示例2: buildEditForm
/**
* {@inheritdoc}
*/
public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
$contextChoices = $this->getContextChoices();
$formatChoices = $this->getFormatChoices($block->getSetting('mediaId'));
$translator = $this->container->get('translator');
$formMapper->add('settings', 'sonata_type_immutable_array', array('keys' => array(array('title', 'text', array('required' => false)), array('content', 'textarea', array('required' => false)), array('orientation', 'choice', array('choices' => array('left' => $translator->trans('feature_left_choice', array(), 'SonataMediaBundle'), 'right' => $translator->trans('feature_right_choice', array(), 'SonataMediaBundle')))), array('context', 'choice', array('required' => true, 'choices' => $contextChoices)), array('format', 'choice', array('required' => count($formatChoices) > 0, 'choices' => $formatChoices)), array($this->getMediaBuilder($formMapper), null, array()))));
}
示例3: render
/**
* {@inheritdoc}
*/
public function render(BlockInterface $block, Response $response = null)
{
if ($this->logger) {
$this->logger->info(sprintf('[cms::renderBlock] block.id=%d, block.type=%s ', $block->getId(), $block->getType()));
}
try {
$service = $this->blockServiceManager->get($block);
$service->load($block);
// load the block
$response = $service->execute($block, $response);
if (!$response instanceof Response) {
throw new \RuntimeException('A block service must return a Response object');
}
} catch (\Exception $e) {
if ($this->logger) {
$this->logger->crit(sprintf('[cms::renderBlock] block.id=%d - error while rendering block - %s', $block->getId(), $e->getMessage()));
}
if ($this->debug) {
throw $e;
}
$response = new Response();
$response->setPrivate();
}
return $response;
}
示例4: 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);
}
示例5: validateBlock
/**
* {@inheritdoc}
*/
public function validateBlock(ErrorElement $errorElement, BlockInterface $block)
{
if (($name = $block->getSetting('menu_name')) && $name !== '' && !$this->menuProvider->has($name)) {
// If we specified a menu_name, check that it exists
$errorElement->with('menu_name')->addViolation('sonata.block.menu.not_existing', array('name' => $name))->end();
}
}
示例6: addChildren
/**
* {@inheritdoc}
*/
public function addChildren(BlockInterface $child)
{
$this->children[] = $child;
$child->setParent($this);
if ($child instanceof DashboardBlockInterface) {
$child->setDashboard($this->getDashboard());
}
}
示例7: execute
/**
* {@inheritdoc}
*/
public function execute(BlockInterface $block, Response $response = null)
{
$settings = array_merge($this->getDefaultSettings(), $block->getSettings());
$revisions = array();
foreach ($this->auditReader->findRevisionHistory($settings['limit'], 0) as $revision) {
$revisions[] = array('revision' => $revision, 'entities' => $this->auditReader->findEntitesChangedAtRevision($revision->getRev()));
}
return $this->renderResponse('SonataDoctrineORMAdminBundle:Block:block_audit.html.twig', array('block' => $block, 'settings' => $settings, 'revisions' => $revisions), $response);
}
示例8: addChild
/**
* {@inheritdoc}
*/
public function addChild(BlockInterface $child, $key = null)
{
$child->setParent($this);
if ($key != null) {
$this->children->set($key, $child);
return true;
}
return $this->children->add($child);
}
示例9: execute
/**
* {@inheritdoc}
*/
public function execute(BlockInterface $block, Response $response = null)
{
$settings = array_merge($this->getDefaultSettings(), $block->getSettings());
$response = $this->renderResponse('IphpCoreBundle:Block:block_container.html.twig', array('container' => $block, 'settings' => $settings), $response);
//$response->setContent('Контент контейнера'
/*Mustache::replace($settings['layout'], array(
'CONTENT' => $response->getContent()
))*/
//);
return $response;
}
示例10: execute
/**
* {@inheritdoc}
*/
public function execute(BlockInterface $block, Response $response = null)
{
$settings = array_merge($this->getDefaultSettings(), $block->getSettings());
$dashboardGroups = $this->pool->getDashboardGroups();
$visibleGroups = array();
foreach ($dashboardGroups as $name => $dashboardGroup) {
if (!$settings['groups'] || in_array($name, $settings['groups'])) {
$visibleGroups[] = $dashboardGroup;
}
}
return $this->renderResponse($this->pool->getTemplate('list_block'), array('block' => $block, 'settings' => $settings, 'admin_pool' => $this->pool, 'groups' => $visibleGroups), $response);
}
示例11: execute
/**
* {@inheritdoc}
*/
public function execute(BlockInterface $block, Response $response = null)
{
$parameters = (array) json_decode($block->getSetting('parameters'), true);
$parameters = array_merge($parameters, array('_block' => $block));
$settings = array_merge($this->getDefaultSettings(), (array) $block->getSettings());
try {
$actionContent = $this->kernel->render($settings['action'], $parameters);
} catch (\Exception $e) {
throw $e;
}
$content = self::mustache($block->getSetting('layout'), array('CONTENT' => $actionContent));
return $this->renderResponse('SonataBlockBundle:Block:block_core_action.html.twig', array('content' => $content, 'block' => $block), $response);
}
示例12: buildEditForm
/**
* {@inheritdoc}
*/
public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
if (!$block->getSetting('mediaId') instanceof MediaInterface) {
$this->load($block);
}
$formatChoices = $this->getFormatChoices($block->getSetting('mediaId'));
$keys[] = array('title', 'text', array('required' => false));
$keys[] = array($this->getMediaBuilder($formMapper), null, array());
$keys[] = array('format', 'choice', array('required' => count($formatChoices) > 0, 'choices' => $formatChoices));
if ($this->getTemplates()) {
$keys[] = array('template', 'choice', array('choices' => $this->getTemplates()));
}
$formMapper->add('settings', 'sonata_type_immutable_array', array('keys' => $keys, 'attr' => array('class' => 'bruery-immutable-container')));
}
示例13: 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);
}
示例14: 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);
}
示例15: renderBlock
/**
* @param BlockInterface $block
* @param OutputInterface $output
* @param bool $extended
* @param int $space
*/
public function renderBlock(BlockInterface $block, OutputInterface $output, $extended, $space = 0)
{
$output->writeln(sprintf('%s <comment>> Id: %d - type: %s - name: %s</comment>', str_repeat(' ', $space), $block->getId(), $block->getType(), $block->getName()));
if ($extended) {
$output->writeln(sprintf('%s page class: <comment>%s</comment>', str_repeat(' ', $space + 1), get_class($block->getPage())));
foreach ($block->getSettings() as $name => $value) {
$output->writeln(sprintf('%s %s: %s', str_repeat(' ', $space + 1), $name, var_export($value, 1)));
}
}
foreach ($block->getChildren() as $block) {
$this->renderBlock($block, $output, $extended, $space + 1);
}
}