/** * @Route("/" ,name="default_index") * @Template() */ public function addAction() { $entity = new CustomerCase(); $entity->setType("CONSULTA_CLIENTE"); $entity->setStatus("New"); $form = $this->createCreateForm($entity); return array('entity' => $entity, 'form' => $form->createView()); }
private function updateDataBase(InputInterface $input, OutputInterface $output, $serializer) { $output->writeln("DESCARGANDO CASOS EN CRM"); //Buscar los casos: $get_entry_list_parameters = array('session' => $this->sessionId, 'module_name' => 'Cases', 'query' => "cases.type = 'CONSULTA_CLIENTE'", 'order_by' => "date_entered ASC", 'offset' => '0', 'link_name_to_fields_array' => array(array('name' => 'contacts', 'value' => array('id', 'first_name', 'last_name', 'email1'))), 'max_results' => '999', 'deleted' => '0', 'Favorites' => false); $result = $this->client->call('get_entry_list', $get_entry_list_parameters); if (isset($result['faultstring'])) { throw new \Exception($result['detail']); } $itemsKeys = array(); $customerCases = array(); foreach ($result['entry_list'] as $index => $items) { //Un nuevo objeto por cada item $customerCase = new CustomerCase(); foreach ($items as $key => $data) { $customerCase->setTicket($this->searchInResult(-1, $items, 'case_number')); $customerCase->setName($this->searchInResult(-1, $items, 'name')); $customerCase->setCreatedAt(strtotime($this->searchInResult(-1, $items, 'date_entered'))); $customerCase->setStatus($this->searchInResult(-1, $items, 'status')); $customerCase->setDescription($this->searchInResult(-1, $items, 'description')); $customerCase->setResolution($this->searchInResult(-1, $items, 'resolution')); } $customerCases[$index] = $customerCase; } //Con esto me aseguro que solo "bajen" los casos que tienen creados los contactos. foreach ($result['relationship_list'] as $index => $items) { foreach ($items['link_list'] as $data) { foreach ($data['records'] as $info) { $email = $this->searchInLinkedResult(-1, $info, 'email1'); $customerCase = $customerCases[$index]; $customerCase->setEmail($email); //Ahora guardo el objeto en Json. $output->writeln("GUARDANDO CASO #" . $customerCase->getTicket() . " EN LOCAL"); $file = $this->getContainer()->get('kernel')->getRootDir() . '/Resources/data/server/case-' . $customerCase->getTicket() . '-data.json'; file_put_contents($file, $serializer->serialize($customerCase, 'json')); } } } }