How to get settings from Controller

Hi,

I’m getting up to speed with Slim and I’m really liking it o far, it’s a breath of fresh air, especially after the byzantine labyrinth some other systems have evolved into (names shall not be mentioned :slight_smile:).

I’m facing what is probably an entirely basic issue, but I haven’t been able to figure it out. My controller code looks like this:

    final class HomeAction
    {
        private $view;
        private $logger;
        private $hash;
        private $auth;
        private $session;
        private $jsonRequest;

        public function __construct (JsonRequest $jsonRequest, Twig $view, LoggerInterface $logger, $hash, $auth)
        {
            $this->view = $view;
            $this->logger = $logger;
            $this->hash = $hash;
            $this->auth = $auth;
            $this->session = new \App\Helper\Session;
            $this->jsonRequest = new JsonRequest();
            $this->JsonRender = new JsonRenderer();
        }


        public function dispatch (Request $request, Response $response, $args)
        {
            $this->view->render ($response, 'home.twig', [
                'user' => User::all (),

            ]);

            return $response;
        }

My question is that I need to access my application settings but I have no idea how to get an app/container context from the class variable available to me under this scope.

Any hints are highly appreciated.

Pass in the settings that you need into the constructor.

Within your factory, they are in $c->get('settings');

Thanks, that worked like a charm.