VideoSiteFactory.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Muzich\CoreBundle\ElementFactory\Site\base;
  3. use Muzich\CoreBundle\Entity\Element;
  4. use Symfony\Component\DependencyInjection\Container;
  5. use Muzich\CoreBundle\ElementFactory\Site\base\BaseFactory;
  6. use Muzich\CoreBundle\ElementFactory\lib\VideoEmbed;
  7. /**
  8. *
  9. *
  10. * @author bux
  11. */
  12. class VideoSiteFactory extends BaseFactory
  13. {
  14. protected $video_engine = null;
  15. public function __construct(Element $element, Container $container)
  16. {
  17. parent::__construct($element, $container);
  18. // Configuration de VideoEmbed
  19. define('SITEBASE', $container->getParameter('sitebase'));
  20. define('VIDEO_EMBED_CONFIG_FILE', SITEBASE.$container->getParameter('video_embed_config_file'));
  21. //to activate debug mode and false for production usage. it will write
  22. //to a log file when something goes wrong but should not produce
  23. //exceptions in production enviroment
  24. define('DEBUG', $container->getParameter('video_embed_debug'));
  25. try {
  26. $this->video_engine = new VideoEmbed($this->element->getUrl());
  27. } catch (Exception $exc) {
  28. }
  29. }
  30. public function getEmbedCode()
  31. {
  32. if ($this->video_engine)
  33. {
  34. return $this->video_engine->embed;
  35. }
  36. return null;
  37. }
  38. }
  39. ?>