Example #1
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $factory = $this->container->get('mautic.factory');
     $model = $factory->getModel('email');
     $repo = $model->getRepository();
     $emails = CsvHelper::csv_to_array(__DIR__ . '/fakeemaildata.csv');
     foreach ($emails as $count => $rows) {
         $email = new Email();
         $email->setDateAdded(new \DateTime());
         $key = $count + 1;
         foreach ($rows as $col => $val) {
             if ($val != 'NULL') {
                 $setter = 'set' . ucfirst($col);
                 if (in_array($col, ['content', 'variantSettings'])) {
                     $val = unserialize(stripslashes($val));
                 }
                 $email->{$setter}($val);
             }
         }
         $email->addList($this->getReference('lead-list'));
         $repo->saveEntity($email);
         $this->setReference('email-' . $key, $email);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function addList(\Mautic\LeadBundle\Entity\LeadList $list)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addList', array($list));
     return parent::addList($list);
 }