public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $schoolID = $this->session->get('tsk_school_id');
     $orgID = $this->session->get('tsk_organization_id');
     $em = $this->entityManager;
     $sc = $this->securityContext;
     $erpContext = new \TSK\UserBundle\Form\Model\ErpContext();
     if ($orgID) {
         $organization = $em->getRepository('TSKUserBundle:Organization')->find($orgID);
         $erpContext->setOrganization($organization);
     }
     if ($schoolID) {
         $school = $em->getRepository('TSKSchoolBundle:School')->find($schoolID);
         $erpContext->setSchool($school);
     }
     $isSuperAdmin = false;
     foreach ($sc->getToken()->getRoles() as $role) {
         if ($role->getRole() == 'ROLE_SUPER_ADMIN') {
             $isSuperAdmin = true;
         }
     }
     if ($isSuperAdmin) {
         // Create form
         $form = $this->formFactory->create(new \TSK\UserBundle\Form\Type\AdminErpContextType($em, $sc), $erpContext);
     } else {
         // Determine if user has more than one school ...
         // Create form
         $form = $this->formFactory->create(new \TSK\UserBundle\Form\Type\UserErpContextType($em, $sc), $erpContext);
     }
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'form' => $form->createView(), 'isSuperAdmin' => $isSuperAdmin, 'settings' => $blockContext->getSettings()), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $user_current = $this->securityContext->getToken()->getUser();
     $user_id = $user_current->getId();
     // Tenues stats
     $tenues = $this->em->getRepository('IuchBundle:Tenue')->findAll();
     $nbr_tenues = 0;
     foreach ($tenues as $tenue) {
         $nbr_tenues += $tenue->getNombreDonne();
     }
     // Cles stats
     $cles = $this->em->getRepository('IuchBundle:Cle')->findAll();
     $nbr_cles = 0;
     foreach ($cles as $cle) {
         if ($cle->getRemis() == true) {
             $nbr_cles++;
         }
     }
     // Badges stats
     $badges = $this->em->getRepository('IuchBundle:Badge')->findAll();
     $nbr_badges = 0;
     foreach ($badges as $badge) {
         if ($badge->getRemis() == true) {
             $nbr_badges++;
         }
     }
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'base_template' => $this->pool->getTemplate('IuchBundle:Block:statuser.html.twig'), 'settings' => $blockContext->getSettings(), 'tenues' => $nbr_tenues, 'cles' => $nbr_cles, 'badges' => $nbr_badges), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $pages = $this->em->getAllSortBy('updatedAt');
     $draftPageCount = 0;
     $reviewPageCount = 0;
     $publishedPageCount = 0;
     $reviewPages = array();
     $draftPages = array();
     foreach ($pages as $page) {
         /** @var \Networking\InitCmsBundle\Model\PageInterface $page */
         if ($page->hasPublishedVersion()) {
             $publishedPageCount++;
         }
         if ($page->isReview()) {
             $reviewPageCount++;
             $draftPageCount++;
             $reviewPages[\Locale::getDisplayLanguage($page->getLocale())][] = $page;
         }
         if ($page->isDraft()) {
             $draftPageCount++;
             $draftPages[\Locale::getDisplayLanguage($page->getLocale())][] = $page;
         }
     }
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'draft_pages' => $draftPageCount, 'review_pages' => $reviewPageCount, 'published_pages' => $publishedPageCount, 'pages' => $pages, 'reviewPages' => $reviewPages, 'draftPages' => $draftPages), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // merge settings
     $settings = $blockContext->getSettings();
     $campaigns = $this->service->getOngoingCampaigns(array('limit' => $settings['limit']));
     return $this->renderResponse($blockContext->getTemplate(), array('campaigns' => $campaigns, 'block' => $blockContext->getBlock(), 'settings' => $settings), $response);
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $settings = $blockContext->getSettings();
     $repository = $this->em->getRepository('KinkinwebLhvbBundle:Gallery');
     $galleries = $repository->getLatest($settings['number']);
     return $this->renderResponse($blockContext->getTemplate(), array('galleries' => $galleries, 'block' => $blockContext->getBlock(), 'settings' => $settings), $response);
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $settings = array_merge($this->getDefaultSettings(), $blockContext->getBlock()->getSettings());
     $tours = $this->em->getRepository('AdminAdministrationBundle:Tour');
     $data = array('items' => $tours->findAll(), 'isSpecial' => $tours->findBy(array('isSpecial' => true)), 'isExpired' => $tours->findBy(array('isExpired' => true)));
     return $this->renderResponse('AdminAdministrationBundle:Block:tours.html.twig', array('block' => $blockContext->getBlock(), 'settings' => $settings, 'data' => $data), $response);
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // merge settings
     $settings = $blockContext->getSettings();
     $purchases = $this->purchaseManager->findLatestPurchases(10);
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $settings, 'latestPurchases' => $purchases), $response);
 }
 /**
  * Render the block
  *
  * @param BlockContextInterface $blockContext
  * @param Response $response
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // merge settings
     $settings = $blockContext->getSettings();
     $teachers = $this->entityManager->getRepository('AppBundle:Teacher')->findAll();
     return $this->renderResponse($blockContext->getTemplate(), array('teachers' => $teachers, 'block' => $blockContext->getBlock(), 'settings' => $settings), $response);
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $user = $this->securityContext->getToken()->getUser();
     if ($user->hasRole('ROLE_SUPER_ADMIN')) {
         $query = $this->entityManager->createQuery('SELECT p from TSK\\SchoolBundle\\Entity\\School p JOIN p.contact c WHERE c.organization=:org');
         $query->setParameter(':org', $this->session->get($this->orgSessionKey));
         $schools = $query->getResult();
     } else {
         $schools = $user->getContact()->getSchools()->toArray();
         // if (count($userSchools)) {
         //     foreach ($userSchools as $us) {
         //         $schools[] = $us->getId();
         //     }
         //     // Filter schools by org and according to your contact_schools list
         //     $query = $this->entityManager->createQuery('SELECT s from TSK\SchoolBundle\Entity\School s WHERE s.id IN (:schools)');
         //     $query->setParameter(':schools', join($schools));
         // }
     }
     $scs = array();
     if (count($schools)) {
         foreach ($schools as $school) {
             $scs[$school->getId()] = array('id' => $school->getId(), 'title' => $school->getContact()->getFirstName() . ' ' . $school->getContact()->getLastName(), 'selected' => $school->getId() == $this->session->get($this->schoolSessionKey) ? 'selected' : '');
         }
     }
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'schools' => $scs, 'settings' => $blockContext->getSettings()), $response);
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // merge settings
     $settings = $blockContext->getSettings();
     $hotCourses = \CourseManager::returnHotCourses();
     return $this->renderResponse($blockContext->getTemplate(), array('hot_courses' => $hotCourses, 'block' => $blockContext->getBlock(), 'settings' => $settings), $response);
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $qb = $this->em->createQueryBuilder()->select('t')->from('AldorPortfolioBundle:Technology', 't');
     $entities = $qb->getQuery()->getResult();
     $settings = $blockContext->getSettings();
     return $this->renderResponse($blockContext->getTemplate(), array('tags' => $entities, 'title' => $settings['title'], 'ribbon' => $settings['ribbon']), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // merge settings
     $settings = $blockContext->getSettings();
     $milestones = $this->service->getUpcomingMilestones(array('limit' => $settings['limit']));
     return $this->renderResponse($blockContext->getTemplate(), array('milestones' => $milestones, 'block' => $blockContext->getBlock(), 'settings' => $settings), $response);
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $comms = array();
     $settings = $blockContext->getSettings();
     $repository = $this->em->getRepository('KinkinwebLhvbBundle:Commission');
     $comms = $repository->findAll();
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $settings, 'commissions' => $comms), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // $settings = array_merge($this->getDefaultSettings(), $blockContext->getSettings());
     $myentityrepository = $this->em->getRepository('TNCYSchoolBundle:ExerciceResult');
     $query = $this->em->createQueryBuilder()->select('exerciceResult')->from('TNCYSchoolBundle:ExerciceResult', 'exerciceResult')->leftJoin('TNCYSchoolBundle:Homework', 'homework', 'WITH', 'exerciceResult.homework = homework')->where('exerciceResult.homework = :h')->setParameter('h', $blockContext->getSettings()['homeworkId'])->getQuery();
     $results = $query->getResult();
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), 'results' => $results), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $revisions = array();
     foreach ($this->auditReader->findRevisionHistory($blockContext->getSetting('limit'), 0) as $revision) {
         $revisions[] = array('revision' => $revision, 'entities' => $this->auditReader->findEntitesChangedAtRevision($revision->getRev()));
     }
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), 'revisions' => $revisions), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $tabs = $blockContext->getSetting('tabs');
     foreach ($tabs as $pos => $tab) {
         $tabs[$pos] = array_merge(array('title' => 'NR Metric', 'reference' => false), $tab);
     }
     return $this->renderResponse('EkinoNewRelicBundle:Block:tabs.html.twig', array('tabs' => $tabs, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'context' => $blockContext));
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // merge settings
     $settings = $blockContext->getSettings();
     $total_amount = $this->purchaseManager->findTotalAmountEarnedThisMonth();
     $totals = array("amount" => $total_amount['amount'] == null ? 0 : $total_amount['amount']);
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $settings, 'totals' => $totals, 'currency_symbol' => $this->configs['currency_symbol']), $response);
 }
Example #18
0
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $teams = array();
     $settings = $blockContext->getSettings();
     $repository = $this->em->getRepository('KinkinwebLhvbBundle:Team');
     $teams = $repository->listTeams($settings['age'], $settings['sex']);
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $settings, 'teams' => $teams), $response);
 }
 protected function assertSettings(array $expected, BlockContextInterface $blockContext)
 {
     $completeExpectedOptions = array_merge(array('use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => false, 'ttl' => 0), $expected);
     ksort($completeExpectedOptions);
     $blockSettings = $blockContext->getSettings();
     ksort($blockSettings);
     $this->assertSame($completeExpectedOptions, $blockSettings);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $user_current = $this->securityContext->getToken()->getUser();
     $info = $this->em->getRepository("ApplicationSonataUserBundle:Matching")->lastMatchingFromUser($user_current);
     // merge settings
     $settings = array_merge($this->getDefaultSettings(), $blockContext->getSettings());
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'base_template' => $this->pool->getTemplate('layout'), 'info' => $info, 'settings' => $blockContext->getSettings()), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $configManager = $this->analyticsService->getGClient()->getConfigManager();
     $client = $this->analyticsService->authenticate();
     $accessToken = json_decode($client->getAccessToken());
     $clientId = $configManager->getGoogleClientWebAppAPIClientId();
     $parameters = array('context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), 'clientId' => $clientId, 'access_token' => $accessToken->access_token);
     return $this->renderResponse($blockContext->getTemplate(), $parameters, $response);
 }
 /**
  * {@inheritdoc}
  */
 protected function getMenu(BlockContextInterface $blockContext)
 {
     $settings = $blockContext->getSettings();
     $menu = parent::getMenu($blockContext);
     if (null === $menu || "" === $menu) {
         $menu = $this->menuBuilder->createCategoryMenu(array('childrenAttributes' => array('class' => $settings['menu_class']), 'attributes' => array('class' => $settings['children_class'])), $settings['current_uri']);
     }
     return $menu;
 }
 /**
  * {@inheritdoc}
  */
 protected function getMenu(BlockContextInterface $blockContext)
 {
     $settings = $blockContext->getSettings();
     $menu = parent::getMenu($blockContext);
     if (null === $menu || '' === $menu) {
         $menu = $this->menuBuilder->createFiltersMenu($settings['product_provider'], array('childrenAttributes' => array('class' => $settings['menu_class'])), $settings['current_uri']);
     }
     return $menu;
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $settings = $blockContext->getSettings();
     if (!isset($settings['resume_name'])) {
         exit("Setting resume name muste be set (" . __FILE__ . " at " . __LINE__ . ")");
         // TODO use exception
     }
     $resume = $this->em->getRepository("AlexLSonataResumeBundle:Resume")->findOneByName($settings['resume_name']);
     return $this->renderResponse($blockContext->getTemplate(), array('block_context' => $blockContext, 'block' => $blockContext->getBlock(), 'resume' => $resume), $response);
 }
Example #25
0
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     // merge settings
     $settings = array_merge($this->getDefaultSettings(), $blockContext->getSettings());
     $curBlock = 'SuppliercheckAdminBundle:Block:block_importCSV.html.twig';
     if (!$this->container->get('security.context')->isGranted("ROLE_SUPER_ADMIN")) {
         $curBlock = 'SuppliercheckAdminBundle:Block:block_empty.html.twig';
     }
     return $this->renderResponse($curBlock, array('block' => $blockContext->getBlock(), 'allTypes' => CSVTypes::getTypesAndIds(), 'settings' => $settings), $response);
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $orgs = $this->entityManager->getRepository('TSK\\UserBundle\\Entity\\Organization')->findAll();
     if (count($orgs)) {
         foreach ($orgs as $org) {
             $organizations[$org->getId()] = array('id' => $org->getId(), 'title' => $org->getTitle(), 'selected' => $org->getId() == $this->session->get($this->sessionKey) ? 'selected' : '');
         }
     }
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'organizations' => $organizations, 'settings' => $blockContext->getSettings()), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $block = $blockContext->getBlock();
     if (!$block->getSetting('blockId') instanceof BlockInterface) {
         $this->load($block);
     }
     /** @var Block $sharedBlock */
     $sharedBlock = $block->getSetting('blockId');
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), 'sharedBlock' => $sharedBlock), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     if (!$response) {
         $response = new Response();
     }
     if ($blockContext->getBlock()->getEnabled()) {
         return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock()), $response);
     }
     return $response;
 }
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $settings = $blockContext->getSettings();
     if ($settings['category']) {
         $posts = $this->em->getRepository('AldorBlogBundle:Post')->getRecentPostsFromCategory($settings['category'], $settings['max']);
     } else {
         $posts = $this->em->getRepository('AldorBlogBundle:Post')->getRecentPosts($settings['max']);
     }
     return $this->renderResponse($blockContext->getTemplate(), array('posts' => $posts, 'title' => $settings['title'], 'category' => $settings['category']), $response);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $block = $blockContext->getBlock();
     // if the referenced target menu does not exist, we just skip the rendering
     if (!$block->getEnabled() || null === $block->getMenuNode()) {
         return $response ?: new Response();
     }
     $menuNode = $block->getMenuNode();
     return $this->renderResponse($blockContext->getTemplate(), array('menu' => $menuNode->getId(), 'block' => $blockContext->getBlock()), $response);
 }