public function actionDefault($id, $type) { if ($id !== null) { $type = (int) $type; if (!ShipmentType::isValidValue($type)) { throw new BadRequestException(sprintf('Unknown shipment type %d.', $type)); } $this->shipment = $this->shipmentService->getById(ShipmentType::createFromValue($type), $id); } if ($this->shipment === null) { throw new BadRequestException(sprintf('Shipment with ID %d not found.', $id)); } }