private function initializeMethod(ShipmentInterface $shipment)
    {
        // Abort if shipment's method is defined
        if (null !== $shipment->getMethod()) {
            return;
        }

        $sale = $shipment->getSale();

        // Abort if default method is not defined
        if (null === $method = $sale->getShipmentMethod()) {
            return;
        }

        $gateway = $this->registry->getGateway($method->getGatewayName());

        // Set shipment method if supported
        if (!$shipment->isReturn() && $gateway->supports(GatewayInterface::CAPABILITY_SHIPMENT)) {
            $shipment->setMethod($method);

            return;
        }

        // Set return method if supported
        if ($shipment->isReturn() && $gateway->supports(GatewayInterface::CAPABILITY_RETURN)) {
            $shipment->setMethod($method);

            return;
        }
    }
private function initializeMethod(ShipmentInterface $shipment)
    {
        // Abort if shipment's method is defined
        if (null !== $shipment->getMethod()) {
            return;
        }

        $sale = $shipment->getSale();

        // Abort if default method is not defined
        if (null === $method = $sale->getShipmentMethod()) {
            return;
        }

        $gateway = $this->registry->getGateway($method->getGatewayName());

        // Set shipment method if supported
        if (!$shipment->isReturn() && $gateway->supports(GatewayInterface::CAPABILITY_SHIPMENT)) {
            $shipment->setMethod($method);

            return;
        }

        // Set return method if supported
        if ($shipment->isReturn() && $gateway->supports(GatewayInterface::CAPABILITY_RETURN)) {
            $shipment->setMethod($method);

            return;
        }
    }
private function initializeMethod ( ShipmentInterface $ shipment ) { // Abort if shipment's method is defined if ( null !== $ shipment -> getMethod ( ) ) { return ; } $ sale = $ shipment -> getSale ( ) ; // Abort if default method is not defined if ( null === $ method = $ sale -> getShipmentMethod ( ) ) { return ; } $ gateway = $ this -> registry -> getGateway ( $ method -> getGatewayName ( ) ) ; // Set shipment method if supported if ( ! $ shipment -> isReturn ( ) && $ gateway -> supports ( GatewayInterface :: CAPABILITY_SHIPMENT ) ) { $ shipment -> setMethod ( $ method ) ; return ; } // Set return method if supported if ( $ shipment -> isReturn ( ) && $ gateway -> supports ( GatewayInterface :: CAPABILITY_RETURN ) ) { $ shipment -> setMethod ( $ method ) ; return ; } }
Initializes the shipment's method.

@param ShipmentInterface $shipment
Initializes the shipment s method .