Loading src/Jity/HomepageBundle/Controller/DefaultController.php +62 −4 Original line number Diff line number Diff line Loading @@ -107,6 +107,8 @@ class DefaultController extends Controller */ public function showPageAction($slug = '', $service = '', $renderService = true, Response $serviceReponse = null) { // Get Entity Manager $em = $this->getDoctrine()->getEntityManager(); Loading Loading @@ -135,16 +137,72 @@ class DefaultController extends Controller ('homepage' != $page->getService()->getName()) ) { $serviceReponse = $this->forward('JityHomepageBundle:Service:show', array( 'page' => $page )); $serviceReponse = $this->get('jity_service.handler') ->getController($page->getService()->getName()) ->process() ; } // Return the rendered result return $this->render('JityHomepageBundle:Default:index.html.twig', array( 'page' => $page, 'service' => (isset($serviceReponse)) ? $serviceReponse->getContent() : '' 'service' => (isset($serviceReponse)) ? $serviceReponse : '' )); // // Get Entity Manager // $em = $this->getDoctrine()->getEntityManager(); // // Try to get the requested Page // if (!empty($slug)) { // $page = $em->getRepository('JityHomepageBundle:Page')->findOneBySlug($slug); // } elseif (!empty($service)) { // $curService = $em->getRepository('JityHomepageBundle:Service')->findOneByName($service); // $page = $curService->getPages()->first(); // // We dont want to render a infinite loop here // $renderService = false; // } // // Page was not found // if (!$page) { // return $this->forward('JityHomepageBundle:Default:showInfo', array('template' => 'homepage_notfound')); // } // // On service relation jump into // if (($service = $page->getService()) && // (true === $renderService) && // ('homepage' != $page->getService()->getName()) // ) { // $serviceReponse = $this->forward('JityHomepageBundle:Service:show', array( // 'page' => $page // )); // } // // Return the rendered result // return $this->render('JityHomepageBundle:Default:index.html.twig', array( // 'page' => $page, // 'service' => (isset($serviceReponse)) ? $serviceReponse->getContent() : '' // )); } /** Loading src/Jity/HomepageBundle/Controller/SecurityController.php→src/Jity/HomepageBundle/Controller/SecurityController.php.old +0 −0 File moved. View file src/Jity/HomepageBundle/DependencyInjection/Compiler/ServiceCompilerPass.php 0 → 100644 +48 −0 Original line number Diff line number Diff line <?php namespace Jity\HomepageBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder, Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface, Symfony\Component\DependencyInjection\Reference; /** * ServiceCompilerPass * * @uses CompilerPassInterface * @version $id$ * @author Hermann Mayer <hermann.mayer92@gmail.com> */ class ServiceCompilerPass implements CompilerPassInterface { /** * process * * @param ContainerBuilder $container * @access public * @return void */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('jity_service.handler')) { return; } $definition = $container->getDefinition( 'jity_service.handler' ); $taggedServices = $container->findTaggedServiceIds( 'jity_service.controller' ); foreach ($taggedServices as $id => $attributes) { $definition->addMethodCall( 'addController', array(new Reference($id)) ); } } } src/Jity/HomepageBundle/DependencyInjection/Service/AbstractService.php 0 → 100644 +88 −0 Original line number Diff line number Diff line <?php namespace Jity\HomepageBundle\DependencyInjection\Service; use Symfony\Component\DependencyInjection\ContainerInterface, JMS\DiExtraBundle\Annotation as DI; /** * AbstractService * * @abstract * @version $id$ * @author Hermann Mayer <hermann.mayer92@gmail.com> */ abstract class AbstractService { /** * getName * * @abstract * @access public * @return void */ abstract public function getName(); /** * getDescription * * @abstract * @access public * @return void */ abstract public function getDescription(); /** * process * * @abstract * @access public * @return void */ abstract public function process(); /** * @var container * @access protected */ protected $container; /** * __construct * * @DI\InjectParams({ * "container" = @DI\Inject("service_container") * }) * * @access public * @return void */ public function __construct(ContainerInterface $container) { $this->container = $container; } /** * getSectionFromConfig * * @param mixed $section * @access public * @return void */ public function getSectionFromConfig($section = null) { if (null === $section) { $section = strtolower($this->getName()); } // Get bundle config from container $config = (object) $this->container->getParameter('jity_homepage'); if (isset($config->$section)) { return $config->$section; } return array(); } } src/Jity/HomepageBundle/DependencyInjection/Service/Controller/BlogController.php 0 → 100644 +56 −0 Original line number Diff line number Diff line <?php namespace Jity\HomepageBundle\DependencyInjection\Service\Controller; use Jity\HomepageBundle\DependencyInjection\Service\AbstractService, Symfony\Bundle\FrameworkBundle\Controller\Controller, JMS\DiExtraBundle\Annotation as DI; use Symfony\Component\HttpFoundation\Response; /** * BlogController * * @DI\Service("jity_service.controller.blog", scope="request") * @DI\Tag("jity_service.controller") * * @uses Controller * @version $id$ * @author Hermann Mayer <hermann.mayer92@gmail.com> */ class BlogController extends AbstractService { /** * getName * * @access public * @return void */ public function getName() { return 'blog'; } /** * getDescription * * @access public * @return void */ public function getDescription() { return 'Fügt die Startseite eines Blogs hinzu.'; } /** * process * * @access public * @return void */ public function process() { return $this->container->get('templating')->render('JityHomepageBundle:Service:Blog/news.html.twig', array()); } } Loading
src/Jity/HomepageBundle/Controller/DefaultController.php +62 −4 Original line number Diff line number Diff line Loading @@ -107,6 +107,8 @@ class DefaultController extends Controller */ public function showPageAction($slug = '', $service = '', $renderService = true, Response $serviceReponse = null) { // Get Entity Manager $em = $this->getDoctrine()->getEntityManager(); Loading Loading @@ -135,16 +137,72 @@ class DefaultController extends Controller ('homepage' != $page->getService()->getName()) ) { $serviceReponse = $this->forward('JityHomepageBundle:Service:show', array( 'page' => $page )); $serviceReponse = $this->get('jity_service.handler') ->getController($page->getService()->getName()) ->process() ; } // Return the rendered result return $this->render('JityHomepageBundle:Default:index.html.twig', array( 'page' => $page, 'service' => (isset($serviceReponse)) ? $serviceReponse->getContent() : '' 'service' => (isset($serviceReponse)) ? $serviceReponse : '' )); // // Get Entity Manager // $em = $this->getDoctrine()->getEntityManager(); // // Try to get the requested Page // if (!empty($slug)) { // $page = $em->getRepository('JityHomepageBundle:Page')->findOneBySlug($slug); // } elseif (!empty($service)) { // $curService = $em->getRepository('JityHomepageBundle:Service')->findOneByName($service); // $page = $curService->getPages()->first(); // // We dont want to render a infinite loop here // $renderService = false; // } // // Page was not found // if (!$page) { // return $this->forward('JityHomepageBundle:Default:showInfo', array('template' => 'homepage_notfound')); // } // // On service relation jump into // if (($service = $page->getService()) && // (true === $renderService) && // ('homepage' != $page->getService()->getName()) // ) { // $serviceReponse = $this->forward('JityHomepageBundle:Service:show', array( // 'page' => $page // )); // } // // Return the rendered result // return $this->render('JityHomepageBundle:Default:index.html.twig', array( // 'page' => $page, // 'service' => (isset($serviceReponse)) ? $serviceReponse->getContent() : '' // )); } /** Loading
src/Jity/HomepageBundle/Controller/SecurityController.php→src/Jity/HomepageBundle/Controller/SecurityController.php.old +0 −0 File moved. View file
src/Jity/HomepageBundle/DependencyInjection/Compiler/ServiceCompilerPass.php 0 → 100644 +48 −0 Original line number Diff line number Diff line <?php namespace Jity\HomepageBundle\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder, Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface, Symfony\Component\DependencyInjection\Reference; /** * ServiceCompilerPass * * @uses CompilerPassInterface * @version $id$ * @author Hermann Mayer <hermann.mayer92@gmail.com> */ class ServiceCompilerPass implements CompilerPassInterface { /** * process * * @param ContainerBuilder $container * @access public * @return void */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('jity_service.handler')) { return; } $definition = $container->getDefinition( 'jity_service.handler' ); $taggedServices = $container->findTaggedServiceIds( 'jity_service.controller' ); foreach ($taggedServices as $id => $attributes) { $definition->addMethodCall( 'addController', array(new Reference($id)) ); } } }
src/Jity/HomepageBundle/DependencyInjection/Service/AbstractService.php 0 → 100644 +88 −0 Original line number Diff line number Diff line <?php namespace Jity\HomepageBundle\DependencyInjection\Service; use Symfony\Component\DependencyInjection\ContainerInterface, JMS\DiExtraBundle\Annotation as DI; /** * AbstractService * * @abstract * @version $id$ * @author Hermann Mayer <hermann.mayer92@gmail.com> */ abstract class AbstractService { /** * getName * * @abstract * @access public * @return void */ abstract public function getName(); /** * getDescription * * @abstract * @access public * @return void */ abstract public function getDescription(); /** * process * * @abstract * @access public * @return void */ abstract public function process(); /** * @var container * @access protected */ protected $container; /** * __construct * * @DI\InjectParams({ * "container" = @DI\Inject("service_container") * }) * * @access public * @return void */ public function __construct(ContainerInterface $container) { $this->container = $container; } /** * getSectionFromConfig * * @param mixed $section * @access public * @return void */ public function getSectionFromConfig($section = null) { if (null === $section) { $section = strtolower($this->getName()); } // Get bundle config from container $config = (object) $this->container->getParameter('jity_homepage'); if (isset($config->$section)) { return $config->$section; } return array(); } }
src/Jity/HomepageBundle/DependencyInjection/Service/Controller/BlogController.php 0 → 100644 +56 −0 Original line number Diff line number Diff line <?php namespace Jity\HomepageBundle\DependencyInjection\Service\Controller; use Jity\HomepageBundle\DependencyInjection\Service\AbstractService, Symfony\Bundle\FrameworkBundle\Controller\Controller, JMS\DiExtraBundle\Annotation as DI; use Symfony\Component\HttpFoundation\Response; /** * BlogController * * @DI\Service("jity_service.controller.blog", scope="request") * @DI\Tag("jity_service.controller") * * @uses Controller * @version $id$ * @author Hermann Mayer <hermann.mayer92@gmail.com> */ class BlogController extends AbstractService { /** * getName * * @access public * @return void */ public function getName() { return 'blog'; } /** * getDescription * * @access public * @return void */ public function getDescription() { return 'Fügt die Startseite eines Blogs hinzu.'; } /** * process * * @access public * @return void */ public function process() { return $this->container->get('templating')->render('JityHomepageBundle:Service:Blog/news.html.twig', array()); } }