Použitie továrničky bez „inject“
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- mbskot
- Člen | 42
Cafte,
je možné použiť továrničku bez definovania „inject“ metódy?
Spravil som toto:
# config.neon
factories:
exampleControl:
class: App\ExampleControl(%id%)
parameters: [id]
# komponenta
namespace App;
class ExampleControl extends \Nette\Application\UI\Control
{
/** @var int */
private $id;
/**
* @param int $id
*/
public function __construct($id)
{
parent::__construct();
$this->id = $id;
}
}
# presenter
$control = $this->createExampleControl(123);
a nefunguje to. Hlási chybu "Nette\MemberAccessException
Call to undefined method FrontModule\HomepagePresenter::createExampleControl()."
V čom robím chybu?
Ďakujem za odpoveď