title: How to access entity variable in controller function?
body: <p>I have a variable <code>private $groupId;</code> in entity. And there is a controller function <code>public function settingsListAction(Request $request)</code></p>
  
  <p>I want to access that <code>groupId</code> in controller function. How it can be achieved?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Controller function is</p>
  
  <pre><code>/**
   * Get all settings content list
   * @Route("settings", name="settings_list")
   */
  public function settingsListAction(Request $request)
  {
      // Cannot edit at all.
      //Fetch Current Financial Year target data to display that on "Road to paradise tab"
      $entity = new J1Setting();
      //do smthing 
      $groupIdValue = $entity-&gt;getGroup();
  
      $settingsGroup = $this-&gt;getDoctrine()-&gt;getRepository('AppBundle:J1SettingGroup')-&gt;findAll();
  
      $settingsList = $this-&gt;getDoctrine()-&gt;getRepository('AppBundle:J1Setting')-&gt;findBy(array('groupId' =&gt; groupIdValue));
  
      return $this-&gt;render('default/settingsList.html.twig', array('settingsGroup' =&gt; $settingsGroup, 'settingsList' =&gt; $settingsList));
  }
  </code></pre>
  
  <p>And entity is:</p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use AppBundle\Component\Annotation\J1Entity;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
  * J1Setting
  *
  * @ORM\Table(name="j1_settings", indexes={@ORM\Index(name="IDX_SName", columns={"name"})})
  * @ORM\Entity(repositoryClass="AppBundle\Repository\J1SettingRepository")
  * @J1Entity(auditClass="AppBundle\Component\Audit\J1AuditSetting")
  */
  class J1Setting
  {
  /**
   * @var integer
   *
   * @ORM\Column(name="setting_id", type="integer")
   * 
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $settingid;
  
  /**
   * @var string
   *
   * @ORM\Column(name="name", type="string", length=100, nullable=true)
   */
  private $name;
  
  /**
   * @var string
   *
   * @ORM\Column(name="value", type="string", length=250, nullable=true)
   */
  private $value;
  
  /**
   * @var string
   *
   * @ORM\Column(name="description", type="string", length=255)
   */
  private $description;
  
  /**
   * @var integer
   *
   * @ORM\Column(name="group_id", type="integer")
   * @ORM\Id
   */
  private $groupId;
  
  /**
   * @var J1SettingGroup
   * 
   * @ORM\ManyToOne(targetEntity="J1SettingGroup", inversedBy="settings")
   * @ORM\JoinColumns({
   * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
   * })
  */
  private $group;
  
  /**
   * @var string
   *
   * @ORM\Column(name="setting_type", type="string", length=100)
   */
  private $settingType;
  
  
  
  /**
   * Get settingid
   *
   * @return integer
   */
  public function getSettingId()
  {
      return $this-&gt;settingid;
  }
  
  /**
   * Set name
   *
   * @param string $name
   * @return J1Setting
   */
  public function setName($name)
  {
      $this-&gt;name = $name;
  
      return $this;
  }
  
  /**
   * Get name
   *
   * @return string
   */
  public function getName()
  {
      return $this-&gt;name;
  }
  
  /**
   * Set value
   *
   * @param string $value
   * @return J1Setting
   */
  public function setValue($value)
  {
      $this-&gt;value = serialize($value);
  
      return $this;
  }
  
  /**
   * Get value
   *
   * @return string
   */
  public function getValue()
  {
      return unserialize($this-&gt;value);
  }
  
  /**
   * Return name replacing underscores with spaces
   *
   * @return mixed
   */
  public function getFriendlyName(){
      return str_replace('_', ' ', $this-&gt;getName());
  }
  /**
   * Set description
   *
   * @param string $description
   * @return J1Setting
   */
  public function setDescription($description)
  {
      $this-&gt;description = $description;
  
      return $this;
  }
  
  /**
   * Get description
   *
   * @return string 
   */
  public function getDescription()
  {
      return $this-&gt;description;
  }
  
  /**
   * Set groupId
   *
   * @param integer $groupId
   * @return J1Setting
   */
  public function setGroupId($groupId)
  {
      $this-&gt;groupId = $groupId;
  
      return $this;
  }
  
  /**
   * Get groupId
   *
   * @return integer 
   */
  public function getGroupId()
  {
      return $this-&gt;groupId;
  }
  
  /**
   * Set settingType
   *
   * @param string $settingType
   * @return J1Setting
   */
  public function setSettingType($settingType)
  {
      $this-&gt;settingType = $settingType;
  
      return $this;
  }
  
  /**
   * Get settingType
   *
   * @return string 
   */
  public function getSettingType()
  {
      return $this-&gt;settingType;
  }
  
  
  /**
  * Set group
  *
  * @param $group
  * @return J1Setting
  */
  public function setGroup($group = null)
  {
  $this-&gt;group = $group;
  
  return $this;
  }
  
  /**
  * Get group
  *
  * @return integer
  */
  public function getGroup()
  {
  return $this-&gt;group;
  }
  }
  </code></pre>