public function createCustomerAddress(Customer $Customer, $is_nonmember = false)
{
$faker = $this->getFaker();
$Pref = $this->app['eccube.repository.master.pref']->find($faker->numberBetween(1, 47));
$tel = explode('-', $faker->phoneNumber);
$fax = explode('-', $faker->phoneNumber);
$CustomerAddress = new CustomerAddress();
$CustomerAddress->setCustomer($Customer)->setDelFlg(Constant::DISABLED)->setName01($faker->lastName)->setName02($faker->firstName)->setKana01($faker->lastKanaName)->setKana02($faker->firstKanaName)->setCompanyName($faker->company)->setZip01($faker->postcode1())->setZip02($faker->postcode2())->setPref($Pref)->setAddr01($faker->city)->setAddr02($faker->streetAddress)->setTel01($tel[0])->setTel02($tel[1])->setTel03($tel[2])->setFax01($fax[0])->setFax02($fax[1])->setFax03($fax[2]);
if ($is_nonmember) {
$Customer->addCustomerAddress($CustomerAddress);
// TODO 外部でやった方がいい?
$sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress';
$customerAddresses = unserialize($this->app['session']->get($sessionCustomerAddressKey));
if (!is_array($customerAddresses)) {
$customerAddresses = array();
}
$customerAddresses[] = $CustomerAddress;
$this->app['session']->set($sessionCustomerAddressKey, serialize($customerAddresses));
} else {
$this->app['orm.em']->persist($CustomerAddress);
$this->app['orm.em']->flush($CustomerAddress);
}
return $CustomerAddress;
}