Example #1
0
 public function __construct(Pixie $pixie, array $values = array())
 {
     parent::__construct($values);
     $this->pixie = $pixie;
     $app = $this;
     $this['fs'] = function () {
         return new Filesystem();
     };
     $this['containerHelper'] = function () use($app) {
         return $app->pixie->containerHelper;
     };
     $this['templating'] = function () use($app) {
         //$loader = new FilesystemLoader([__DIR__ . '/../../../assets/views/%name%']);
         $loader = new ClassTemplateLoader('App\\Templating\\Templates');
         //$engine = new PhpEngine(new SimpleTemplateNameParser(__DIR__ . '/../../../assets/views'), $app['containerHelper'], $loader);
         $engine = new PhpEngine(new PlainTemplateNameParser(), $app['containerHelper'], $loader);
         $engine->setEscaper('html_strong', function ($value) use($engine) {
             // Numbers and Boolean values get turned into strings which can cause problems
             // with type comparisons (e.g. === or is_int() etc).
             return is_string($value) ? htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $engine->getCharset(), true) : $value;
         });
         $engine->addHelpers([new TranslatorHelper($app['translator'])]);
         return $engine;
     };
     $this['translator'] = function () {
         return new IdentityTranslator();
     };
     $this->register(new ValidatorServiceProvider());
     $this->register(new FormServiceProvider());
     //$this->register(new TranslationServiceProvider());
     $this['form.extensions'] = $app->extend('form.extensions', function (array $extensions) use($app) {
         $realPath = realpath(__DIR__ . '/../../../vendor/symfony/framework-bundle/Symfony/Bundle/FrameworkBundle/Resources/views/Form');
         $extensions[] = new TemplatingExtension($app['templating'], null, [$realPath ?: 'phar://' . __DIR__ . '/../../../vendor/symfony/framework-bundle.phar/Symfony/Bundle/FrameworkBundle/Resources/views/Form']);
         $extensions[] = new VulnExtension();
         return $extensions;
     });
     $this['annotation.reader'] = function () {
         $basePath = __DIR__ . '/../../../modules/vulninjection/classes/';
         AnnotationRegistry::registerAutoloadNamespace('VulnModule\\Config\\Annotation', $basePath);
         try {
             return new AnnotationReader();
         } catch (\Exception $e) {
             return null;
         }
     };
     $this['vulnerability.context_metadata_factory'] = function () use($app) {
         $factory = new ContextMetadataFactory($app->pixie->annotationReader);
         $factory->addNamespace('App\\Controller\\', Context::TECH_GENERIC);
         $factory->addNamespace('App\\Controller\\', Context::TECH_WEB);
         $factory->addNamespace('AmfphpModule\\Services\\', Context::TECH_AMF);
         $factory->addNamespace('App\\Rest\\Controller\\', Context::TECH_REST);
         $factory->addNamespace('', Context::TECH_GWT);
         return $factory;
     };
 }
Example #2
0
    /**
     * @param PhpEngine $view
     * @param $label
     * @param $required
     * @param $compound
     * @param $id
     * @param $name
     * @param $translation_domain
     * @param $label_attr
     * @param FormHelper $formHelper
     * @param TranslatorHelper $translatorHelper
     * @param null $label_format
     */
    public function condition_label($view, $label, $required, $compound, $id, $name, $translation_domain, $label_attr, $formHelper, $translatorHelper, $label_format = null)
    {
        /** @var FormView $form */
        ?>
        <?php 
        if (false !== $label) {
            ?>
        <?php 
            if ($required) {
                $label_attr['class'] = trim((isset($label_attr['class']) ? $label_attr['class'] : '') . ' required');
            }
            ?>
        <?php 
            if (!$compound) {
                $label_attr['for'] = $id;
            }
            ?>
        <?php 
            if (!$label) {
                $label = !is_null($label_format) ? strtr($label_format, array('%name%' => $name, '%id%' => $id)) : $formHelper->humanize($name);
            }
            ?>
            <label <?php 
            foreach ($label_attr as $k => $v) {
                printf('%s="%s" ', $view->escape($k), $view->escape($v));
            }
            ?>
><?php 
            echo $view->escape($translatorHelper->trans($label, array(), $translation_domain));
            ?>
: </label>
        <?php 
        }
        ?>
        <?php 
    }