vendor/startplatz/wordpress-integration-bundle/Wordpress/ShortCode/ControllerShortCode.php line 30

Open in your IDE?
  1. <?php
  2. namespace Startplatz\Bundle\WordpressIntegrationBundle\Wordpress\ShortCode;
  3. use Startplatz\Bundle\WordpressIntegrationBundle\Wordpress\ShortCode;
  4. use Symfony\Component\HttpKernel\Controller\ControllerReference;
  5. use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
  6. class ControllerShortCode implements ShortCode
  7. {
  8.     protected $controller;
  9.     protected $handler;
  10.     protected $debug;
  11.     public function __construct(FragmentHandler $handler$controller,$debug)
  12.     {
  13.         $this->controller $controller;
  14.         $this->handler $handler;
  15.         $this->debug $debug;
  16.     }
  17.     public function execute($attributes$content null)
  18.     {
  19.         try {
  20.             $attributes = (array)$attributes;
  21.             return $this->handler->render(
  22.                 new ControllerReference(
  23.                     $this->controller,
  24.                     $attributes
  25.                 )
  26.             );
  27.         } catch (\Exception $e) {
  28.             if ($this->debug) {
  29.                 throw $e;
  30.             }
  31.         }
  32.     }
  33. }