Nefunguje registrace služby
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- kasparek
- Člen | 43
Ahoj,
snažím si vytvořit malou administraci ale narazil jsem na problém
u config.neon když si chchci model Pages.php registrovat jako službu.
config.neon
#
# SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser!
#
# If you don't protect this directory from direct web access, anybody will be able to see your passwords.
# https://nette.org/en/security-warning
#
parameters:
php:
date.timezone: Europe/Prague
nette:
application:
errorPresenter: Error
mapping:
*: App\*Module\Presenters\*Presenter
database:
dsn: 'mysql:host=localhost;dbname=test'
user: root
password: root
session:
expiration: 14 days
services:
- App\Model\UserManager
- App\RouterFactory
router: @App\RouterFactory::createRouter
pages: \App\Model\Pages
Vyhazuje mi to chybu
Class \App\Model\Pages used in service 'pages' not found or is not instantiable.
Pages.php
<?php
namespace Model;
use Nette\Object;
/**
* Pages model class.
*/
class Pages extends Nette\Object {
/** @var Nette\Database\Connection */
public $database;
public function __construct(Nette\Database\Connection $database)
{
$this->database = $database;
}
public function getPages() {
return $this->database->table('pages');
}
public function findBySlug($slug) {
return $this->database->table('pages')->where("slug", $slug)->fetch();
}
public function findFirstPage() {
return $this->database->table('pages')->get(1);
}
public function getMenu() {
return $this->database->table('pages')->fetchPairs('slug', 'title');
}
public function countAllWithSlug($slug) {
return $this->database->table('pages')->where("slug", $slug)->count();
}
}
Nevím jestli je chyba někde jinde ale už si nevím rady.
Verze nette je 2.2.3
Díky za rady