Adding Omnisearch controller

This commit is contained in:
Bob den Otter
2018-11-17 16:17:22 +01:00
parent f4b43de4da
commit 78c0d562dd
4 changed files with 87 additions and 5 deletions
@@ -82,7 +82,13 @@ class ContentEditController extends BaseController
return new RedirectResponse($url);
}
private function contentFromPost(Content $content = null, Request $request)
/**
* @param Content|null $content
* @param Request $request
*
* @return Content
*/
private function contentFromPost(Content $content, Request $request): Content
{
$post = $request->request->all();
@@ -104,7 +110,12 @@ class ContentEditController extends BaseController
return $content;
}
private function updateFieldFromPost(string $key, $postfield, Content $content)
/**
* @param string $key
* @param mixed $postfield
* @param Content $content
*/
private function updateFieldFromPost(string $key, $postfield, Content $content): void
{
if (!$field = $content->getField($key)) {
$fields = collect($content->getDefinition()->get('fields'));
+21 -3
View File
@@ -5,28 +5,46 @@ declare(strict_types=1);
namespace Bolt\Controller\Backend;
use Bolt\Controller\BaseController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class GeneralController extends BaseController
{
/**
* @Route("/about", name="bolt_about")
*
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*
* @return Response
*/
public function about()
public function about(): Response
{
return $this->renderTemplate('pages/about.html.twig');
}
/**
* @Route("/kitchensink", name="bolt_kitchensink")
*
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*
* @return Response
*/
public function kitchensink()
public function kitchensink(): Response
{
$this->addFlash('success', '<strong>Well done!</strong> You successfully read this important alert message.');
$this->addFlash('info', '<strong>Heads up!</strong> This alert needs your attention, but it\'s not super important.');
$this->addFlash('warning', '<strong>Warning!</strong> Better check yourself, you\'re not looking too good.');
$this->addFlash('danger', '<strong>Oh snap!</strong> Change a few things up and try submitting again.');
return $this->renderTemplate('pages/about.html.twig');
$twigVars = [
'title' => 'Kitchensink',
'subtitle' => 'To show a number of different things, on one page',
];
return $this->renderTemplate('pages/placeholder.html.twig', $twigVars);
}
}
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Bolt\Controller\Backend;
use Bolt\Controller\BaseController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class OmnisearchController extends BaseController
{
/**
* @Route("/omnisearch", name="bolt_omnisearch")
*/
public function omnisearch(): Response
{
$twigVars = [
'title' => 'Omnisearch',
'subtitle' => 'To search, in an omni-like fashion',
];
return $this->renderTemplate('pages/placeholder.html.twig', $twigVars);
}
}
+28
View File
@@ -0,0 +1,28 @@
{# Page: Footer > About #}
{% extends '@bolt/_base/layout.html.twig' %}
{% block title %} <strong>{{ title }}</strong>
{% if subtitle|default() %}» {{ subtitle }} {% endif %}{% endblock title %}
{% block main %}
<div class="row">
<div class="col-md-9">
<h2>{{ title }}</h2>
{% if subtitle|default() %}
<h3>{{ subtitle }}</h3>
{% endif %}
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Torquatus, is qui consul
cum Cn. Tum ille timide vel potius verecunde: Facio, inquit. Quae sequuntur igitur?
Sunt enim prima elementa naturae, quibus auctis vírtutis quasi germen efficitur.
Omnis enim est natura diligens sui. Duo Reges: constructio interrete.
</p>
</div>
</div>
{% endblock main %}