/** * 設定を読み込む * * @param string $mailType * @param string $to * @param string $subject * @return array * @throws \LibraryBundle\Exception\DataNotFoundException */ private function _loadSetting($mailType, $to, $subject) { $setting = array('from' => null, 'fromLabel' => null, 'to' => $to, 'subject' => $subject, 'template' => null); // メッセージ設定取得 $config = $this->container->get('lib.config_mail')->getData($mailType); // メーラー設定取得 if (!$this->container->hasParameter('mailer')) { throw new \LibraryBundle\Exception\DataNotFoundException('parameters.mailを設定してください'); } $mailer = $this->container->getParameter('mailer'); // 送信元アカウント情報 if (!isset($mailer[$config['account']])) { throw new \LibraryBundle\Exception\DataNotFoundException($config['account'] . 'を設定してください'); } $account = $mailer[$config['account']]; // 送信者 $setting['from'] = $account['address']; // 返信先 if (isset($account['reply'])) { $setting['reply'] = $account['reply']; } $setting['fromLabel'] = s_empty($account, 'label') ? $account['label'] : null; // 宛先 // force_sendがtrueで設定されていない // 開発環境 or 開発サーバーだったら誤送信防止のためのメールアドレスへ飛ばす if ((!isset($config['force_send']) || $config['force_send'] === false) && (parent::isDevelopment() || parent::isDevelopmentServer())) { if (!isset($mailer['development_to'])) { throw new \LibraryBundle\Exception\DataNotFoundException('parameters.mailer.development_toを設定してください'); } $setting['to'] = $mailer['development_to']; } // 件名 // 件名がどこにもない場合Exception if (is_null($subject) && !s_empty($config, 'subject')) { throw new \LibraryBundle\Exception\DataNotFoundException('subjectを設定してください'); } elseif (is_null($subject) && s_empty($config, 'subject')) { $setting['subject'] = $config['subject']; } // 本文テンプレート $setting['template'] = $config['template']; return $setting; }