php - How works the pseudo-variable $this in symfony? -


i understand official explanation $this: http://php.net/manual/en/language.oop5.basic.php

but if try understand object reference in case of symfony, don't know it, example:

each time when need return theme, use this:

public function indexaction()     {         return $this->render('foo/bar.html.twig', array());     } 

or when generate form:

public function indexaction(request $request)     {          // create form          $form = $this->createformbuilder()                 ->add('name', texttype::class)                 ->add('email', emailtype::class)                 ->add('subject', texttype::class)                 ->add('message', textareatype::class)                 ->add('send', submittype::class)                 ->getform(); } 

but object $this? , if working other word or value not $this, try understand better.

if asking located methods called $this in controller, take @ extends statement of controller (just after class declaration).

all controllers extends (by default) frameworkbundle controller, can access of inherited methods, such createform, render, getdoctrine, generateurl.

the parent controller extends containeraware (dependency injection), allows access , use services.
of methods listed shortcuts of services methods.

i.e. $this->generateurl(/*params*/) equal $this->container->get('router')->generate(/*params/*)


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -