Example #1
0
 /**
  * Gets the last updated shipment of the order
  *
  * @return false|ShipmentInterface
  */
 public function getLastShipment()
 {
     if ($this->shipments->isEmpty()) {
         return false;
     }
     $last = $this->shipments->first();
     foreach ($this->shipments as $shipment) {
         if ($shipment->getUpdatedAt() > $last->getUpdatedAt()) {
             $last = $shipment;
         }
     }
     return $last;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function hasShipment(ShipmentInterface $shipment)
 {
     return $this->shipments->contains($shipment);
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function removeShipment(ShipmentInterface $shipment)
 {
     if ($this->hasShipment($shipment)) {
         $shipment->setOrder(null);
         $this->shipments->removeElement($shipment);
     }
     return $this;
 }