Skip to content

Instantly share code, notes, and snippets.

@eS-IT
Last active January 12, 2017 16:52
Show Gist options
  • Save eS-IT/8482b702777e639da46c9ba319c1d58d to your computer and use it in GitHub Desktop.
Save eS-IT/8482b702777e639da46c9ba319c1d58d to your computer and use it in GitHub Desktop.
Contao 4: Dependency Injection - AcmeElement.php
<?php
class AcmeElement extends \ContentElement
{
/**
* Template
* @var string
*/
protected $strTemplate = 'ce_esit_default';
/**
* Generate the content element
*/
protected function compile()
{
if (TL_MODE == 'BE') {
$this->strTemplate = 'be_wildcard';
$this->Template = new \BackendTemplate($this->strTemplate);
$this->Template->wildcard = "### AcmeElement ###";
} else {
$greeter = \Contao\System::getContainer()->get('acme_test.greeter');
$greeter->greet();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment