0

Smyony2 で d:f:l を使用しようとすると、このエラーが発生します。Servicio と Usuario で同じエラーが発生したため、1 つの例を投稿します。助けていただければ、もう 1 つの例も修正されます。

  [ErrorException]
  Catchable Fatal Error: Argument 1 passed to PGE\BitacoraBundle\Entity\Tarea::setServicio() must be an instance of PGE\BitacoraBundle\Entity\Servicio, integer given, called in D:\Zend\Apache2\htdocs\PGE\src\PGE\BitacoraBu
  ndle\DataFixtures\ORM\Tareas.php on line 20 and defined in D:\Zend\Apache2\htdocs\PGE\src\PGE\BitacoraBundle\Entity\Tarea.php line 281

これはコードです:

Tareas.php

<?php
namespace PGE\BitacoraBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use PGE\BitacoraBundle\Entity\Tarea;

class Tareas extends AbstractFixture implements OrderedFixtureInterface
{
    public function getOrder()
    {
        return 3;
    }
    public function load(ObjectManager $manager)
    {
        for ($i = 1; $i < 5; $i++) {
            $entidad = new Tarea();

            $entidad->setServicio($i);

            $entidad->setFechaInicio(new \DateTime());
            $entidad->setFechaFinal(new \DateTime());
            $entidad->setDescripcion('Descripcion aqui');
            $entidad->setEstado('Pendiente');
            $entidad->setPrioridad('P1');
            $entidad->setResumen('Hola soy un resumen');
            $entidad->setSolicitante('x068753');
            $entidad->setUsuario($i);
        }
    $manager->flush();
    }
}

Usuario.php

<?php
namespace PGE\BitacoraBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="bitacora_usuario")
*/
class Usuario
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
    */
    private $id;

    /** @ORM\Column(type="string", length=255) */
    private $nombre;

    /** @ORM\Column(type="string", length=255) */
    private $apellidos;

    /** @ORM\Column(type="string", length=255) */
    private $prbes;

    public function __toString()
    {
        return $this->getNombre().' '.$this->getApellidos();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set nombre
     *
     * @param string $nombre
     * @return Usuario
     */
    public function setNombre($nombre)
    {
        $this->nombre = $nombre;

        return $this;
    }

    /**
     * Get nombre
     *
     * @return string 
     */
    public function getNombre()
    {
        return $this->nombre;
    }

    /**
     * Set apellidos
     *
     * @param string $apellidos
     * @return Usuario
     */
    public function setApellidos($apellidos)
    {
        $this->apellidos = $apellidos;

        return $this;
    }

    /**
     * Get apellidos
     *
     * @return string 
     */
    public function getApellidos()
    {
        return $this->apellidos;
    }

    /**
     * Set prbes
     *
     * @param string $prbes
     * @return Usuario
     */
    public function setPrbes($prbes)
    {
        $this->prbes = $prbes;

        return $this;
    }

    /**
     * Get prbes
     *
     * @return string 
     */
    public function getPrbes()
    {
        return $this->prbes;
    }
}

編集: Symfony 2.1.X を使用しています

4

1 に答える 1