/** * {@inheritDoc} */ public function getAlias() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAlias', array()); return parent::getAlias(); }
/** * Creates the table structure for form results * * @param Form $entity * @param bool $isNew * @param bool $dropExisting */ public function createTableSchema(Form $entity, $isNew = false, $dropExisting = false) { //create the field as its own column in the leads table $schemaHelper = $this->factory->getSchemaHelper('table'); $name = "form_results_" . $entity->getId() . "_" . $entity->getAlias(); $columns = $this->generateFieldColumns($entity); if ($isNew || !$isNew && !$schemaHelper->checkTableExists($name)) { $schemaHelper->addTable(array('name' => $name, 'columns' => $columns, 'options' => array('primaryKey' => array('submission_id'), 'uniqueIndex' => array('submission_id', 'form_id'))), true, $dropExisting); $schemaHelper->executeChanges(); } else { //check to make sure columns exist $schemaHelper = $this->factory->getSchemaHelper('column', $name); foreach ($columns as $c) { if (!$schemaHelper->checkColumnExists($c['name'])) { $schemaHelper->addColumn($c, false); } } $schemaHelper->executeChanges(); } }
/** * Fetch the form results * * @param Form $form * @param array $options * * @return array * @throws \Doctrine\ORM\NoResultException * @throws \Doctrine\ORM\NonUniqueResultException */ public function getFormResults(Form $form, array $options = array()) { $query = $this->_em->getConnection()->createQueryBuilder(); $query->from(MAUTIC_TABLE_PREFIX . 'form_submissions', 'fs')->select('fr.*')->leftJoin('fs', $this->getResultsTableName($form->getId(), $form->getAlias()), 'fr', 'fr.submission_id = fs.id')->where('fs.form_id = :formId')->setParameter('formId', $form->getId()); if (!empty($options['leadId'])) { $query->andWhere('fs.lead_id = ' . (int) $options['leadId']); } if (!empty($options['formId'])) { $query->andWhere($query->expr()->eq('fs.form_id', ':id'))->setParameter('id', $options['formId']); } if (!empty($options['limit'])) { $query->setMaxResults((int) $options['limit']); } return $query->execute()->fetchAll(); }