Closed aistis- closed 9 years ago
Hello, I need to do some calculations with my entity before converting it to string/integer. It looks something like this:
$priceProvider = $this->get('the_most_awesome_price_'); $buyer = $this->getUser(); $datatable = $this->get('datatable') ->setEntity('SuperAwesomeundle:WarehouseProduct', 'wp') ->addJoin('wp.product', 'p') ->addJoin('wp.warehouse', 'w') ->addJoin('w.groups', 'wg', Join::ON) ->addJoin('wg.group', 'g', Join::ON) ->addJoin('g.members', 'm', Join::ON) ->setWhere('m = :buyer', array('buyer' => $buyer)) ->setFields(array( 'Product' => 'p.name', 'Price' => 'wp', // I need here to select the whole entity 'Quantity' => 'wp.quantity', 'Warehouse' => 'w.name', '_identifier_' => 'wp.id' )) ->setHasAction(true) ->setRenderers( array( 4 => array( 'view' => 'SuperAwesomeundle:RandomController:actions.html.twig', ), ) ) ->setRenderer( function(&$data) use ($priceProvider, $buyer) { foreach ($data as $key => $value){ if (1 === $key) { // I need to do some calculations from the WarehouseProduct // entity here to get printable value $data[$key] = $priceProvider->getPriceForBuyer($buyer, $data[$key]); } } } );
Do you guys have any ideas for that?
My work around is to get the entity by ID int the renderer...
Hello, I need to do some calculations with my entity before converting it to string/integer. It looks something like this:
Do you guys have any ideas for that?