From 9ce3120f4c8222f8e14cfa3f9b2cb4b0c95828fd Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Fri, 13 Sep 2024 14:36:11 -0500 Subject: [PATCH] FEATURE Getters for contact info via Silverstripe Link --- src/Model/Location.php | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Model/Location.php b/src/Model/Location.php index 90c2eb8..56d08df 100644 --- a/src/Model/Location.php +++ b/src/Model/Location.php @@ -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 @@ -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 @@ -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); + } }