Skip to content

Instantly share code, notes, and snippets.

@holantomas
Last active October 20, 2017 10:29
Show Gist options
  • Save holantomas/910757baf51618ecf3b43f47ef3e7034 to your computer and use it in GitHub Desktop.
Save holantomas/910757baf51618ecf3b43f47ef3e7034 to your computer and use it in GitHub Desktop.
Ukazka Nette komponenty
services:
- IFooControlFactory
<p n:foreach="$flashes as $flash">{$flash->message}</p>
<?php
use Nette\Application\UI\Control;
class FooControl extends Control {
/** @var SomeDependecy */
private $depend;
public function (SomeDependecy $depend) {
$this->depend = $depend;
$this->getTemplate()->setFile(__DIR__ . DIRECTORY_SEPARATOR . "foo.latte");
}
public function handleShowFlashmessage() {
$this->flashMessage('Hello world');
$this->redrawControl();
}
public function render() {
$this->getTemplate()->render();
}
}
<?php
interaface IFooControlFactory {
/**
* @return FooControl
*/
public function create();
}
<?php
class Presenter {
/** @var IFooControlFactory @inject */
public $fooControlFactory;
/**
* @return FooControl
*/
protected function createComponentFoo() {
return $this->fooControlFactory->create();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment