私は変数private $groupId;
を持っています。コントローラ機能がありますpublic function settingsListAction(Request $request)
コントローラ機能のエンティティ変数にアクセスする方法は?
コントローラー機能のgroupId
にアクセスしたいと思います。どのように達成することができますか?
編集
コントローラ機能は
/**
* 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->getGroup();
$settingsGroup = $this->getDoctrine()->getRepository('AppBundle:J1SettingGroup')->findAll();
$settingsList = $this->getDoctrine()->getRepository('AppBundle:J1Setting')->findBy(array('groupId' => groupIdValue));
return $this->render('default/settingsList.html.twig', array('settingsGroup' => $settingsGroup, 'settingsList' => $settingsList));
}
され、エンティティは次のとおりです。
<?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->settingid;
}
/**
* Set name
*
* @param string $name
* @return J1Setting
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set value
*
* @param string $value
* @return J1Setting
*/
public function setValue($value)
{
$this->value = serialize($value);
return $this;
}
/**
* Get value
*
* @return string
*/
public function getValue()
{
return unserialize($this->value);
}
/**
* Return name replacing underscores with spaces
*
* @return mixed
*/
public function getFriendlyName(){
return str_replace('_', ' ', $this->getName());
}
/**
* Set description
*
* @param string $description
* @return J1Setting
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set groupId
*
* @param integer $groupId
* @return J1Setting
*/
public function setGroupId($groupId)
{
$this->groupId = $groupId;
return $this;
}
/**
* Get groupId
*
* @return integer
*/
public function getGroupId()
{
return $this->groupId;
}
/**
* Set settingType
*
* @param string $settingType
* @return J1Setting
*/
public function setSettingType($settingType)
{
$this->settingType = $settingType;
return $this;
}
/**
* Get settingType
*
* @return string
*/
public function getSettingType()
{
return $this->settingType;
}
/**
* Set group
*
* @param $group
* @return J1Setting
*/
public function setGroup($group = null)
{
$this->group = $group;
return $this;
}
/**
* Get group
*
* @return integer
*/
public function getGroup()
{
return $this->group;
}
}
詳細を入力する必要があります。この '$ groupId'変数はどこにありますか?コントローラクラスの一部ですか?あなたの問題の完全な例を提供してください。 –
@EmanuelOster質問を編集しました –