/** * @param \Shockwavemk\Mail\Base\Model\Config $config * @param \Magento\Framework\ObjectManagerInterface $manager * @throws MailException */ public function __construct(\Shockwavemk\Mail\Base\Model\Config $config, \Magento\Framework\ObjectManagerInterface $manager) { try { $this->_storage = $manager->get($config->getStorageClassName()); } catch (\Exception $e) { throw new MailException(new Phrase($e->getMessage()), $e); } }
/** * Selects transport class name from config and creates a new transport object with given message * * @param Config $config * @param MessageInterface $message * @param ObjectManagerInterface $manager * @throws MailException */ public function __construct(Config $config, MessageInterface $message, ObjectManagerInterface $manager) { try { $this->_message = $message; $transportClassName = $config->getTransportClassName(); $this->_transport = $manager->create($transportClassName, ['message' => $message]); } catch (\Exception $e) { throw new MailException(new Phrase($e->getMessage()), $e); } }
public function getLocalFileListForPath($localPath) { $files = []; $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($localPath), RecursiveIteratorIterator::LEAVES_ONLY, FilesystemIterator::SKIP_DOTS); foreach ($objects as $path => $object) { if ($object->getFilename() != '.' && $object->getFilename() != '..') { $hostTempFolderPath = $this->_config->getHostTempFolderPath(); $remoteFilePath = str_replace($hostTempFolderPath, '/', $object->getPathName()); $file = ['name' => $object->getFilename(), 'localPath' => $object->getPathName(), 'remotePath' => $remoteFilePath, 'modified' => $object->getMTime()]; $files[$object->getFilename()] = $file; } } return $files; }
/** * Get list of files in a local file path * * @param $localPath * @return string[] */ public function getLocalFileListForPath($localPath) { $files = []; $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($localPath), RecursiveIteratorIterator::LEAVES_ONLY, FilesystemIterator::SKIP_DOTS); /** * @var string $path * @var SplFileObject $object */ foreach ($objects as $path => $object) { /** @noinspection TypeUnsafeComparisonInspection */ /** @noinspection NotOptimalIfConditionsInspection */ if ($object->getFilename() != '.' && $object->getFilename() != '..') { $hostTempFolderPath = $this->_config->getHostSpoolerFolderPath(); /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ $remoteFilePath = str_replace($hostTempFolderPath, '/', $object->getPathName()); /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ $file = ['name' => $object->getFilename(), 'localPath' => $object->getPathName(), 'remotePath' => $remoteFilePath, 'modified' => $object->getMTime()]; $files[$object->getFilename()] = $file; } } return $files; }
/** * @return string */ public function getTrackingOpensEnabled() { /** @noinspection IsEmptyFunctionUsageInspection */ if (empty($value = $this->getData('tracking_opens_enabled'))) { $value = $this->_config->getTrackingOpensEnabled(); $this->setData('tracking_opens_enabled', $value); } return $value; }