Doctrine 2 주석 내장 기능이 Windows의 Symfony 2.8에서 작동하지 않습니다.'이름에 불법 문자가 있습니다 .`는 Doctrine 2에 포함되어 있습니다. symfony 2,8 양식에 임베드 가능
@ORM \ Embeddable이 작동하지 않습니다. 오류가 발생합니다. 이름 "address.addr_line_1"에 잘못된 문자가 있습니다. 이름은 문자, 숫자 또는 밑줄로 시작해야하며 문자, 숫자, 숫자, 밑줄 ("_"), 하이픈 ("-") 및 콜론 (":") 만 포함해야합니다. 오류는 공급 업체 ... \ src \ Symfony \ Component \ Form \ FormConfigBuilder.php에서옵니다.
이유는 자동 생성 된 이름 인 "address.addr_line_1"에있는 점인 것 같습니다.
자동 접두사를 사용하지 않도록 설정하고 자체 이름을 지정하려고했습니다. Doctrine은 addr_line_1과 같이 컬럼 이름을 가진 테이블을 생성한다.
그러나 생성 된 양식에는 주소가 "address.addr_line_1"인 필드가 포함되어 있지만 오류는 The name xxx contains illegal characters
이지만.
양식에 addr_line_1
을 사용하면 해당 이름이 존재하지 않는 오류가 발생합니다. 솔루션의
<?php
namespace Learn\MySQLBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
//use Doctrine\ORM\Mapping\Embeddable;
use Learn\MySQLBundle\Entity\Embeddable\AddressEmb;
use Learn\MySQLBundle\Entity\Embeddable\TelEmb;
/**
* @ORM\Table(name="te12AuthorEmb")
* @ORM\Entity()
*/
class e12AuthorEmb
{
/**
* @ORM\Id
* @ORM\Column(type="string", length=36)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Learn\MySQLBundle\Doctrine\Generator6")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string")
*/
protected $name;
// columnPrefix = "address_"
/** @ORM\Embedded(class="Learn\MySQLBundle\Entity\Embeddable\AddressEmb", columnPrefix=false) */
protected $address;
/** @var string @ORM\Column(type="string", length=200) */
protected $email = '';
// if there is a \Learn.. that cmd does not generate entities and crud, columnPrefix = "tel_"
/** @ORM\Embedded(class="Learn\MySQLBundle\Entity\Embeddable\TelEmb", columnPrefix=false) */
protected $tel = '';
public function __construct()
{
$this->address = new AddressEmb();
$this->tel = new TelEmb();
}
/**
* Set id
*
* @param string $id
*
* @return e5Author
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get id
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return e5Author
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set email
*
* @param string $email
*
* @return e10AuthorEmb
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set address
*
* @param \Learn\MySQLBundle\Entity\Embeddable\AddressEmb $address
*
* @return e10AuthorEmb
*/
public function setAddress(\Learn\MySQLBundle\Entity\Embeddable\AddressEmb $address)
{
$this->address = $address;
return $this;
}
/**
* Get address
*
* @return \Learn\MySQLBundle\Entity\Embeddable\AddressEmb
*/
public function getAddress()
{
return $this->address;
}
/**
* Set tel
*
* @param \Learn\MySQLBundle\Entity\Embeddable\TelEmb $tel
*
* @return e10AuthorEmb
*/
public function setTel(\Learn\MySQLBundle\Entity\Embeddable\TelEmb $tel)
{
$this->tel = $tel;
return $this;
}
/**
* Get tel
*
* @return \Learn\MySQLBundle\Entity\Embeddable\TelEmb
*/
public function getTel()
{
return $this->tel;
}
}
,,
<?php
namespace Learn\MySQLBundle\Entity\Embeddable;
use Doctrine\ORM\Mapping as ORM;
/**
* Description of AddressEmb
*
* @author gintare
*/
/** @ORM\Embeddable */
class AddressEmb
{
/** @ORM\Column(name="addr_line_1", type = "string", nullable=true) */
protected $addr_line_1 = "";
/** @ORM\Column(name="addr_line_2", type = "string", nullable=true) */
protected $addr_line_2 = "";
/** @ORM\Column(name="addr_town", type = "string", nullable=true) */
protected $addr_town = "";
/** @ORM\Column(name="addr_state", type = "string", nullable=true) */
protected $addr_state = "";
/** @ORM\Column(name="addr_postcode", type = "string", nullable=true) */
protected $addr_postcode = "";
/* may be relation to other entity @var \Entities\Country * */
/** @ORM\Column(name="addr_country", type = "string", nullable=true) */
protected $addr_country;
public function __construct($line_1 = null, $line_2 = null, $town = null,
$state = null, $postcode = null, $country=null)
{
$this->addr_line_1 = $line_1;
$this->addr_line_2 = $line_2;
$this->addr_town = $town;
$this->addr_state = $state;
$this->addr_postcode = $postcode;
$this->addr_country = $country;
}
}
<?php
namespace Learn\MySQLBundle\Entity\Embeddable;
use Doctrine\ORM\Mapping as ORM;
//use Doctrine\ORM\Mapping\Embeddable;
/**
* TelEmb - value object to represent telephone code with country
*
* @author gintare
*/
/** @ORM\Embeddable */
class TelEmb
{
/** @ORM\Column(name="tel_number", type = "string", nullable=true) */
protected $tel_number = "";
/* *@ORM\Column(name="tel_countrycode", type = "string", nullable=true) */
protected $tel_countrycode = "";
/** @ORM\Column(name="tel_country", type = "string", nullable=true) */
protected $tel_country;
/** @ORM\Column(name="tel_type", type = "string", nullable=true) */
protected $tel_type; //mobile, landline,
/** @ORM\Column(name="tel_costinfo", type = "string", nullable=true) */
protected $tel_costinfo; // information about cost
/** @ORM\Column(name="tel_accessinfo", type = "string", nullable=true) */
protected $tel_accessinfo; // information abotu accessability
public function __construct($number = null, $countrycode = null, $country = null,
$accessinfo = null, $costinfo = null, $type = null)
{
$this->tel_number = $number;
$this->tel_countrycode = $countrycode;
$this->tel_country = $country;
$this->tel_accessinfo = $accessinfo;
$this->tel_costinfo = $costinfo;
$this->tel_type = $type;
}
}
하나는 C:\Bitnami\wampstack-5.6.20-0\apache2\htdocs\sym\LearnDB\vendor\symfony\symfony\src\Symfony\Component\Form\FormConfigBuilder.php
에 점을 사용할 수있는 권한을 넣어하는 것입니다.
return '' === $name || null === $name || preg_match('/^[a-zA-Z0-9_][a-zA-Z0-9_\.\-:]*$/D', $name);
이 새로운 형태가 발생, 작동하지만 내가 임베드 특수 getter와 setter를 생성해야하기 때문에 내가 아직 학습과 진행되지 않았다. 가장 좋은 해결책은 여기에 설명 된대로 특성을 사용하는 것입니다 : http://russellscottwalker.blogspot.co.uk/2013/11/entities-vs-value-objects-and-doctrine-2.html
그럼에도 불구하고 Symfony 공급 업체 코드를 변경하지 않고 Embedable을 작동시키는 방법을 알고 있다면 작성할 수 있습니까?
은 아마 순서와 SELECT 오처럼 직접 쿼리와 함께 일하는 것이 오 WHERE o.address.addr_line_1 = : 그것은 심포니 양식을 작동하지 않습니다 http://welcometothebundle.com/persist-the-money-doctrine-value-object/ 1 호선.
너는 이걸 알지 못했다. Doctrine의 다른 점은 무엇입니까? – olga
Windows를 사용하기 때문에 Windows는 문자열에 대소 문자를 구분하지 않으므로 유사한 이름을 가진 두 개의 클래스를 가질 수 없습니다. – panche14