Skip to content

Commit

Permalink
Merge pull request #73 from TheDMSGroup/2.15.0-beta2
Browse files Browse the repository at this point in the history
Re-add the getRepository method.
  • Loading branch information
heathdutton authored Dec 11, 2018
2 parents 84e8bcb + f0e1d06 commit 3e5ea91
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Model/OverrideLeadModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace MauticPlugin\MauticExtendedFieldBundle\Model;

use Doctrine\ORM\Mapping\ClassMetadata;
use Mautic\LeadBundle\Entity\CompanyChangeLog;
use Mautic\LeadBundle\Entity\CompanyLead;
use Mautic\LeadBundle\Entity\Lead;
Expand All @@ -19,6 +20,7 @@
use Mautic\LeadBundle\Helper\IdentifyCompanyHelper;
use Mautic\LeadBundle\Model\IpAddressModel;
use Mautic\LeadBundle\Model\LeadModel;
use MauticPlugin\MauticExtendedFieldBundle\Entity\OverrideLeadRepository;

/**
* Class OverrideLeadModel.
Expand All @@ -30,6 +32,39 @@ class OverrideLeadModel extends LeadModel
*/
public $ipAddressModel;

/**
* Alterations to core:
* Returns OverrideLeadRepository.
*
* @return \MauticPlugin\MauticExtendedFieldBundle\Entity\OverrideLeadRepository
*/
public function getRepository()
{
static $repoSetup;
$metastart = new ClassMetadata(Lead::class);
$repo = new OverrideLeadRepository($this->em, $metastart, $this->leadFieldModel);

// The rest of this method functions similar to core (with the exception of avoiding $this->repoSetup):
$repo->setDispatcher($this->dispatcher);
if (!$repoSetup) {
$repoSetup = true;

//set the point trigger model in order to get the color code for the lead
$fields = $this->leadFieldModel->getFieldList(true, false);

$socialFields = (!empty($fields['social'])) ? array_keys($fields['social']) : [];
$repo->setAvailableSocialFields($socialFields);

$searchFields = [];
foreach ($fields as $group => $groupFields) {
$searchFields = array_merge($searchFields, array_keys($groupFields));
}
$repo->setAvailableSearchFields($searchFields);
}

return $repo;
}

/**
* Alterations to core:
* Includes extended objects.
Expand Down

0 comments on commit 3e5ea91

Please sign in to comment.