How to extend User class?

Notice: This thread is very old.
ghost1511
Member | 1
+
0
-

It's my first post on this forum so i would like to welcome everyone :)

I don't know how to extend Nette\Security\User. I would like to add some properties, and preserve functionality of this class.

Where should I do it? and how to replace the object in UI\Presenter?

PS. I hope my english isn't bad. I have not used it for a long time ;)

Tomáš Votruba
Moderator | 1110
+
0
-

Maybe there is better way, but it is possible via extension by overloading default class:

extensions:
	- MyUserExtension
class MyUserExtension extends Nette\DI\Extension
{

	public function loadConfiguration()
	{
		$container = $this->getContainerBuilder();

		$container->getDefinition('user')
			->setClass('YourCustom\Security\User');
	}

}

OR better try in config.neon:

services:
	user: YourCustom\Security\User

Last edited by Tomáš Votruba (2014-04-15 23:33)