PHP Nette -  Parameter in __construct() has no class type hint or default value

PHP Nette - Parameter in __construct() has no class type hint or default value

Dobrý den,



při vytváření konstruktoru pro mojí factory (továrničku) obdržím chybu:





Nette\DI\ServiceCreationException
Service '3' (type of App\Model\Emails): Parameter $from in __construct() has no class type hint or default value, so its value must be specified.







Samozřejmě, že chybu jsem si přeložil, ale nevím jak to vyřešit. Prosím o pomoc:


public function __construct(Nette\Database\Context $database, Nette\Mail\IMailer $mailer, Settings $modelSettings, Logs $modelLogs, $from, $to, $subject, $message, $template, $priority)
{
$this->database = $database;
$this->mailer = $mailer;
$this->modelLogs = $modelLogs;
$this->modelSettings = $modelSettings;

$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->message = $message;
$this->template = $template;
$this->priority = $priority;
}







ODPOVĚĎ


Ahoj,



chybu "Nette\DI\ServiceCreationException Service '3' (type of App\Model\Emails): Parameter $from in __construct() has no class type hint or default value, so its value must be specified" jsem vyřešil nastavením hodnot v konstruktoru na NULL:




public function __construct(Nette\Database\Context $database, Nette\Mail\IMailer $mailer, Settings $modelSettings, Logs $modelLogs, $from = NULL, $to = NULL, $subject = NULL, $message = NULL, $template = NULL, $priority = NULL)
{
$this->database = $database;
$this->mailer = $mailer;
$this->modelLogs = $modelLogs;
$this->modelSettings = $modelSettings;

$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->message = $message;
$this->template = $template;
$this->priority = $priority;
}

Související obsah

programovani

nette

php

construct

factory

interface

error

oop

Komentáře

Vaše reakce na PHP Nette - Parameter in __construct() has no class type hint or default value

Reference

Podívejte se na naše reference

Prohlédnout

Aplikace

Podívejte se na naše aplikace

Prohlédnout

Co umíme?

Podívejte se co umíme

Prohlédnout

Co umíme?

Vytváříme sofistikované aplikace pro náročné

Od webových aplikací přes android až po převodové můstky či složité informační systémy.

Podívejte se k nám

Máte ještě čas? Podívejte se na další rubriky

Tento web používá soubory cookie. Dalším procházením tohoto webu vyjadřujete souhlas s jejich používáním.. Více informací zde.