A
A
ak_wi2019-06-18 16:35:41
symfony
ak_wi, 2019-06-18 16:35:41

Where is the best place in Symfony to store data displayed on all pages of the application?

Such data includes, for example, a phone number and an address that will be displayed in the footer on each page of the site. It seems that creating a separate entity for this and storing it in the database is not a good idea. And how to do it optimally? Store it in twig configs? And is it possible to make a simple editor of this through a form, for example?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
user49981, 2019-06-18
@ak_wi

https://symfony.com/doc/master/templating/embeddin...

// src/ControllerIndexController::data
    public function data()
    {
        $data = $this->getDoctrine()->getRepository(Data::class)->findOneBy([]);
        return $this->render('data.html.twig', ['data' => $data]);
    }

<!-- data.html.twig -->
    {{ data }}

<!--  base.html.twig  -->
    {% block footer %}
        <footer>
            {{ render(controller('App\\Controller\\IndexController::data')) }}
        </footer>
    {% endblock %}

O
OnYourLips, 2019-06-18
@OnYourLips

How to do it architecturally - answer from user49981

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question