Advertisement
Guest User

Untitled

a guest
Aug 31st, 2012
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.00 KB | None | 0 0
  1. //controller
  2. public function editAction($id)
  3.     {
  4.         $em = $this->getDoctrine()->getEntityManager();
  5.  
  6.         $entity = $em->getRepository('DemandaBundle:Demanda')->find($id);
  7.  
  8.         if (!$entity) {
  9.             throw $this->createNotFoundException('Unable to find Demanda entity.');
  10.         }
  11.  
  12.         $editForm = $this->createForm(new DemandaType(), $entity);
  13.         $deleteForm = $this->createDeleteForm($id);
  14.        
  15.  
  16.         return $this->render('DemandaBundle:Demanda:edit.html.twig', array(
  17.             'entity'      => $entity,
  18.             'edit_form'   => $editForm->createView(),
  19.             'delete_form' => $deleteForm->createView(),
  20.         ));
  21.     }
  22.  
  23.  
  24.  
  25.  
  26. //classe demanda
  27. <?php
  28.  
  29. namespace MaisAlimentos\DemandaBundle\Entity;
  30.  
  31. use Doctrine\ORM\Mapping as ORM;
  32. use Doctrine\Common\Collections\ArrayCollection;
  33.  
  34. /**
  35.  * MaisAlimentos\DemandaBundle\Entity\Demanda
  36.  *
  37.  * @ORM\Table()
  38.  * @ORM\Entity(repositoryClass="MaisAlimentos\DemandaBundle\Entity\DemandaRepository")
  39.  */
  40. class Demanda
  41. {
  42.     /**
  43.      * @var integer $id
  44.      *
  45.      * @ORM\Column(name="id", type="integer")
  46.      * @ORM\Id
  47.      * @ORM\GeneratedValue(strategy="AUTO")
  48.      */
  49.     private $id;
  50.  
  51.     /**
  52.      * @var string $titulo
  53.      *
  54.      * @ORM\Column(name="titulo", type="string", length=255)
  55.      */
  56.     private $titulo;
  57.  
  58.     /**
  59.      * @var datetime $data_finalizacao
  60.      *
  61.      * @ORM\Column(name="data_finalizacao", type="datetime")
  62.      */
  63.     private $data_finalizacao;
  64.  
  65.     /**
  66.      * @var boolean $ativa
  67.      *
  68.      * @ORM\Column(name="ativa", type="boolean")
  69.      */
  70.     private $ativa;
  71.  
  72.  
  73. /**
  74.      * @ORM\OneToMany(targetEntity="ProdutoDemanda", mappedBy="demanda", cascade={"all"})
  75.      */
  76.     private $produtosDemanda;
  77.  
  78.  
  79.     public function __construct()
  80. {
  81.     $this->produtosDemanda = new ArrayCollection();
  82. }
  83.  
  84.  
  85.     /**
  86.      * Get id
  87.      *
  88.      * @return integer
  89.      */
  90.     public function getId()
  91.     {
  92.         return $this->id;
  93.     }
  94.  
  95.     /**
  96.      * Set titulo
  97.      *
  98.      * @param string $titulo
  99.      */
  100.     public function setTitulo($titulo)
  101.     {
  102.         $this->titulo = $titulo;
  103.     }
  104.  
  105.     /**
  106.      * Get titulo
  107.      *
  108.      * @return string
  109.      */
  110.     public function getTitulo()
  111.     {
  112.         return $this->titulo;
  113.     }
  114.  
  115.     /**
  116.      * Set data_finalizacao
  117.      *
  118.      * @param datetime $dataFinalizacao
  119.      */
  120.     public function setDataFinalizacao($dataFinalizacao)
  121.     {
  122.         $this->data_finalizacao = $dataFinalizacao;
  123.     }
  124.  
  125.     /**
  126.      * Get data_finalizacao
  127.      *
  128.      * @return datetime
  129.      */
  130.     public function getDataFinalizacao()
  131.     {
  132.         return $this->data_finalizacao;
  133.     }
  134.  
  135.     /**
  136.      * Set ativa
  137.      *
  138.      * @param boolean $ativa
  139.      */
  140.     public function setAtiva($ativa)
  141.     {
  142.         $this->ativa = $ativa;
  143.     }
  144.  
  145.     /**
  146.      * Get ativa
  147.      *
  148.      * @return boolean
  149.      */
  150.     public function getAtiva()
  151.     {
  152.         return $this->ativa;
  153.     }
  154.  
  155.    
  156.     public function setProdutosDemanda( $produtosDemanda)
  157.     {
  158.        foreach ($produtosDemanda as $produtoDemanda) {
  159.         $produtoDemanda->setDemanda($this);
  160.     }
  161.  
  162.     $this->$produtosDemanda = $produtosDemanda;
  163.     }
  164.    
  165.     public function getProdutosDemanda()
  166.     {
  167.         return $this->produtosDemanda;
  168.     }
  169.    
  170.    
  171. }
  172.  
  173.  
  174. //classe produto
  175.  
  176. <?php
  177.  
  178. namespace MaisAlimentos\DemandaBundle\Entity;
  179.  
  180. use Doctrine\ORM\Mapping as ORM;
  181.  
  182. /**
  183.  * MaisAlimentos\DemandaBundle\Entity\ProdutoDemanda
  184.  *
  185.  * @ORM\Table()
  186.  * @ORM\Entity(repositoryClass="MaisAlimentos\DemandaBundle\Entity\ProdutoDemandaRepository")
  187.  */
  188. class ProdutoDemanda
  189. {
  190.     /**
  191.      * @var integer $id
  192.      *
  193.      * @ORM\Column(name="id", type="integer")
  194.      * @ORM\Id
  195.      * @ORM\GeneratedValue(strategy="AUTO")
  196.      */
  197.     private $id;
  198.  
  199.     /**
  200.      * @var string $nome
  201.      *
  202.      * @ORM\Column(name="nome", type="string", length=255)
  203.      */
  204.     private $nome;
  205.  
  206.     /**
  207.      * @var string $ncm
  208.      *
  209.      * @ORM\Column(name="ncm", type="string", length=255)
  210.      */
  211.     private $ncm;
  212.  
  213.     /**
  214.      * @var string $cod_mda
  215.      *
  216.      * @ORM\Column(name="cod_mda", type="string", length=255)
  217.      */
  218.     private $cod_mda;
  219.  
  220.     /**
  221.      * @var integer $quantidade
  222.      *
  223.      * @ORM\Column(name="quantidade", type="integer")
  224.      */
  225.     private $quantidade;
  226.  
  227.     /**
  228.      * @var string $unidade
  229.      *
  230.      * @ORM\Column(name="unidade", type="string", length=255)
  231.      */
  232.     private $unidade;
  233.  
  234.     /**
  235.      * @var string $cota
  236.      *
  237.      * @ORM\Column(name="cota", type="string", length=255)
  238.      */
  239.     private $cota;
  240.    
  241.     /**
  242.      * @ORM\ManyToOne(targetEntity="MaisAlimentos\DemandaBundle\Entity\Demanda")
  243.      * @ORM\JoinColumn(name="demanda_id", referencedColumnName="id", onDelete="CASCADE")
  244.     */
  245.     private $demanda;
  246.  
  247.  
  248.     /**
  249.      * Get id
  250.      *
  251.      * @return integer
  252.      */
  253.     public function getId()
  254.     {
  255.         return $this->id;
  256.     }
  257.  
  258.     /**
  259.      * Set nome
  260.      *
  261.      * @param string $nome
  262.      */
  263.     public function setNome($nome)
  264.     {
  265.         $this->nome = $nome;
  266.     }
  267.  
  268.     /**
  269.      * Get nome
  270.      *
  271.      * @return string
  272.      */
  273.     public function getNome()
  274.     {
  275.         return $this->nome;
  276.     }
  277.  
  278.     /**
  279.      * Set ncm
  280.      *
  281.      * @param string $ncm
  282.      */
  283.     public function setNcm($ncm)
  284.     {
  285.         $this->ncm = $ncm;
  286.     }
  287.  
  288.     /**
  289.      * Get ncm
  290.      *
  291.      * @return string
  292.      */
  293.     public function getNcm()
  294.     {
  295.         return $this->ncm;
  296.     }
  297.  
  298.     /**
  299.      * Set cod_mda
  300.      *
  301.      * @param string $codMda
  302.      */
  303.     public function setCodMda($codMda)
  304.     {
  305.         $this->cod_mda = $codMda;
  306.     }
  307.  
  308.     /**
  309.      * Get cod_mda
  310.      *
  311.      * @return string
  312.      */
  313.     public function getCodMda()
  314.     {
  315.         return $this->cod_mda;
  316.     }
  317.  
  318.     /**
  319.      * Set quantidade
  320.      *
  321.      * @param integer $quantidade
  322.      */
  323.     public function setQuantidade($quantidade)
  324.     {
  325.         $this->quantidade = $quantidade;
  326.     }
  327.  
  328.     /**
  329.      * Get quantidade
  330.      *
  331.      * @return integer
  332.      */
  333.     public function getQuantidade()
  334.     {
  335.         return $this->quantidade;
  336.     }
  337.  
  338.     /**
  339.      * Set unidade
  340.      *
  341.      * @param string $unidade
  342.      */
  343.     public function setUnidade($unidade)
  344.     {
  345.         $this->unidade = $unidade;
  346.     }
  347.  
  348.     /**
  349.      * Get unidade
  350.      *
  351.      * @return string
  352.      */
  353.     public function getUnidade()
  354.     {
  355.         return $this->unidade;
  356.     }
  357.  
  358.     /**
  359.      * Set cota
  360.      *
  361.      * @param string $cota
  362.      */
  363.     public function setCota($cota)
  364.     {
  365.         $this->cota = $cota;
  366.     }
  367.  
  368.     /**
  369.      * Get cota
  370.      *
  371.      * @return string
  372.      */
  373.     public function getCota()
  374.     {
  375.         return $this->cota;
  376.     }
  377.    
  378.  
  379.    
  380.     public function setDemanda(\MaisAlimentos\DemandaBundle\Entity\Demanda $demanda)
  381.     {
  382.         $this->demanda = $demanda;
  383.     }
  384.    
  385.     public function getDemanda()
  386.     {
  387.         return $this->demanda;
  388.     }
  389. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement