setPrice() публичный Метод

Please note that the price is for a single item only, and can be null.
public setPrice ( float $price )
$price float The price to set
Пример #1
0
 /**
  * Retrieves a collection of resources.
  *
  * @param Request $request The request
  * @param int $id The ID of the part
  *
  * @return array|\Dunglas\ApiBundle\Model\PaginatorInterface|\Traversable
  *
  * @throws RuntimeException|RootNodeNotFoundException
  */
 public function __invoke(Request $request, $id)
 {
     list($resourceType) = $this->extractAttributes($request);
     $part = $this->getItem($this->dataProvider, $resourceType, $id);
     /**
      * @var $part Part
      */
     $quantity = $request->request->get("quantity");
     $user = $this->userService->getUser();
     $stock = new StockEntry(intval($quantity), $user);
     if ($request->request->has("price") && $request->request->get("price") !== null) {
         $stock->setPrice(floatval($request->request->get("price")));
     }
     if ($request->request->has("comment") && $request->request->get("comment") !== null) {
         $stock->setComment($request->request->get("comment"));
     }
     $part->addStockEntry($stock);
     $this->registry->getManager()->persist($stock);
     $this->registry->getManager()->flush();
     return $part;
 }