protected function assertDeletable(ResourceInterface $resource)
    {
        if ($resource instanceof Model\SupplierOrderItemInterface) {
            if (null === $stockUnit = $resource->getStockUnit()) {
                return;
            }
            if (0 < $stockUnit->getShippedQuantity()) {
                throw new Exception\IllegalOperationException(
                    "Supplier delivery can't be removed as at least one ".
                    "of its items is linked to a shipped stock unit."
                ); // TODO message as translation id
            }
        } elseif ($resource instanceof Model\SupplierOrderInterface) {
            foreach ($resource->getItems() as $item) {
                $this->assertDeletable($item);
            }
        } elseif ($resource instanceof Model\SupplierDeliveryItemInterface) {
            $this->assertDeletable($resource->getOrderItem());
        } elseif ($resource instanceof Model\SupplierDeliveryInterface) {
            foreach ($resource->getItems() as $item) {
                $this->assertDeletable($item);
            }
        } else {
            throw new Exception\InvalidArgumentException("Unexpected resource."); // TODO message as translation id
        }
    }
protected function assertDeletable(ResourceInterface $resource)
    {
        if ($resource instanceof Model\SupplierOrderItemInterface) {
            if (null === $stockUnit = $resource->getStockUnit()) {
                return;
            }
            if (0 < $stockUnit->getShippedQuantity()) {
                throw new Exception\IllegalOperationException(
                    "Supplier delivery can't be removed as at least one ".
                    "of its items is linked to a shipped stock unit."
                ); // TODO message as translation id
            }
        } elseif ($resource instanceof Model\SupplierOrderInterface) {
            foreach ($resource->getItems() as $item) {
                $this->assertDeletable($item);
            }
        } elseif ($resource instanceof Model\SupplierDeliveryItemInterface) {
            $this->assertDeletable($resource->getOrderItem());
        } elseif ($resource instanceof Model\SupplierDeliveryInterface) {
            foreach ($resource->getItems() as $item) {
                $this->assertDeletable($item);
            }
        } else {
            throw new Exception\InvalidArgumentException("Unexpected resource."); // TODO message as translation id
        }
    }
protected function assertDeletable ( ResourceInterface $ resource ) { if ( $ resource instanceof Model \ SupplierOrderItemInterface ) { if ( null === $ stockUnit = $ resource -> getStockUnit ( ) ) { return ; } if ( 0 < $ stockUnit -> getShippedQuantity ( ) ) { throw new Exception \ IllegalOperationException ( "Supplier delivery can't be removed as at least one " . "of its items is linked to a shipped stock unit." ) ; // TODO message as translation id } } elseif ( $ resource instanceof Model \ SupplierOrderInterface ) { foreach ( $ resource -> getItems ( ) as $ item ) { $ this -> assertDeletable ( $ item ) ; } } elseif ( $ resource instanceof Model \ SupplierDeliveryItemInterface ) { $ this -> assertDeletable ( $ resource -> getOrderItem ( ) ) ; } elseif ( $ resource instanceof Model \ SupplierDeliveryInterface ) { foreach ( $ resource -> getItems ( ) as $ item ) { $ this -> assertDeletable ( $ item ) ; } } else { throw new Exception \ InvalidArgumentException ( "Unexpected resource." ) ; // TODO message as translation id } }
Asserts that the resource can be safely deleted.

@param ResourceInterface $resource

@throws Exception\CommerceExceptionInterface
Asserts that the resource can be safely deleted .