コード例 #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;
 }
コード例 #2
0
 public function testSetDefaultOptions()
 {
     /** @var OptionsResolverInterface|\PHPUnit_Framework_MockObject_MockObject $resolver */
     $resolver = $this->getMock('Symfony\\Component\\OptionsResolver\\OptionsResolverInterface');
     $resolver->expects($this->once())->method('setDefaults')->with($this->isType('array'));
     $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]]));
     $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $this->type->setDefaultOptions($resolver);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->routerMock = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $this->assetsHelperMock = $this->getMockBuilder('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper')->disableOriginalConstructor()->getMock();
     $this->assetsHelperMock->expects($this->any())->method('getUrl')->will($this->returnArgument(0));
     $this->containerMock = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->containerMock->expects($this->any())->method('get')->will($this->returnValueMap(array(array('templating.helper.assets', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->assetsHelperMock), array('router', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->routerMock))));
     $this->helper = new CKEditorHelper($this->containerMock);
 }
コード例 #4
0
 /**
  * @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;
 }
コード例 #5
0
ファイル: PhpcrOdmTree.php プロジェクト: viral810/ngSimpleCMS
 /**
  * {@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;
 }
コード例 #6
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;
 }
コード例 #7
0
 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);
 }
コード例 #8
0
 /**
  * @return CoreAssetsHelper
  */
 protected function getAssetsHelper()
 {
     if (!$this->assetsHelper) {
         $this->assetsHelper = $this->container->get('templating.helper.assets');
         $this->assetsHelper->addPackage('url', new UrlPackage());
     }
     return $this->assetsHelper;
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 /**
  * Constructor.
  *
  * @param string       $basePath      The base path
  * @param string|array $baseUrls      Base asset URLs
  * @param string       $version       The asset version
  * @param string       $format        The version format
  * @param array        $namedPackages Additional packages
  */
 public function __construct($basePath = null, $baseUrls = array(), $version = null, $format = null, $namedPackages = array())
 {
     if ($baseUrls) {
         $defaultPackage = new UrlPackage($baseUrls, $version, $format);
     } else {
         $defaultPackage = new PathPackage($basePath, $version, $format);
     }
     parent::__construct($defaultPackage, $namedPackages);
 }
コード例 #11
0
 /**
  * @param array $files
  * @param array $options
  * @param array $expected
  *
  * @dataProvider optionsProvider
  */
 public function testFinishView(array $files, array $options, array $expected)
 {
     $testDir = $this->getTestDir();
     $this->removeTestDir($testDir);
     mkdir($testDir);
     $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface');
     $view = new FormView();
     $valueMap = [];
     foreach ($files as $fileName) {
         file_put_contents($testDir . DIRECTORY_SEPARATOR . $fileName, '');
         if (isset($expected['files'][$fileName])) {
             array_push($valueMap, [$options['source']['url'] . '/' . $fileName, null, $expected['files'][$fileName]]);
         }
     }
     $this->assetHelper->expects($this->exactly(count($files)))->method('getUrl')->willReturnMap($valueMap);
     $this->type->finishView($view, $form, $options);
     $this->assertEquals($expected, $view->vars);
     $this->removeTestDir($testDir);
 }
コード例 #12
0
 public function testFinishView()
 {
     $this->registry->expects($this->once())->method('getAvailableIntegrationTypesDetailedData')->will($this->returnValue(['testType1' => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], 'testType2' => ["label" => "oro.type2.label"]]));
     $this->assetHelper->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $testIntegration1 = new Integration();
     $testIntegration1->setType('testType1');
     $testIntegration1Label = uniqid('label');
     $testIntegration1Id = uniqid('id');
     $testIntegration2 = new Integration();
     $testIntegration2->setType('testType2');
     $testIntegration2Label = uniqid('label');
     $testIntegration2Id = uniqid('id');
     $view = new FormView();
     $view->vars['choices'] = [new ChoiceView($testIntegration1, $testIntegration1Id, $testIntegration1Label), new ChoiceView($testIntegration2, $testIntegration2Id, $testIntegration2Label)];
     $this->type->finishView($view, $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'), []);
     $this->assertInstanceOf('Oro\\Bundle\\FormBundle\\Form\\Type\\ChoiceListItem', $view->vars['choices'][0]->label);
     $this->assertInstanceOf('Oro\\Bundle\\FormBundle\\Form\\Type\\ChoiceListItem', $view->vars['choices'][1]->label);
     $this->assertSame(['data-status' => true, 'data-icon' => 'bundles/acmedemo/img/logo.png'], $view->vars['choices'][0]->label->getAttr());
 }
コード例 #13
0
 /**
  * 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;
 }
コード例 #14
0
ファイル: AssetsHelper.php プロジェクト: woakes070048/mautic
 /**
  * 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;
 }
コード例 #15
0
 /**
  * @dataProvider pathProvider
  */
 public function testRenderTemplate($path, $asset, $url)
 {
     $this->assetsHelperMock->expects($this->once())->method('getUrl')->with($this->equalTo($path))->will($this->returnValue($asset));
     $this->assertSame('CKEDITOR.addTemplates("foo", {"imagesPath":' . json_encode($url) . ',"filename":"bat"});', $this->helper->renderTemplate('foo', array('imagesPath' => $path, 'filename' => 'bat')));
 }
コード例 #16
0
ファイル: CKEditorHelperTest.php プロジェクト: jul6art/vscms
 public function testRenderTemplate()
 {
     $this->assetsHelperMock->expects($this->once())->method('getUrl')->with($this->equalTo('foo'), $this->equalTo(null))->will($this->returnValue('bar'));
     $this->assetsVersionTrimerHelperMock->expects($this->once())->method('trim')->with($this->equalTo('bar'))->will($this->returnValue('baz'));
     $this->assertSame('CKEDITOR.addTemplates("foo", {"imagesPath":"baz","filename":"bat"});', $this->helper->renderTemplate('foo', array('imagesPath' => 'foo', 'filename' => 'bat')));
 }
コード例 #17
0
 public function testGetHelperName()
 {
     $helper = new CoreAssetsHelper($this->package);
     $this->assertEquals('assets', $helper->getName());
 }
コード例 #18
0
 public function testGetJsPath()
 {
     $this->assetsHelperMock->expects($this->once())->method('getUrl')->with($this->equalTo('foo'))->will($this->returnValue('bar'));
     $this->assertSame('bar', $this->helper->getJsPath('foo'));
 }