/**
  * This method is used instead of APY\JsFormValidationBundle\Generator\FormValidationScriptGenerator::generate
  * to return inline client-side form validation javascript
  *
  * @param FormView $formView
  * @param boolean  $overwrite
  *
  * @return string
  */
 public function generate(FormView $formView, $overwrite = true)
 {
     $validationBundle = $this->getValidationBundle();
     $javascriptFramework = strtolower($this->container->getParameter('apy_js_form_validation.javascript_framework'));
     $template = $this->container->get('templating')->render("{$validationBundle}:Frameworks:JsFormValidation.js.{$javascriptFramework}.twig", $this->generateValidationParameters($formView));
     // Js compression
     if ($this->container->getParameter('apy_js_form_validation.yui_js')) {
         // Create asset and compress it
         $asset = new AssetCollection();
         $asset->setContent($template);
         return $asset->getContent();
     }
     return $template;
 }
Exemplo n.º 2
0
 public function testSetContent()
 {
     $coll = new AssetCollection();
     $coll->setContent('asdf');
     $this->assertEquals('asdf', $coll->getContent(), '->setContent() sets the content');
 }