/** * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $translator = $this->container->get('translator'); $textfields = array('title', 'firstname', 'lastname', 'company', 'position', 'email', 'phone', 'mobile', 'fax', 'address1', 'address2', 'city', 'state', 'zipcode', 'country', 'website', 'twitter', 'facebook', 'googleplus', 'skype', 'linkedin', 'instagram', 'foursquare'); $leadsSchema = $this->container->get('mautic.factory')->getSchemaHelper('column', 'leads'); foreach ($textfields as $key => $name) { $entity = new LeadField(); $entity->setLabel($translator->trans('mautic.lead.field.' . $name, array(), 'fixtures')); if (in_array($name, array('title', 'company', 'city', 'zipcode'))) { $type = 'lookup'; } elseif ($name == 'country') { $type = 'country'; } elseif ($name == 'state') { $type = 'region'; } elseif (in_array($name, array('phone', 'mobile'))) { $type = 'tel'; } elseif ($name == 'email') { $type = 'email'; $entity->setIsUniqueIdentifer(true); } else { $type = 'text'; } if ($name == 'title') { $entity->setProperties(array("list" => "|Mr|Mrs|Miss")); } $entity->setType($type); $fixed = in_array($name, array('title', 'firstname', 'lastname', 'position', 'company', 'email', 'phone', 'mobile', 'address1', 'address2', 'country', 'city', 'state', 'zipcode')) ? true : false; $entity->setIsFixed($fixed); $entity->setOrder($key + 1); $entity->setAlias($name); $listable = in_array($name, array('address1', 'address2', 'phone', 'mobile', 'fax', 'twitter', 'facebook', 'googleplus', 'skype', 'linkedin', 'foursquare', 'instagram', 'website')) ? false : true; $entity->setIsListable($listable); $shortVisible = in_array($name, array('firstname', 'lastname', 'email')) ? true : false; $entity->setIsShortVisible($shortVisible); $group = in_array($name, array('twitter', 'facebook', 'googleplus', 'skype', 'linkedin', 'instagram', 'foursquare')) ? 'social' : 'core'; $entity->setGroup($group); $manager->persist($entity); $manager->flush(); //add the column to the leads table $leadsSchema->addColumn(array('name' => $name, 'type' => in_array($name, array('email', 'country')) ? 'string' : 'text', 'options' => array('notnull' => false))); $this->addReference('leadfield-' . $name, $entity); } $leadsSchema->executeChanges(); $indexHelper = $this->container->get('mautic.factory')->getSchemaHelper('index', 'leads'); // Add email and country indexes $indexHelper->setName('leads'); $indexHelper->addIndex('email', 'email_search'); $indexHelper->addIndex('country', 'country_search'); $indexHelper->executeChanges(); }
/** * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $fields = FieldModel::$coreFields; $translator = $this->container->get('translator'); $indexesToAdd = []; /** @var ColumnSchemaHelper $leadsSchema */ $leadsSchema = $this->container->get('mautic.schema.helper.factory')->getSchemaHelper('column', 'leads'); $order = 1; foreach ($fields as $alias => $field) { $type = isset($field['type']) ? $field['type'] : 'text'; $entity = new LeadField(); $entity->setLabel($translator->trans('mautic.lead.field.' . $alias, [], 'fixtures')); $entity->setGroup(isset($field['group']) ? $field['group'] : 'core'); $entity->setOrder($order); $entity->setAlias($alias); $entity->setType($type); $entity->setIsUniqueIdentifer(!empty($field['unique'])); $entity->setProperties(isset($field['properties']) ? $field['properties'] : []); $entity->setIsFixed(!empty($field['fixed'])); $entity->setIsListable(!empty($field['listable'])); $entity->setIsShortVisible(!empty($field['short'])); $manager->persist($entity); $manager->flush(); //add the column to the leads table $leadsSchema->addColumn(FieldModel::getSchemaDefinition($alias, $type, $entity->getIsUniqueIdentifier())); $indexesToAdd[] = $alias; $this->addReference('leadfield-' . $alias, $entity); $order++; } $leadsSchema->executeChanges(); /** @var IndexSchemaHelper $indexHelper */ $indexHelper = $this->container->get('mautic.schema.helper.factory')->getSchemaHelper('index', 'leads'); foreach ($indexesToAdd as $name) { $type = isset($fields[$name]['type']) ? $fields[$name]['type'] : 'text'; if ('textarea' != $type) { $indexHelper->addIndex([$name], MAUTIC_TABLE_PREFIX . $name . '_search'); } } // Add an attribution index $indexHelper->addIndex(['attribution', 'attribution_date'], MAUTIC_TABLE_PREFIX . '_contact_attribution'); $indexHelper->executeChanges(); }
/** * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $fieldGroups['lead'] = FieldModel::$coreFields; $fieldGroups['company'] = FieldModel::$coreCompanyFields; $translator = $this->container->get('translator'); $indexesToAdd = []; foreach ($fieldGroups as $object => $fields) { if ($object == 'company') { /** @var ColumnSchemaHelper $companiesSchema */ $schema = $this->container->get('mautic.schema.helper.factory')->getSchemaHelper('column', 'companies'); } else { /** @var ColumnSchemaHelper $companiesSchema */ $schema = $this->container->get('mautic.schema.helper.factory')->getSchemaHelper('column', 'leads'); } $order = 1; foreach ($fields as $alias => $field) { $type = isset($field['type']) ? $field['type'] : 'text'; $entity = new LeadField(); $entity->setLabel($translator->trans('mautic.lead.field.' . $alias, [], 'fixtures')); $entity->setGroup(isset($field['group']) ? $field['group'] : 'core'); $entity->setOrder($order); $entity->setAlias($alias); $entity->setIsRequired(isset($field['required']) ? $field['required'] : false); $entity->setType($type); $entity->setObject($field['object']); $entity->setIsUniqueIdentifer(!empty($field['unique'])); $entity->setProperties(isset($field['properties']) ? $field['properties'] : []); $entity->setIsFixed(!empty($field['fixed'])); $entity->setIsListable(!empty($field['listable'])); $entity->setIsShortVisible(!empty($field['short'])); $manager->persist($entity); $manager->flush(); $schema->addColumn(FieldModel::getSchemaDefinition($alias, $type, $entity->getIsUniqueIdentifier())); $indexesToAdd[$object][] = $alias; $this->addReference('leadfield-' . $alias, $entity); ++$order; } $schema->executeChanges(); } foreach ($indexesToAdd as $object => $indexes) { if ($object == 'company') { /** @var IndexSchemaHelper $indexHelper */ $indexHelper = $this->container->get('mautic.schema.helper.factory')->getSchemaHelper('index', 'companies'); } else { /** @var IndexSchemaHelper $indexHelper */ $indexHelper = $this->container->get('mautic.schema.helper.factory')->getSchemaHelper('index', 'leads'); } foreach ($indexes as $name) { $type = isset($fields[$name]['type']) ? $fields[$name]['type'] : 'text'; if ('textarea' != $type) { $indexHelper->addIndex([$name], $name . '_search'); } } if ($object == 'lead') { // Add an attribution index $indexHelper->addIndex(['attribution', 'attribution_date'], 'contact_attribution'); } else { $indexHelper->addIndex(['companyname', 'companyemail'], 'company_filter'); $indexHelper->addIndex(['companyname', 'companycity', 'companycountry', 'companystate'], 'company_match'); } $indexHelper->executeChanges(); } }
/** * {@inheritDoc} */ public function setGroup($group) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setGroup', array($group)); return parent::setGroup($group); }