Class ‚App\Components\Login\LoginControl‘ not found
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Durisvk
- Člen | 31
Problém je v tom, že môj presenter(viď. nižšie) **nevie nájsť môj **LoginControl class, pričom ten sa nachádza v app/components/Login/LoginControl.php – zatiaľ čo presenter je v app/presenters/HomepagePresenter.php
Error ktorý dostávam: Class ‚App\Components\Login\LoginControl‘ not found
<?php
namespace App\Components\Login;
class LoginControl extends \Nette\Application\UI\Control {
/**
* @var Nette\Http\User
*/
private $user;
public function __construct(Nette\Http\User $u) {
parent::__construct();
$this->user=$u;
}
public function render() {
$this->template->setFile(__DIR__ . '/login.latte');
$this->template->render();
}
protected function createComponentLoginForm() {
$form = new LoginForm;
$form->onSubmit[] = array($this, 'postForm_onSubmit');
}
protected function cryptPassword($password) {
return crypt($password,crypt('qyzxjb$te6546)98s=-36rgvdjha3;.,kenq`~','5*4234hdnsf~3414-*/451vsgaquerhfg?><ML:qwe322441asdc'));
}
/** @var \App\Model\Authenticator @inject */
private function postForm_onSubmit(Nette\Application\UI\Form $form) {
$values = $form->getValues();
$this->user->login($values['name'],$this->cryptPassword($values['pass']));
}
}
<?php
namespace App\Presenters;
use Nette,
App\Model,
App\Components\Login;
/**
* Homepage presenter.
*/
class HomepagePresenter extends BasePresenter
{
private $database;
private $authenticator;
function __construct(Nette\Database\Context $connection) {
$this->database=$connection;
}
private $welcome='Welcome to ArcheryArena!';
public function renderDefault()
{
$this->template->welcome = $this->welcome;
}
protected function createComponentLogInForm() {
$this->authenticator= new \App\Model\MyAuthenticator($this->database);
$this->user->setAuthenticator($this->authenticator);
return new \App\Components\Login\LoginControl($this->user);
}
}
Vopred Vďaka za odpoveď
- Durisvk
- Člen | 31
Ešte doplnok, zrejme si musím naconfigurovať mapping aj na componenty.
Zatiaľ obsahuje len cesty na Module a na Presenters. Takže vyzerá takto:
parameters:
php:
date.timezone: Europe/Prague
nette:
application:
errorPresenter: Error
mapping:
*: App\*Module\Presenters\*Presenter
session:
expiration: 14 days
services:
- App\RouterFactory
router: @App\RouterFactory::createRouter
authenticator: \App\Model\MyAuthenticator
Neviem však ako to urobiť…Pomôžete mi prosím? :)
- Durisvk
- Člen | 31
Opäť zdravím, cache som premazal, nepomohlo. Stále ten istý error.
GitHub : https://github.com/…ArcheryArena
- Marek Šneberger
- Člen | 130
return new \App\Components\LoginControl\LoginControl($this->user);
Editoval Marek Šneberger (16. 8. 2014 22:05)