Rewriting Quickstart to use Model
- McLel
- Member | 12
Hello again. I've finished quickstart and I'm trying to rewrite it so it uses Model. But I can't get it to work. For starters, I wanted to rewrite the homepage:
presenters/HomepagePresenter.php:
model/HomepageModel.php:
Config.neon:
I am getting this error:
Nette\DI\ServiceCreationException
Class App\Model\HomepageModel used in service ‘26_App_Model_HomepageModel’ not found or is not instantiable.
I haven't changed anything in Latte yet. What am I missing?
Last edited by McLel (2015-11-17 15:32)
- Šaman
- Member | 2667
Is your /model
in /app
? It looks like RobotLoader
cant find class App\Model\HomepageModel
. Check all names and
namespaces. I cant see error in this in your posted code.
But you have another error – you dont inject HomepageModel
to
presenter correctly. Change to:
And name HomepageModel is VERY bad name for one class of model.
NewsModel
, or better NewsRepository
or
NewsService
will be better.
edit:
You use use
section (use App\Model\HomepageModel
), so
only HomepageModel
is need in @var
annotation.
I change it.
Last edited by Šaman (2015-11-17 15:13)