Ejemplo n.º 1
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $factory = $this->container->get('mautic.factory');
     $repo = $factory->getModel('page.page')->getRepository();
     $hits = CsvHelper::csv_to_array(__DIR__ . '/fakepagehitdata.csv');
     foreach ($hits as $count => $rows) {
         $hit = new Hit();
         foreach ($rows as $col => $val) {
             if ($val != 'NULL') {
                 $setter = 'set' . ucfirst($col);
                 if (in_array($col, ['page', 'ipAddress'])) {
                     $hit->{$setter}($this->getReference($col . '-' . $val));
                 } elseif (in_array($col, ['dateHit', 'dateLeft'])) {
                     $hit->{$setter}(new \DateTime($val));
                 } elseif ($col == 'browserLanguages') {
                     $val = unserialize(stripslashes($val));
                     $hit->{$setter}($val);
                 } else {
                     $hit->{$setter}($val);
                 }
             }
         }
         $repo->saveEntity($hit);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $factory = $this->container->get('mautic.factory');
     $repo = $factory->getModel('page.page')->getRepository();
     $pages = CsvHelper::csv_to_array(__DIR__ . '/fakepagedata.csv');
     foreach ($pages as $count => $rows) {
         $page = new Page();
         $key = $count + 1;
         foreach ($rows as $col => $val) {
             if ($val != 'NULL') {
                 $setter = 'set' . ucfirst($col);
                 if (in_array($col, ['translationParent', 'variantParent'])) {
                     $page->{$setter}($this->getReference('page-' . $val));
                 } elseif (in_array($col, ['dateAdded', 'variantStartDate'])) {
                     $page->{$setter}(new \DateTime($val));
                 } elseif (in_array($col, ['content', 'variantSettings'])) {
                     $val = unserialize(stripslashes($val));
                     $page->{$setter}($val);
                 } else {
                     $page->{$setter}($val);
                 }
             }
         }
         $page->setCategory($this->getReference('page-cat-1'));
         $repo->saveEntity($page);
         $this->setReference('page-' . $key, $page);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $reports = CsvHelper::csv_to_array(__DIR__ . '/fakereportdata.csv');
     foreach ($reports as $count => $rows) {
         $report = new Report();
         $key = $count + 1;
         foreach ($rows as $col => $val) {
             if ($val != "NULL") {
                 $setter = "set" . ucfirst($col);
                 if (in_array($col, array('columns', 'filters', 'graphs', 'tableOrder'))) {
                     $val = unserialize(stripslashes($val));
                 }
                 $report->{$setter}($val);
             }
         }
         $manager->persist($report);
         $this->setReference('report-' . $key, $report);
     }
     $manager->flush();
 }
Ejemplo n.º 4
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $factory = $this->container->get('mautic.factory');
     $leadRepo = $factory->getModel('lead.lead')->getRepository();
     $today = new \DateTime();
     $leads = CsvHelper::csv_to_array(__DIR__ . '/fakeleaddata.csv');
     foreach ($leads as $count => $l) {
         $key = $count + 1;
         $lead = new Lead();
         $lead->setDateAdded($today);
         $ipAddress = new IpAddress();
         $ipAddress->setIpAddress($l['ip'], $factory->getSystemParameters());
         $this->setReference('ipAddress-' . $key, $ipAddress);
         unset($l['ip']);
         $lead->addIpAddress($ipAddress);
         $lead->setOwner($this->getReference('sales-user'));
         foreach ($l as $col => $val) {
             $lead->addUpdatedField($col, $val);
         }
         $leadRepo->saveEntity($lead);
         $this->setReference('lead-' . $count, $lead);
     }
 }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $factory = $this->container->get('mautic.factory');
     $pageModel = $factory->getModel('page.page');
     $repo = $factory->getModel('form.submission')->getRepository();
     $fixture =& $this;
     $importResults = function ($results) use($factory, $pageModel, $repo, &$fixture) {
         foreach ($results as $count => $rows) {
             $submission = new Submission();
             $submission->setDateSubmitted(new \DateTime());
             foreach ($rows as $col => $val) {
                 if ($val != "NULL") {
                     $setter = "set" . ucfirst($col);
                     if (in_array($col, array('form', 'page', 'ipAddress'))) {
                         $entity = $fixture->getReference($col . '-' . $val);
                         if ($col == 'page') {
                             $submission->setReferer($pageModel->generateUrl($entity));
                         }
                         $submission->{$setter}($entity);
                         unset($rows[$col]);
                     } else {
                         //the rest are custom field values
                         break;
                     }
                 }
             }
             $submission->setResults($rows);
             $repo->saveEntity($submission);
         }
     };
     $results = CsvHelper::csv_to_array(__DIR__ . '/fakeresultdata.csv');
     $importResults($results);
     sleep(2);
     $results2 = CsvHelper::csv_to_array(__DIR__ . '/fakeresult2data.csv');
     $importResults($results2);
 }
Ejemplo n.º 7
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $factory = $this->container->get('mautic.factory');
     $model = $factory->getModel('form.form');
     $repo = $model->getRepository();
     $forms = CsvHelper::csv_to_array(__DIR__ . '/fakeformdata.csv');
     $formEntities = array();
     foreach ($forms as $count => $rows) {
         $form = new Form();
         $key = $count + 1;
         foreach ($rows as $col => $val) {
             if ($val != "NULL") {
                 $setter = "set" . ucfirst($col);
                 if (in_array($col, array('dateAdded'))) {
                     $form->{$setter}(new \DateTime($val));
                 } elseif (in_array($col, array('cachedHtml'))) {
                     $val = stripslashes($val);
                     $form->{$setter}($val);
                 } else {
                     $form->{$setter}($val);
                 }
             }
         }
         $repo->saveEntity($form);
         $formEntities[] = $form;
         $this->setReference('form-' . $key, $form);
     }
     //import fields
     $fields = CsvHelper::csv_to_array(__DIR__ . '/fakefielddata.csv');
     $repo = $factory->getModel('form.field')->getRepository();
     foreach ($fields as $count => $rows) {
         $field = new Field();
         foreach ($rows as $col => $val) {
             if ($val != "NULL") {
                 $setter = "set" . ucfirst($col);
                 if (in_array($col, array('form'))) {
                     $form = $this->getReference('form-' . $val);
                     $field->{$setter}($form);
                     $form->addField($count, $field);
                 } elseif (in_array($col, array('customParameters', 'properties'))) {
                     $val = unserialize(stripslashes($val));
                     $field->{$setter}($val);
                 } else {
                     $field->{$setter}($val);
                 }
             }
         }
         $repo->saveEntity($field);
     }
     //import actions
     $actions = CsvHelper::csv_to_array(__DIR__ . '/fakeactiondata.csv');
     $repo = $factory->getModel('form.action')->getRepository();
     foreach ($actions as $count => $rows) {
         $action = new Action();
         foreach ($rows as $col => $val) {
             if ($val != "NULL") {
                 $setter = "set" . ucfirst($col);
                 if (in_array($col, array('form'))) {
                     $action->{$setter}($this->getReference('form-' . $val));
                 } elseif (in_array($col, array('properties'))) {
                     $val = unserialize(stripslashes($val));
                     if ($col == 'settings') {
                         $val['callback'] = stripslashes($val['callback']);
                     }
                     $action->{$setter}($val);
                 } else {
                     $action->{$setter}($val);
                 }
             }
         }
         $repo->saveEntity($action);
     }
     //create the tables
     foreach ($formEntities as $form) {
         //create the HTML
         $model->generateHtml($form);
         //create the schema
         $model->createTableSchema($form, true, true);
     }
 }