Пример #1
0
 /**
  * @param ParameterBag $bag
  *
  * @return Client
  * @throws \Exception
  */
 public function create($bag)
 {
     $client = new Client();
     $client->setMsisdn($bag->get(self::PARAM_MSISDN));
     $client->setCountry($bag->get(self::PARAM_COUNTRY));
     $client->setClientDirection($bag->get(self::PARAM_DIRECTION));
     $this->enManager->persist($client);
     $this->enManager->flush();
     return $client;
 }
 /**
  * @param Client $client
  * @param string $name
  *
  * @return bool
  */
 private function updateClientName(Client $client, $name)
 {
     if ($client->getName() == $name || empty($name)) {
         return $client;
     }
     $data = ['id' => $client->getId(), 'msisdn' => $client->getMsisdn(), 'name' => $name, 'gender' => $client->getGender(), 'country' => $client->getCountry(), 'clientDirection' => $client->getClientDirection()];
     return $this->getClientManager()->update(new ParameterBag($data));
 }
 protected function getClient($id)
 {
     $client = $this->enManager->getRepository(Client::clazz())->find($id);
     if ($client) {
         return $client;
     }
     throw new \Exception('Can\'t find Client by id');
 }
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $client = new Client();
     $client->setMsisdn('380670000000');
     $client->setName('Гордей');
     $client->setCountry($this->getReference('country:ua'));
     $client->setClientDirection($this->getReference('clientDirection:internet'));
     $client->setGender(Client::GENDER_MALE);
     $manager->persist($client);
     $this->addReference('client:00', $client);
     $client = new Client();
     $client->setMsisdn('380671111111');
     $client->setName('Андрей');
     $client->setCountry($this->getReference('country:ua'));
     $client->setClientDirection($this->getReference('clientDirection:friends'));
     $client->setGender(Client::GENDER_MALE);
     $manager->persist($client);
     $this->addReference('client:01', $client);
     $client = new Client();
     $client->setMsisdn('3806722222222');
     $client->setName('Инна');
     $client->setCountry($this->getReference('country:ua'));
     $client->setClientDirection($this->getReference('clientDirection:return'));
     $client->setGender(Client::GENDER_FEMALE);
     $manager->persist($client);
     $this->addReference('client:02', $client);
     $manager->flush();
 }
Пример #5
0
 /**
  * @param ParameterBag $params
  *
  * @return object
  */
 public function create($params)
 {
     $entity = new Client();
     $entity->setCountry($params->get('country'));
     $entity->setClientDirection($params->get('clientDirection'));
     $entity->setMsisdn($params->get('msisdn'));
     $entity->setName($params->get('name'));
     $entity->setGender($params->get('gender'));
     $this->persist($entity);
     return $entity;
 }