/**
  * @param ContainerInterface $container
  * @returns AuraViewRenderer
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     $config = isset($config['templates']) ? $config['templates'] : [];
     if ($container->has('Aura\\View\\View')) {
         $renderer = $container->get('Aura\\View\\View');
     } else {
         $factory = new HelperLocatorFactory();
         $helpers = $factory->newInstance();
         $view_factory = new ViewFactory();
         $renderer = $view_factory->newInstance($helpers);
     }
     // Inject helpers
     $this->injectHelpers($renderer, $container);
     // Inject renderer
     $view = new AuraViewRenderer($renderer, isset($config['layout']) ? $config['layout'] : null);
     $map = isset($config['map']) ? $config['map'] : [];
     $viewRegistry = $renderer->getViewRegistry();
     $layoutRegistry = $renderer->getLayoutRegistry();
     foreach ($map as $template => $filename) {
         $viewRegistry->set($template, $filename);
         $layoutRegistry->set($template, $filename);
     }
     // Add template paths
     $allPaths = isset($config['paths']) && is_array($config['paths']) ? $config['paths'] : [];
     foreach ($allPaths as $namespace => $paths) {
         $namespace = is_numeric($namespace) ? null : $namespace;
         foreach ((array) $paths as $path) {
             $view->addPath($path, $namespace);
         }
     }
     return $view;
 }
示例#2
0
 public function getHtml()
 {
     if (!empty($this->html)) {
         return $this->html;
     }
     $factory = new HelperLocatorFactory();
     return $factory->newInstance();
 }
 protected function newView(RootConfig $config)
 {
     $helpersFactory = new HelperLocatorFactory();
     $helpers = $helpersFactory->newInstance();
     $viewFactory = new ViewFactory();
     $view = $viewFactory->newInstance($helpers);
     $this->setTemplate($view, $config);
     return $view;
 }
示例#4
0
<?php

// templates/contact.php
use Aura\Html\HelperLocatorFactory;
$factory = new HelperLocatorFactory();
$helper = $factory->newInstance();
function showFieldErrors($form, $name)
{
    $errors = $form->getMessages($name);
    $str = '';
    if ($errors) {
        $str .= '<ul>';
        foreach ($errors as $error) {
            $str .= '<li>' . $error . '</li>';
        }
        $str .= '</ul>';
    }
    return $str;
}
?>
<html>
<head>
    <title>Aura input form, inside slim framework</title>
</head>
<body>
    <form method="post" action="<?php 
echo $app->urlFor('contact');
?>
" enctype="multipart/form-data" >
        <table cellpadding="0" cellspacing="0">
            <tr>