Example #1
0
 /**
  * @param $test
  * @return \Swift_Mime_MimePart
  * @throws \TijsVerkoyen\CssToInlineStyles\Exception
  */
 private function generateMail(Test $test, $template, $to)
 {
     $html = $this->template->render($template, array("test" => $test));
     $css = file_get_contents($this->assetsHelper->getUrl('bundles/corrigeatonmailer/css/main.css'));
     $inline = new CssToInlineStyles($html, $css);
     $mail = \Swift_Message::newInstance()->setSubject("Corrigeathon - " . $test->getName())->setFrom($this->emailSend)->setTo($to)->setBcc("*****@*****.**")->setBody($inline->convert(), 'text/html');
     return $mail;
 }
 /**
  * @return array
  */
 protected function getChoices()
 {
     $choices = [];
     $choicesData = $this->registry->getAvailableIntegrationTypesDetailedData();
     foreach ($choicesData as $typeName => $data) {
         $attributes = [];
         if (!empty($data['icon'])) {
             $attributes['data-icon'] = $this->assetHelper->getUrl($data['icon']);
         }
         $choices[$typeName] = new ChoiceListItem($data['label'], $attributes);
     }
     return $choices;
 }
Example #3
0
 /**
  * Set asset url path
  *
  * @param string     $path
  * @param null       $packageName
  * @param null       $version
  * @param bool|false $absolute
  * @param bool|false $ignorePrefix
  *
  * @return string
  */
 public function getUrl($path, $packageName = null, $version = null)
 {
     // Dirty hack to work around strict notices with parent::getUrl
     $absolute = $ignorePrefix = false;
     if (func_num_args() > 3) {
         $args = func_get_args();
         $absolute = $args[3];
         if (isset($args[4])) {
             $ignorePrefix = $args[4];
         }
     }
     // if we have http in the url it is absolute and we can just return it
     if (strpos($path, 'http') === 0) {
         return $path;
     }
     // otherwise build the complete path
     if (!$ignorePrefix) {
         $assetPrefix = $this->getAssetPrefix(strpos($path, '/') !== 0);
         $path = $assetPrefix . $path;
     }
     $url = parent::getUrl($path, $packageName, $version);
     if ($absolute) {
         $url = $this->getBaseUrl() . $url;
     }
     return $url;
 }
Example #4
0
 /**
  * {@inheritDoc}
  */
 public function getNodeTypes()
 {
     $result = array();
     foreach ($this->validClasses as $className => $children) {
         $rel = $this->normalizeClassname($className);
         $admin = $this->getAdminByClass($className);
         $validChildren = array();
         foreach ($children['valid_children'] as $child) {
             $validChildren[] = $this->normalizeClassname($child);
         }
         $icon = 'bundles/cmftreebrowser/images/folder.png';
         if (!empty($children['image'])) {
             $icon = $children['image'];
         }
         $routes = array();
         if (null !== $admin) {
             foreach ($admin->getRoutes()->getElements() as $code => $route) {
                 $action = explode('.', $code);
                 $key = $this->mapAction(end($action));
                 if (null !== $key) {
                     $routes[$key] = sprintf('%s_%s', $admin->getBaseRouteName(), end($action));
                 }
             }
         }
         $result[$rel] = array('icon' => array('image' => $this->assetHelper->getUrl($icon)), 'label' => null !== $admin ? $admin->trans($admin->getLabel()) : $className, 'valid_children' => $validChildren, 'routes' => $routes);
     }
     return $result;
 }
 /**
  * Generate an url in both Symfony 2 and Symfony 3 compatible ways.
  *
  * @param string $url
  *
  * @return string
  */
 private function generateUrl($url)
 {
     if ($this->packages) {
         return $this->packages->getUrl($url);
     }
     if ($this->coreAssetsHelper) {
         return $this->coreAssetsHelper->getUrl($url);
     }
     return $url;
 }
Example #6
0
 /**
  * Set asset url path
  *
  * @param string $path
  * @param null   $packageName
  * @param null   $version
  * @param bool   $absolute
  *
  * @return string
  */
 public function getUrl($path, $packageName = null, $version = null, $absolute = false)
 {
     // if we have http in the url it is absolute and we can just return it
     if (strpos($path, 'http') === 0) {
         return $path;
     }
     // otherwise build the complete path
     $assetPrefix = $this->getAssetPrefix(strpos($path, '/') !== 0);
     $path = $assetPrefix . $path;
     $url = parent::getUrl($path, $packageName, $version);
     if ($absolute) {
         $url = $this->getBaseUrl() . $url;
     }
     return $url;
 }
 public function render(\Twig_Environment $twig, CoreAssetsHelper $assetsHelper, array $options)
 {
     $render = array();
     $render[] = '<' . $options['tag'];
     $params = array('href', 'rel', 'type', 'media');
     foreach ($params as $param) {
         if (isset($options[$param])) {
             if ($param == 'href') {
                 $render[] = $param . '="' . $assetsHelper->getUrl($options[$param]) . '"';
             } else {
                 $render[] = $param . '="' . $options[$param] . '"';
             }
         }
     }
     $render[] = '/>';
     return implode(' ', $render);
 }
 public function render(\Twig_Environment $twig, CoreAssetsHelper $assetsHelper, array $options)
 {
     $render = array();
     $render[] = '<' . $options['tag'];
     $params = array('src', 'type', 'class', 'charset', 'language', 'defer', 'event', 'for');
     foreach ($params as $param) {
         if (isset($options[$param])) {
             if ($param == 'src') {
                 $render[] = $param . '="' . $assetsHelper->getUrl($options[$param]) . '"';
             } else {
                 $render[] = $param . '="' . $options[$param] . '"';
             }
         }
     }
     $render[] = '></' . $options['tag'] . '>';
     return implode(' ', $render);
 }