Call to a member function getByType() on a non-object v novej verzii 2.0rc1-PHP5.3
- Jamicon
- Člen | 19
Prešiel som z verzie Nette-2.0beta-PHP5.3 na Nette-2.0rc1-PHP5.3. Základnú stránku mi načíta, ale skoky do iného presenteru väčšinou skončí chybou na riadku 1386:
1381: /**
1382: * @return Nette\Http\Request
1383: */
1384: protected function getHttpRequest()
1385: {
1386: return $this->context->getByType('Nette\Http\IRequest');
1387: }
1388:
1389:
1390:
Píše mi toto:
Fatal Error
Call to a member function getByType() on a non-object
Neviem, čo mám zmeniť, routa je podľa mňa v poriadku, na verzii beta funguje všetko spolahlivo.
- Jamicon
- Člen | 19
<?php
/**
* My Application bootstrap file.
*/
use Nette\Diagnostics\Debugger,
Nette\Application\Routers\Route,
Nette\Application\Routers\RouteList,
Nette\Caching\Cache,
Nette\Security\Permission,
Nette\Configurator;
// Load Nette Framework
require_once LIBS_DIR . '/Nette/loader.php';
require_once LIBS_DIR . '/dibi/Nette/DateTime53.php';
require_once LIBS_DIR . '/dibi/dibi.php';
// Enable Nette Debugger for error visualisation & logging
Debugger::$logDirectory = __DIR__ . '/../log';
Debugger::$strictMode = TRUE;
Debugger::enable();
// Configure application
$configurator = new Nette\Config\Configurator;
$configurator->setTempDirectory(__DIR__ . '/../temp');
// Enable RobotLoader - this will load all classes automatically
$configurator->createRobotLoader()
->addDirectory(APP_DIR)
->addDirectory(LIBS_DIR)
->register();
// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config.neon');
$container = $configurator->createContainer();
// Opens already started session
if ($container->session->exists()) {
// sezení vyprší po 30 dňoch neaktivity
$container->session->setExpiration('+ 30 days');
// nastavení cesty pro ukládání session dat na serveru
// soubory session se hromadí v tomto adresáři, udržuje ho garbage collector
$container->session->setSavePath(__DIR__ . '/../temp/cache/sessions');
$container->session->start();
}
\dibi::connect( $container->params['database'] );
// Setup router
$router = $container->router;
$router[] = new Route('admin/<presenter>/[<action>][/<id=>]', array(
'module' => 'Admin',
'action' => 'default'), Route::SECURED);
$router[] = new Route('member/<presenter>/[<action>][/<id=>]', array(
'module' => 'member',
'action' => 'default'), Route::SECURED);
$router[] = new Route('<presenter>/<action>[/<id [0-9]+>]', array(
'module' => 'Front',
'presenter' => 'Hladanie',
'action' => 'zadanie',
'id' => null,
));
//$router[] = new Route('<module>/<presenter>/<action>[/<id>]');
//$router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY);
//$router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
// Configure and run the application!
$application = $container->application;
//$application->catchExceptions = TRUE;
$application->errorPresenter = 'Error';
$application->run();
Keďže ide pravdepodobne o kontainer, prikladám ešte 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
#
common:
parameters:
database:
driver: mysqli
host: localhost
dbname: ****
user: ****
password: ****
database: ****
profiler: true
php:
date.timezone: Europe/Bratislava
#session.save_path: "%tempDir%/sessions"
zlib.output_compression: yes
nette:
database:
default:
dsn: '%database.driver%:host=%database.host%;dbname=%database.dbname%'
user: %database.user%
password: %database.password%
services:
database: @Nette\Database\Connection
# authenticator: Authenticator( @database::table(users) )
authenticator:
class: Models\Triedy\Authenticator
factories:
production < common:
development < common:
Editoval Jamicon (26. 1. 2012 9:57)
- Jamicon
- Člen | 19
Bohužiaľ rovnakú chybu mi vyhodí aj na Nette-2.0-rc2, navyše mi pribudla
ešte jedna. Asi počkám na finálnu verziu. Zaujímavé je, že chyba
vyskakuje iba vtedy, keď je v presenteri použitá komponenta
ForumControl,
dokonca i vtedy, keď daná akcia Forum nepoužije. Žeby chyba v upravenom
modeli? Idem sa pozrieť.
- landy
- Člen | 3
Zdravim mám stejný problém na nejnovější verzi Nette. neví někdo co s tím?
class HomepagePresenter extends BasePresenter
{
public function __construct(\Asdf\Cqrs\CommandBus $bus)
{
$this->setContext($kolo);
}
public function setContext(\Nette\DI\IContainer $context)
{
$this->context = $context;
}
public function renderDefault()
{
$this->template->anyVariable = 'any value';
}
}