Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //controller
- public function editAction($id)
- {
- $em = $this->getDoctrine()->getEntityManager();
- $entity = $em->getRepository('DemandaBundle:Demanda')->find($id);
- if (!$entity) {
- throw $this->createNotFoundException('Unable to find Demanda entity.');
- }
- $editForm = $this->createForm(new DemandaType(), $entity);
- $deleteForm = $this->createDeleteForm($id);
- return $this->render('DemandaBundle:Demanda:edit.html.twig', array(
- 'entity' => $entity,
- 'edit_form' => $editForm->createView(),
- 'delete_form' => $deleteForm->createView(),
- ));
- }
- //classe demanda
- <?php
- namespace MaisAlimentos\DemandaBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\Common\Collections\ArrayCollection;
- /**
- * MaisAlimentos\DemandaBundle\Entity\Demanda
- *
- * @ORM\Table()
- * @ORM\Entity(repositoryClass="MaisAlimentos\DemandaBundle\Entity\DemandaRepository")
- */
- class Demanda
- {
- /**
- * @var integer $id
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string $titulo
- *
- * @ORM\Column(name="titulo", type="string", length=255)
- */
- private $titulo;
- /**
- * @var datetime $data_finalizacao
- *
- * @ORM\Column(name="data_finalizacao", type="datetime")
- */
- private $data_finalizacao;
- /**
- * @var boolean $ativa
- *
- * @ORM\Column(name="ativa", type="boolean")
- */
- private $ativa;
- /**
- * @ORM\OneToMany(targetEntity="ProdutoDemanda", mappedBy="demanda", cascade={"all"})
- */
- private $produtosDemanda;
- public function __construct()
- {
- $this->produtosDemanda = new ArrayCollection();
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set titulo
- *
- * @param string $titulo
- */
- public function setTitulo($titulo)
- {
- $this->titulo = $titulo;
- }
- /**
- * Get titulo
- *
- * @return string
- */
- public function getTitulo()
- {
- return $this->titulo;
- }
- /**
- * Set data_finalizacao
- *
- * @param datetime $dataFinalizacao
- */
- public function setDataFinalizacao($dataFinalizacao)
- {
- $this->data_finalizacao = $dataFinalizacao;
- }
- /**
- * Get data_finalizacao
- *
- * @return datetime
- */
- public function getDataFinalizacao()
- {
- return $this->data_finalizacao;
- }
- /**
- * Set ativa
- *
- * @param boolean $ativa
- */
- public function setAtiva($ativa)
- {
- $this->ativa = $ativa;
- }
- /**
- * Get ativa
- *
- * @return boolean
- */
- public function getAtiva()
- {
- return $this->ativa;
- }
- public function setProdutosDemanda( $produtosDemanda)
- {
- foreach ($produtosDemanda as $produtoDemanda) {
- $produtoDemanda->setDemanda($this);
- }
- $this->$produtosDemanda = $produtosDemanda;
- }
- public function getProdutosDemanda()
- {
- return $this->produtosDemanda;
- }
- }
- //classe produto
- <?php
- namespace MaisAlimentos\DemandaBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * MaisAlimentos\DemandaBundle\Entity\ProdutoDemanda
- *
- * @ORM\Table()
- * @ORM\Entity(repositoryClass="MaisAlimentos\DemandaBundle\Entity\ProdutoDemandaRepository")
- */
- class ProdutoDemanda
- {
- /**
- * @var integer $id
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string $nome
- *
- * @ORM\Column(name="nome", type="string", length=255)
- */
- private $nome;
- /**
- * @var string $ncm
- *
- * @ORM\Column(name="ncm", type="string", length=255)
- */
- private $ncm;
- /**
- * @var string $cod_mda
- *
- * @ORM\Column(name="cod_mda", type="string", length=255)
- */
- private $cod_mda;
- /**
- * @var integer $quantidade
- *
- * @ORM\Column(name="quantidade", type="integer")
- */
- private $quantidade;
- /**
- * @var string $unidade
- *
- * @ORM\Column(name="unidade", type="string", length=255)
- */
- private $unidade;
- /**
- * @var string $cota
- *
- * @ORM\Column(name="cota", type="string", length=255)
- */
- private $cota;
- /**
- * @ORM\ManyToOne(targetEntity="MaisAlimentos\DemandaBundle\Entity\Demanda")
- * @ORM\JoinColumn(name="demanda_id", referencedColumnName="id", onDelete="CASCADE")
- */
- private $demanda;
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set nome
- *
- * @param string $nome
- */
- public function setNome($nome)
- {
- $this->nome = $nome;
- }
- /**
- * Get nome
- *
- * @return string
- */
- public function getNome()
- {
- return $this->nome;
- }
- /**
- * Set ncm
- *
- * @param string $ncm
- */
- public function setNcm($ncm)
- {
- $this->ncm = $ncm;
- }
- /**
- * Get ncm
- *
- * @return string
- */
- public function getNcm()
- {
- return $this->ncm;
- }
- /**
- * Set cod_mda
- *
- * @param string $codMda
- */
- public function setCodMda($codMda)
- {
- $this->cod_mda = $codMda;
- }
- /**
- * Get cod_mda
- *
- * @return string
- */
- public function getCodMda()
- {
- return $this->cod_mda;
- }
- /**
- * Set quantidade
- *
- * @param integer $quantidade
- */
- public function setQuantidade($quantidade)
- {
- $this->quantidade = $quantidade;
- }
- /**
- * Get quantidade
- *
- * @return integer
- */
- public function getQuantidade()
- {
- return $this->quantidade;
- }
- /**
- * Set unidade
- *
- * @param string $unidade
- */
- public function setUnidade($unidade)
- {
- $this->unidade = $unidade;
- }
- /**
- * Get unidade
- *
- * @return string
- */
- public function getUnidade()
- {
- return $this->unidade;
- }
- /**
- * Set cota
- *
- * @param string $cota
- */
- public function setCota($cota)
- {
- $this->cota = $cota;
- }
- /**
- * Get cota
- *
- * @return string
- */
- public function getCota()
- {
- return $this->cota;
- }
- public function setDemanda(\MaisAlimentos\DemandaBundle\Entity\Demanda $demanda)
- {
- $this->demanda = $demanda;
- }
- public function getDemanda()
- {
- return $this->demanda;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement