これは私がマップしようとしている私のコードです
これは私のuser.phpです
<?php
namespace User\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
/**
* @ORM\Entity
* @ORM\Table(name="users")
* @property string $user_name
* @property string $pass_word
* @property int $id
*/
class User implements InputFilterAwareInterface {
protected $inputFilter;
/**
* @ORM\ManyToMany(targetEntity="Subject\Entity\Subject", inversedBy="users")
* @JoinTable(name="users_subjects")
* @var Collection
*/
protected $userName;
protected $password;
private $subjects;
/** @ORM\Id() @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO") @var int */
protected $id;
public function __get($property) {
return $this->$property;
}
public function __construct() {
$this->subjects = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Magic setter to save protected properties.
*
* @param string $property
* @param mixed $value
*/
public function __set($property, $value) {
$this->$property = $value;
}
/**
* Convert the object to an array.
*
* @return array
*/
public function getArrayCopy() {
return get_object_vars($this);
}
public function populate($data = array()) {
$this->id = $data['id'];
$this->userName = $data['userame'];
$this->password = $data['password '];
}
public function setInputFilter(InputFilterInterface $inputFilter) {
throw new \Exception("Not used");
}
public function getInputFilter() {
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$inputFactory = new InputFactory();
$inputFilter->add($inputFactory->createInput(array('name' => 'id',
'required' => true,
'filters' => array(
array('name' => 'Int'),
))));
$inputFilter->add($inputFactory->createInput(array('name' => 'Username',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
)));
$inputFilter->add($inputFactory->createInput(array('name' => 'Password',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
)));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
//put your code here
}
?>
そしてここに私のsubject.phpが行きます
<?php
namespace Subject\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
/**
*
* @ORM\Entity
* @ORM\Table(name="subject")
* @property string $subjectname
* @property int $users
* @property int $id
*/
class Subject implements InputFilterAwareInterface {
protected $inputFilter;
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $subjectname;
/**
* @ORM\ManyToMany(targetEntity="User\Entity\User", mappedBy="subjects")
*/
protected $users;
public function __construct() {
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
$this->addUser($this->users);
}
/** @return User|null */
public function getUsers() {
return $this->users;
}
/** @param User $user */
public function addUser(User $user) {
if ($users !== null || $user instanceof User) {
$this->users->add($users);
} else {
throw new InvalidArgumentException('$user must be instance of Entity\User or null!');
}
}
/**
* Magic getter to expose protected properties.
*
* @param string $property
* @return mixed
*/
public function __get($property) {
return $this->$property;
}
/**
* Magic setter to save protected properties.
*
* @param string $property
* @param mixed $value
*/
public function __set($property, $value) {
$this->$property = $value;
}
/**
* Convert the object to an array.
*
* @return array
*/
public function getArrayCopy() {
return get_object_vars($this);
}
/**
* Populate from an array.
*
* @param array $data
*/
public function populate($data = array()) {
$this->id = $data['id'];
$this->subjectname = $data['subjectname'];
$this->users = $data['user_id'];
//print_r($data);
}
public function setInputFilter(InputFilterInterface $inputFilter) {
throw new \Exception("Not used");
}
public function getInputFilter() {
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array(
'name' => 'id',
// 'required' => true,
'filters' => array(
array('name' => 'Int'),
),
)));
$inputFilter->add($factory->createInput(array(
'name' => 'subjectname',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
)));
$inputFilter->add($factory->createInput(array(
'name' => 'users',
'required' => true,
'filters' => array(
array('name' => 'Int'),
),
)));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
}
多対多をマッピングしているので、なぜこのエラーが発生するのかわかりません
ターゲットエンティティのUser\Entity\Userが「Subject\Entity \ Subject#users」に見つかりません。」