Author: Adam Piotrowski (adam@wellcommerce.org)
示例#1
0
 /**
  * Changes mailer configuration on runtime
  *
  * @param MailerConfiguration $mailerConfiguration
  *
  * @return \Swift_Mailer
  */
 protected function createMailer(MailerConfiguration $mailerConfiguration)
 {
     $transport = new \Swift_SmtpTransport();
     $transport->setHost($mailerConfiguration->getHost());
     $transport->setPort($mailerConfiguration->getPort());
     $transport->setUsername($mailerConfiguration->getUser());
     $transport->setPassword($mailerConfiguration->getPass());
     return \Swift_Mailer::newInstance($transport);
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     if (!$this->isEnabled()) {
         return;
     }
     /**
      * @var $theme       \WellCommerce\Bundle\ThemeBundle\Entity\ThemeInterface
      * @var $company     \WellCommerce\Bundle\CompanyBundle\Entity\CompanyInterface
      * @var $orderStatus \WellCommerce\Bundle\OrderBundle\Entity\OrderStatusInterface
      */
     $theme = $this->getReference('theme');
     $company = $this->getReference('company');
     $currency = $this->randomizeSamples('currency', LoadCurrencyData::$samples);
     $shop = $this->container->get('shop.factory')->create();
     $shop->setName('WellCommerce');
     $shop->setCompany($company);
     $shop->setTheme($theme);
     $shop->setUrl($this->container->getParameter('fallback_hostname'));
     $shop->setDefaultCountry('US');
     $shop->setDefaultCurrency($currency->getCode());
     $mailerConfiguration = new MailerConfiguration();
     $mailerConfiguration->setFrom($this->container->getParameter('mailer_from'));
     $mailerConfiguration->setHost($this->container->getParameter('mailer_host'));
     $mailerConfiguration->setPort($this->container->getParameter('mailer_port'));
     $mailerConfiguration->setUser($this->container->getParameter('mailer_user'));
     $mailerConfiguration->setPass($this->container->getParameter('mailer_password'));
     $shop->setMailerConfiguration($mailerConfiguration);
     $manager->persist($shop);
     $manager->flush();
     $this->setReference('shop', $shop);
 }