Skip to content
Snippets Groups Projects
Select Git revision
  • 3e4fc1b1c4ef46cae404b2c642d2a76ca06f54df
  • master default protected
  • improvement/rename-transport-interface
  • 1.1.0
  • 1.0.1
  • 1.0.0
6 results

PlaceErpOrder.php

Blame
  • PlaceErpOrder.php 2.11 KiB
    <?php
    /**
     * Copyright (c) 2020 TechDivision GmbH
     * All rights reserved
     *
     * This product includes proprietary software developed at TechDivision GmbH, Germany
     * For more information see https://www.techdivision.com/
     *
     * To obtain a valid license for using this software please contact us at
     * license@techdivision.com
     */
    declare(strict_types=1);
    
    namespace Workshop\OrderExport\Model\Command;
    
    use Magento\Framework\App\Filesystem\DirectoryList;
    use Magento\Framework\Exception\FileSystemException;
    use Magento\Framework\Filesystem\Io\IoInterface;
    use Magento\Framework\Filesystem;
    use Magento\Framework\Serialize\SerializerInterface;
    use Workshop\OrderExport\Api\Data\ErpOrderInterface;
    use Workshop\OrderExport\Api\PlaceErpOrderInterface;
    
    /**
     * @copyright  Copyright (c) 2020 TechDivision GmbH <info@techdivision.com> - TechDivision GmbH
     * @link       https://www.techdivision.com/
     * @author     Vadim Justus <v.justus@techdivision.com>
     */
    class PlaceErpOrder implements PlaceErpOrderInterface
    {
        /**
         * @var IoInterface
         */
        private $file;
    
        /**
         * @var Filesystem
         */
        private $filesystem;
    
        /**
         * @var SerializerInterface
         */
        private $serializer;
    
        /**
         * @param IoInterface $file
         * @param Filesystem $filesystem
         * @param SerializerInterface $serializer
         */
        public function __construct(
            IoInterface $file,
            Filesystem $filesystem,
            SerializerInterface $serializer
        ) {
            $this->file = $file;
            $this->filesystem = $filesystem;
            $this->serializer = $serializer;
        }
    
        /**
         * @param ErpOrderInterface $erpOrder
         * @throws FileSystemException
         */
        public function execute(ErpOrderInterface $erpOrder): void
        {
            $varExportDir = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_EXPORT);
            $orderExportPath = $varExportDir->getAbsolutePath('order');
            $this->file->mkdir($orderExportPath, 0770, true);