I am doing app where I need register user.
RegisterController
class RegisterController extends Controller
{
public function indexAction(Request $request){
}
public function registerUserAction(Request $request) {
$newUser = new Register();
$newUser = $newUser->addNewUser($username, $password);
}
}
Service Register
class Register
{
public function addNewUser($username, $password) {
if(self::validateUsername($username) && self::validatePassword($password)) {
$em = $this->getDoctrine()->getManager();
}
}
}
config/services.yaml services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
Of course I can't access doctrine and entity manager in Register and I don't know how I can do this. Please don't post symfony documentation about service containers, I read it all and don't get it.