php - Cannot use object of type as array -


i'm trying render order in page validation when refresh validation.html.twig got error:

error: cannot use object of type fly\bookingsbundle\entity\address array

if (!isset($order['tva']['%'.$entity->gettva()->getvalue()]))

but don't see wrong in controller:

bill

public function bill() {     $em = $this->getdoctrine()->getmanager();     $generator = $this->container->get('security.secure_random');     $session = $this->getrequest()->getsession();     $address = $session->get('address');     $cart = $session->get('cart');     $order = array();     $totalht = 0;     $totalttc = 0;      $order = $em->getrepository('flybookingsbundle:address')->find($address['address']);     $entities = $em->getrepository('flybookingsbundle:post')->findarray(array_keys($session->get('cart')));      foreach($entities $entity)     {         $priceht = ($entity->getprice() * $cart[$entity->getid()]);         $pricettc = ($entity->getprice() * $cart[$entity->getid()] / $entity->gettva()->getmultiplicate());         $totalht += $priceht;         $totalttc += $pricettc;          if (!isset($order['tva']['%'.$entity->gettva()->getvalue()]))             $order['tva']['%'.$entity->gettva()->getvalue()] = round($pricettc - $priceht,2);         else             $order['tva']['%'.$entity->gettva()->getvalue()] += round($pricettc - $priceht,2);          $order['entity'][$order->getid()] = array('reference' => $order->getname(),                                                  'quantity' => $cart[$entity->getid()],                                                  'priceht' => round($entity->getprice(),2),                                                  'pricettc' => round($entity->getprice() / $entity->gettva()->getmultiplicate(),2));     }      $order['address'] = array('surname' => $address->getsurname(),         'name' => $address->getname(),         'phone' => $address->getphone(),         'address' => $address->getaddress(),         'zipcode' => $address->getzipcode(),         'city' => $address->getcity(),         'country' => $address->getcountry(),         'complement' => $address->getcomplement());      $order['priceht'] = round($totalht,2);     $order['pricettc'] = round($totalttc,2);     $order['token'] = bin2hex($generator->nextbytes(20));      return $order; } 

validationaction

public function validationaction() {     if ($this->get('request')->getmethod() == 'post')         $this->setaddressonsession();     $em = $this->getdoctrine()->getmanager();     $prepareorder = $this->forward('flybookingsbundle:post:prepareorder');     $order = $em->getrepository('flybookingsbundle:address')->find($prepareorder->getcontent() );     return $this->render('flybookingsbundle:post:validation.html.twig', array('order' => $order)); } 

you assigning address object $order variable $order = $em->getrepository('flybookingsbundle:address')->find($address['address']); , want use array here $order['tva']..... , further down in code. have work $order methods/properties $order->gettva().


Comments