Get parameters from config.neon in template
Notice: This thread is very old.
- greeny
- Member | 405
You can't do it directly.
Better create some service that will help you:
config.neon:
<script>
common:
parameters:
contact_email: abc@abc.com
services:
- My\Namespace\Service( %contact_email% )
</script>
Service.php:
<?php
namespace My\Namespace;
class Service {
protected $email;
public function __construct($email) {
$this->email = $email;
}
public function getContactEmail() {
return $this->email;
}
}
?>
Presenter:
<?php
...
/** @var \My\Namespace\Service @inject */
public $service;
public function renderDefault() {
$this->template->email = $this->service->getContactEmail();
}
?>
Hope you will understand it :)
Last edited by greeny (2014-04-20 15:25)
- amik
- Member | 118
Ja wrote:
Yeah, I follow you, thanks :)
What if I done this with “parameters”?
<?php services: - My\Namespace\Service( %parameters% ) ?>
would be then accessible as an array with ‘contact_email’ ⇒ 'abc@abc.cz'?
This is not a good idea in the manner of reusability – your service will then receive a huge array of parameters from which it needs only e-mail. See my todays earlier post which explains similar problem.