Skip to content

Commit

Permalink
FEATURE Getters for contact info via Silverstripe Link
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish committed Sep 13, 2024
1 parent 093915d commit 9ce3120
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/Model/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

namespace Dynamic\Locations\Model;

use Dynamic\SilverStripeGeocoder\AddressDataExtension;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Forms\FieldList;
use SilverStripe\LinkField\Models\Link;
use SilverStripe\LinkField\Form\MultiLinkField;
use SilverStripe\TagField\TagField;
use SilverStripe\Versioned\Versioned;
use SilverStripe\LinkField\Models\Link;
use SilverStripe\LinkField\Models\EmailLink;
use SilverStripe\LinkField\Models\PhoneLink;
use SilverStripe\LinkField\Form\MultiLinkField;
use Dynamic\SilverStripeGeocoder\AddressDataExtension;
use SilverStripe\LinkField\Models\ExternalLink;

/**
* Class \Dynamic\Elements\Locations\Model\Location
Expand Down Expand Up @@ -56,6 +60,12 @@ class Location extends DataObject
*/
private static string $description = 'A Location DataObject for use with the Locations Element';

/**
* @var string
* @config
*/
private static string $menu_icon_class = 'font-icon-globe-1';

/**
* @var array
* @config
Expand Down Expand Up @@ -172,4 +182,28 @@ public function getCMSFields(): FieldList

return parent::getCMSFields();
}

/**
* @return DataList
*/
public function getPhoneNumbers()
{
return $this->Links()->filter('ClassName', PhoneLink::class);
}

/**
* @return DataList
*/
public function getEmailAddresses()
{
return $this->Links()->filter('ClassName', EmailLink::class);
}

/**
* @return DataList
*/
public function getWebsiteLinks()
{
return $this->Links()->filter('ClassName', ExternalLink::class);
}
}

0 comments on commit 9ce3120

Please sign in to comment.