From 05559b8bcc4b1accd30cffd09404cc8850e54788 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Wed, 28 Mar 2018 14:03:26 -0500 Subject: [PATCH 01/11] additional get methods --- .../custom/activenet/src/ActivenetClient.php | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/custom/activenet/src/ActivenetClient.php b/modules/custom/activenet/src/ActivenetClient.php index aa73bd9ab8..c9d70a409f 100644 --- a/modules/custom/activenet/src/ActivenetClient.php +++ b/modules/custom/activenet/src/ActivenetClient.php @@ -3,6 +3,7 @@ namespace Drupal\activenet; use GuzzleHttp\Client; +// use Drupal\activenet\ActivenetClientFactory; /** * Class ActivenetClient. @@ -86,15 +87,12 @@ public function __call($method, $args) { $suffix = ''; if (empty($args)) { - $args[] = [ - 'api_key' => $api_key - ]; + $args[]['api_key'] = $api_key; } else { - $args = ['api_key', $api_key]; + $args[0]['api_key'] = $api_key; } $suffix = '?' . http_build_query($args[0], '', '&'); - switch ($method) { case 'makeRequest': throw new ActivenetClientException(sprintf('Please, extend Activenet client!', $method)); @@ -108,8 +106,20 @@ public function __call($method, $args) { case 'getActivities': return $this->makeRequest('get', $base_uri . 'activities' . $suffix); + case 'getActivityTypes': + return $this->makeRequest('get', $base_uri . 'activitytypes' . $suffix); + + case 'getActivityCategories': + return $this->makeRequest('get', $base_uri . 'activitycategories' . $suffix); + + case 'getActivityOtherCategories': + return $this->makeRequest('get', $base_uri . 'activityothercategories' . $suffix); + case 'getFlexRegPrograms': return $this->makeRequest('get', $base_uri . 'flexregprograms' . $suffix); + + case 'getFlexRegProgramTypes': + return $this->makeRequest('get', $base_uri . 'flexregprogramtypes' . $suffix); case 'getMembershipPackages': return $this->makeRequest('get', $base_uri . 'membershippackages' . $suffix); @@ -121,4 +131,11 @@ public function __call($method, $args) { throw new ActivenetClientException(sprintf('Method %s not implemented yet.', $method)); } + public function getActivityDetail($id){ + $settings = \Drupal::config('activenet.settings'); + $base_uri = $settings->get('base_uri'); + $suffix = '?api_key=' . $settings->get('api_key'); + return $this->makeRequest('get', $base_uri . 'activities/' . $id . $suffix); + } + } From 33dee8866954e2291c1c813e3615b974fbe06f41 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Fri, 11 May 2018 13:40:54 -0500 Subject: [PATCH 02/11] update docs with methods --- modules/custom/activenet/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/custom/activenet/README.md b/modules/custom/activenet/README.md index 076459e540..1c3cbcbfcc 100644 --- a/modules/custom/activenet/README.md +++ b/modules/custom/activenet/README.md @@ -13,8 +13,14 @@ print_r($centers); //returns json response of all centers All available methods: ``` getSites() +getCenters() getActivities() +getActivityTypes() +getActivityCategories() +getActivityOtherCategories() getFlexRegPrograms() +getFlexRegProgramTypes() getMembershipPackages() getMembershipCategories() +getActivityDetail($id) ``` From b91e50fb9ffc1ffa801d402fdf497f7b4c909596 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Wed, 16 May 2018 09:01:41 -0500 Subject: [PATCH 03/11] Debug code removed. Using dependency injection for settings. --- .../custom/activenet/src/ActivenetClient.php | 53 ++++++++++++++----- .../activenet/src/ActivenetClientFactory.php | 8 ++- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/modules/custom/activenet/src/ActivenetClient.php b/modules/custom/activenet/src/ActivenetClient.php index c9d70a409f..64affa0241 100644 --- a/modules/custom/activenet/src/ActivenetClient.php +++ b/modules/custom/activenet/src/ActivenetClient.php @@ -2,21 +2,46 @@ namespace Drupal\activenet; +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\ImmutableConfig; use GuzzleHttp\Client; -// use Drupal\activenet\ActivenetClientFactory; /** * Class ActivenetClient. * * @package Drupal\activenet * - * @method mixed getBranches(array $args) - * @method mixed getSessions(array $args) - * @method mixed getPrograms(array $args) - * @method mixed getChildCarePrograms(array $args) - * @method mixed getMembershipTypes(array $args) + * @method mixed getCenters(array $args) + * @method mixed getSites(array $args) + * @method mixed getActivities(array $args) + * @method mixed getActivityTypes(array $args) + * @method mixed getActivityOtherCategories(array $args) + * @method mixed getFlexRegPrograms(array $args) + * @method mixed getFlexRegProgramTypes(array $args) + * @method mixed getMembershipPackages(array $args) + * @method mixed getMembershipCategories(array $args) + * @method mixed getActivityDetail(integer $id) */ class ActivenetClient extends Client implements ActivenetClientInterface { + + /** + * Settings + * + * @var array of settings from config + */ + protected $api_settings; + + /** + * ActivenetClient constructor + * @param array $api_settings + * The api config settings. + */ + + public function setApi(array $api_settings) { + $this->api_settings = $api_settings; + } + + /** * Wrapper for 'request' method. @@ -34,7 +59,6 @@ class ActivenetClient extends Client implements ActivenetClientInterface { * @throws \Drupal\activenet\ActivenetClientException */ private function makeRequest($method, $uri, array $parameters = []) { - try { $response = $this->request($method, $uri, $parameters); @@ -79,10 +103,10 @@ private function makeRequest($method, $uri, array $parameters = []) { * @throws ActivenetClientException. */ public function __call($method, $args) { - $settings = \Drupal::config('activenet.settings'); - $api_key = $settings->get('api_key'); - $base_uri = $settings->get('base_uri'); + if(!$this->api_settings) throw new ActivenetClientException(sprintf('Please inject api settings using "$this->setAPI($api_settings)".')); + $api_key = $this->api_settings['api_key']; + $base_uri = $this->api_settings['base_uri']; // Prepare suffix for the endpoint. $suffix = ''; @@ -131,10 +155,11 @@ public function __call($method, $args) { throw new ActivenetClientException(sprintf('Method %s not implemented yet.', $method)); } - public function getActivityDetail($id){ - $settings = \Drupal::config('activenet.settings'); - $base_uri = $settings->get('base_uri'); - $suffix = '?api_key=' . $settings->get('api_key'); + public function getActivityDetail(integer $id){ + if(!$this->api_settings) throw new ActivenetClientException(sprintf('Please inject api settings using "$this->setAPI($api_settings)".')); + + $base_uri = $this->api_settings['base_uri']; + $suffix = '?api_key=' . $this->api_settings['api_key']; return $this->makeRequest('get', $base_uri . 'activities/' . $id . $suffix); } diff --git a/modules/custom/activenet/src/ActivenetClientFactory.php b/modules/custom/activenet/src/ActivenetClientFactory.php index c9a90c0be8..23a0f49350 100644 --- a/modules/custom/activenet/src/ActivenetClientFactory.php +++ b/modules/custom/activenet/src/ActivenetClientFactory.php @@ -39,7 +39,13 @@ public function get() { 'base_uri' => $settings->get('base_uri'), 'headers' => ['Accept' => 'application/json'], ]; - return new ActivenetClient($config); + $api_config = [ + 'base_uri' => $settings->get('base_uri'), + 'api_key' => $settings->get('api_key'), + ]; + $client = new ActivenetClient($config); + $client->setApi($api_config); + return $client; } } From 4bce999cecae264d0d4276794b34bab53cf04560 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Wed, 16 May 2018 09:04:36 -0500 Subject: [PATCH 04/11] remove unused dependencies --- modules/custom/activenet/src/ActivenetClient.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/custom/activenet/src/ActivenetClient.php b/modules/custom/activenet/src/ActivenetClient.php index 64affa0241..35fb59d804 100644 --- a/modules/custom/activenet/src/ActivenetClient.php +++ b/modules/custom/activenet/src/ActivenetClient.php @@ -2,8 +2,6 @@ namespace Drupal\activenet; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Config\ImmutableConfig; use GuzzleHttp\Client; /** @@ -157,7 +155,7 @@ public function __call($method, $args) { public function getActivityDetail(integer $id){ if(!$this->api_settings) throw new ActivenetClientException(sprintf('Please inject api settings using "$this->setAPI($api_settings)".')); - + $base_uri = $this->api_settings['base_uri']; $suffix = '?api_key=' . $this->api_settings['api_key']; return $this->makeRequest('get', $base_uri . 'activities/' . $id . $suffix); From 5ceff09e7ca12b43c406ac9c07f515bdd5b63a10 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Wed, 28 Mar 2018 14:03:26 -0500 Subject: [PATCH 05/11] additional get methods --- .../custom/activenet/src/ActivenetClient.php | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/custom/activenet/src/ActivenetClient.php b/modules/custom/activenet/src/ActivenetClient.php index aa73bd9ab8..c9d70a409f 100644 --- a/modules/custom/activenet/src/ActivenetClient.php +++ b/modules/custom/activenet/src/ActivenetClient.php @@ -3,6 +3,7 @@ namespace Drupal\activenet; use GuzzleHttp\Client; +// use Drupal\activenet\ActivenetClientFactory; /** * Class ActivenetClient. @@ -86,15 +87,12 @@ public function __call($method, $args) { $suffix = ''; if (empty($args)) { - $args[] = [ - 'api_key' => $api_key - ]; + $args[]['api_key'] = $api_key; } else { - $args = ['api_key', $api_key]; + $args[0]['api_key'] = $api_key; } $suffix = '?' . http_build_query($args[0], '', '&'); - switch ($method) { case 'makeRequest': throw new ActivenetClientException(sprintf('Please, extend Activenet client!', $method)); @@ -108,8 +106,20 @@ public function __call($method, $args) { case 'getActivities': return $this->makeRequest('get', $base_uri . 'activities' . $suffix); + case 'getActivityTypes': + return $this->makeRequest('get', $base_uri . 'activitytypes' . $suffix); + + case 'getActivityCategories': + return $this->makeRequest('get', $base_uri . 'activitycategories' . $suffix); + + case 'getActivityOtherCategories': + return $this->makeRequest('get', $base_uri . 'activityothercategories' . $suffix); + case 'getFlexRegPrograms': return $this->makeRequest('get', $base_uri . 'flexregprograms' . $suffix); + + case 'getFlexRegProgramTypes': + return $this->makeRequest('get', $base_uri . 'flexregprogramtypes' . $suffix); case 'getMembershipPackages': return $this->makeRequest('get', $base_uri . 'membershippackages' . $suffix); @@ -121,4 +131,11 @@ public function __call($method, $args) { throw new ActivenetClientException(sprintf('Method %s not implemented yet.', $method)); } + public function getActivityDetail($id){ + $settings = \Drupal::config('activenet.settings'); + $base_uri = $settings->get('base_uri'); + $suffix = '?api_key=' . $settings->get('api_key'); + return $this->makeRequest('get', $base_uri . 'activities/' . $id . $suffix); + } + } From 80f61b197a2716d66c3fffbe8f4df45122c3e8e0 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Fri, 11 May 2018 13:40:54 -0500 Subject: [PATCH 06/11] update docs with methods --- modules/custom/activenet/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/custom/activenet/README.md b/modules/custom/activenet/README.md index 076459e540..1c3cbcbfcc 100644 --- a/modules/custom/activenet/README.md +++ b/modules/custom/activenet/README.md @@ -13,8 +13,14 @@ print_r($centers); //returns json response of all centers All available methods: ``` getSites() +getCenters() getActivities() +getActivityTypes() +getActivityCategories() +getActivityOtherCategories() getFlexRegPrograms() +getFlexRegProgramTypes() getMembershipPackages() getMembershipCategories() +getActivityDetail($id) ``` From 413b1f06eb27aca8547324c3f35808ef623722c8 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Wed, 16 May 2018 09:01:41 -0500 Subject: [PATCH 07/11] Debug code removed. Using dependency injection for settings. --- .../custom/activenet/src/ActivenetClient.php | 53 ++++++++++++++----- .../activenet/src/ActivenetClientFactory.php | 8 ++- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/modules/custom/activenet/src/ActivenetClient.php b/modules/custom/activenet/src/ActivenetClient.php index c9d70a409f..64affa0241 100644 --- a/modules/custom/activenet/src/ActivenetClient.php +++ b/modules/custom/activenet/src/ActivenetClient.php @@ -2,21 +2,46 @@ namespace Drupal\activenet; +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\ImmutableConfig; use GuzzleHttp\Client; -// use Drupal\activenet\ActivenetClientFactory; /** * Class ActivenetClient. * * @package Drupal\activenet * - * @method mixed getBranches(array $args) - * @method mixed getSessions(array $args) - * @method mixed getPrograms(array $args) - * @method mixed getChildCarePrograms(array $args) - * @method mixed getMembershipTypes(array $args) + * @method mixed getCenters(array $args) + * @method mixed getSites(array $args) + * @method mixed getActivities(array $args) + * @method mixed getActivityTypes(array $args) + * @method mixed getActivityOtherCategories(array $args) + * @method mixed getFlexRegPrograms(array $args) + * @method mixed getFlexRegProgramTypes(array $args) + * @method mixed getMembershipPackages(array $args) + * @method mixed getMembershipCategories(array $args) + * @method mixed getActivityDetail(integer $id) */ class ActivenetClient extends Client implements ActivenetClientInterface { + + /** + * Settings + * + * @var array of settings from config + */ + protected $api_settings; + + /** + * ActivenetClient constructor + * @param array $api_settings + * The api config settings. + */ + + public function setApi(array $api_settings) { + $this->api_settings = $api_settings; + } + + /** * Wrapper for 'request' method. @@ -34,7 +59,6 @@ class ActivenetClient extends Client implements ActivenetClientInterface { * @throws \Drupal\activenet\ActivenetClientException */ private function makeRequest($method, $uri, array $parameters = []) { - try { $response = $this->request($method, $uri, $parameters); @@ -79,10 +103,10 @@ private function makeRequest($method, $uri, array $parameters = []) { * @throws ActivenetClientException. */ public function __call($method, $args) { - $settings = \Drupal::config('activenet.settings'); - $api_key = $settings->get('api_key'); - $base_uri = $settings->get('base_uri'); + if(!$this->api_settings) throw new ActivenetClientException(sprintf('Please inject api settings using "$this->setAPI($api_settings)".')); + $api_key = $this->api_settings['api_key']; + $base_uri = $this->api_settings['base_uri']; // Prepare suffix for the endpoint. $suffix = ''; @@ -131,10 +155,11 @@ public function __call($method, $args) { throw new ActivenetClientException(sprintf('Method %s not implemented yet.', $method)); } - public function getActivityDetail($id){ - $settings = \Drupal::config('activenet.settings'); - $base_uri = $settings->get('base_uri'); - $suffix = '?api_key=' . $settings->get('api_key'); + public function getActivityDetail(integer $id){ + if(!$this->api_settings) throw new ActivenetClientException(sprintf('Please inject api settings using "$this->setAPI($api_settings)".')); + + $base_uri = $this->api_settings['base_uri']; + $suffix = '?api_key=' . $this->api_settings['api_key']; return $this->makeRequest('get', $base_uri . 'activities/' . $id . $suffix); } diff --git a/modules/custom/activenet/src/ActivenetClientFactory.php b/modules/custom/activenet/src/ActivenetClientFactory.php index c9a90c0be8..23a0f49350 100644 --- a/modules/custom/activenet/src/ActivenetClientFactory.php +++ b/modules/custom/activenet/src/ActivenetClientFactory.php @@ -39,7 +39,13 @@ public function get() { 'base_uri' => $settings->get('base_uri'), 'headers' => ['Accept' => 'application/json'], ]; - return new ActivenetClient($config); + $api_config = [ + 'base_uri' => $settings->get('base_uri'), + 'api_key' => $settings->get('api_key'), + ]; + $client = new ActivenetClient($config); + $client->setApi($api_config); + return $client; } } From 0ed64e39fc6611ca9dc9d461725a528a8827949a Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Wed, 16 May 2018 09:04:36 -0500 Subject: [PATCH 08/11] remove unused dependencies --- modules/custom/activenet/src/ActivenetClient.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/custom/activenet/src/ActivenetClient.php b/modules/custom/activenet/src/ActivenetClient.php index 64affa0241..35fb59d804 100644 --- a/modules/custom/activenet/src/ActivenetClient.php +++ b/modules/custom/activenet/src/ActivenetClient.php @@ -2,8 +2,6 @@ namespace Drupal\activenet; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Config\ImmutableConfig; use GuzzleHttp\Client; /** @@ -157,7 +155,7 @@ public function __call($method, $args) { public function getActivityDetail(integer $id){ if(!$this->api_settings) throw new ActivenetClientException(sprintf('Please inject api settings using "$this->setAPI($api_settings)".')); - + $base_uri = $this->api_settings['base_uri']; $suffix = '?api_key=' . $this->api_settings['api_key']; return $this->makeRequest('get', $base_uri . 'activities/' . $id . $suffix); From 48def6a2a770255da5d5a0f9febb6516788f530c Mon Sep 17 00:00:00 2001 From: Aaron Christian Date: Fri, 24 Aug 2018 13:36:49 -0700 Subject: [PATCH 09/11] OS-160: Fixes a display bug in the main navigation. Adds collapsing support for the main navigation on window.resize(). --- .../openy_carnation/dist/css/style.css | 1 + .../openy_carnation/src/js/openy_carnation.js | 48 +++++++++++-------- .../src/scss/modules/_menu.scss | 2 +- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/themes/openy_themes/openy_carnation/dist/css/style.css b/themes/openy_themes/openy_carnation/dist/css/style.css index 78cd6a1d2a..e6180f6402 100644 --- a/themes/openy_themes/openy_carnation/dist/css/style.css +++ b/themes/openy_themes/openy_carnation/dist/css/style.css @@ -11014,6 +11014,7 @@ a[href="#step2"] { height: 0; } .nav-home .dropdown-menu.show { display: flex; + flex-wrap: wrap; height: auto; } .viewport .page-head__main-menu .nav-level-2 { diff --git a/themes/openy_themes/openy_carnation/src/js/openy_carnation.js b/themes/openy_themes/openy_carnation/src/js/openy_carnation.js index 15a827bfdc..d8f8032562 100644 --- a/themes/openy_themes/openy_carnation/src/js/openy_carnation.js +++ b/themes/openy_themes/openy_carnation/src/js/openy_carnation.js @@ -14,7 +14,7 @@ attach: function (context, settings) { var alertModals = $('.alert-modal', context); - $(window).on('load',function() { + $(window).on('load', function () { if (alertModals.length) { alertModals.modal('show'); } @@ -31,7 +31,8 @@ if (bannerHeader.length > 0) { $('.banner-zone-node').once('openy-move-banners').append(bannerHeader.eq(0)); $('body').addClass('with-banner'); - } else { + } + else { $('body').addClass('without-banner'); } } @@ -80,7 +81,7 @@ searchBtn.once('openy-search-toggle-hide').on('click', function () { mainMenuLinks.removeClass('show').addClass('fade'); - setTimeout(function() { + setTimeout(function () { searchInput.focus(); }, 500); }); @@ -97,14 +98,21 @@ Drupal.behaviors.openyMobileMenu = { attach: function (context, settings) { var sidebar = $('#sidebar'); - var $target = $('.top-navs'); + var topNav = $('.top-navs'); sidebar.on('show.bs.collapse', function () { - $target.addClass('menu-in'); + topNav.addClass('menu-in'); }); sidebar.on('hide.bs.collapse', function () { - $target.removeClass('menu-in'); + topNav.removeClass('menu-in'); + }); + + $(window).resize(function() { + if($(window).width() > 991) { + topNav.removeClass('menu-in'); + sidebar.collapse('hide'); + } }); } }; @@ -129,11 +137,12 @@ */ Drupal.behaviors.openyHeaderAffix = { attach: function (context, settings) { - $(window).once('openy-affix', context).on('scroll', function(event) { + $(window).once('openy-affix', context).on('scroll', function (event) { var scrollValue = $(window).scrollTop(); if (scrollValue === settings.scrollTopPx || scrollValue > 1) { $('.top-navs').addClass('affix'); - } else if (scrollValue === settings.scrollTopPx || scrollValue < 1) { + } + else if (scrollValue === settings.scrollTopPx || scrollValue < 1) { $('.top-navs').removeClass('affix'); } }); @@ -188,7 +197,8 @@ $this.attr('type', 'password'); $this.removeClass("show"); $(this).removeClass("btn-outline-primary"); - } else { + } + else { $this.attr('type', 'text'); $this.val($("#passeye-" + i).val()); $this.addClass("show"); @@ -237,7 +247,7 @@ */ Drupal.behaviors.openySubCategoryClassesTheme = { attach: function (context, settings) { - $('.sub-category-classes-view').once().each(function() { + $('.sub-category-classes-view').once().each(function () { var view = $(this); // Initialize Slick. @@ -249,8 +259,8 @@ slidesToScroll: 3, prevArrow: '', nextArrow: '', - customPaging: function(slider, i) { - return ''; + customPaging: function (slider, i) { + return ''; }, responsive: [ { @@ -278,15 +288,15 @@ // Filters actions. view.find('.add-filters') - .on('click', function(e) { + .on('click', function (e) { e.preventDefault(); view.find('.selects-container, .actions-wrapper').removeClass('hidden-xs'); view.find('.close-filters').removeClass('hidden'); view.find('.filters-container').addClass('hidden'); $(this).addClass('hidden'); - }); + }); view.find('.close-filters') - .on('click', function(e) { + .on('click', function (e) { e.preventDefault(); view.find('.selects-container, .actions-wrapper').addClass('hidden-xs'); view.find('.add-filters').removeClass('hidden'); @@ -295,7 +305,7 @@ }); view.find('.js-form-type-select select') - .change(function() { + .change(function () { if ($(window).width() > 767) { view.find('.js-form-type-select select').attr('readonly', true); view.find('form .form-actions input:eq(0)').trigger('click'); @@ -303,7 +313,7 @@ }); view.find('.filter .remove') - .on('click', function(e) { + .on('click', function (e) { e.preventDefault(); view.parents('.filter').remove(); view.find('select option[value="' + $(this).data('id') + '"]').attr('selected', false); @@ -315,9 +325,9 @@ }); view.find('.clear') - .on('click', function(e) { + .on('click', function (e) { e.preventDefault(); - view.find('.filters-container').find('a.remove').each(function() { + view.find('.filters-container').find('a.remove').each(function () { view.find('select option[value="' + $(this).data('id') + '"]').attr('selected', false); }); view.find('.js-form-type-select select').attr('readonly', true); diff --git a/themes/openy_themes/openy_carnation/src/scss/modules/_menu.scss b/themes/openy_themes/openy_carnation/src/scss/modules/_menu.scss index 4ac48082c8..85ed0751fb 100644 --- a/themes/openy_themes/openy_carnation/src/scss/modules/_menu.scss +++ b/themes/openy_themes/openy_carnation/src/scss/modules/_menu.scss @@ -68,12 +68,12 @@ &.show { display: flex; + flex-wrap: wrap; height: auto; } } } - .viewport { .page-head__main-menu { .nav-level-2 { From 66771fa8d39edc9a7f822f76afe51794c403b034 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Thu, 13 Sep 2018 12:59:43 -0500 Subject: [PATCH 10/11] pull in max results --- modules/custom/activenet/src/ActivenetClientFactory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 modules/custom/activenet/src/ActivenetClientFactory.php diff --git a/modules/custom/activenet/src/ActivenetClientFactory.php b/modules/custom/activenet/src/ActivenetClientFactory.php old mode 100644 new mode 100755 index 23a0f49350..905a6a4ac8 --- a/modules/custom/activenet/src/ActivenetClientFactory.php +++ b/modules/custom/activenet/src/ActivenetClientFactory.php @@ -37,7 +37,10 @@ public function get() { $settings = $this->configFactory->get('activenet.settings'); $config = [ 'base_uri' => $settings->get('base_uri'), - 'headers' => ['Accept' => 'application/json'], + 'headers' => [ + 'Accept' => 'application/json', + 'page_info' => '{"total_records_per_page":200}', + ], ]; $api_config = [ 'base_uri' => $settings->get('base_uri'), From 51db7c9db27b7e9cfd9e6ae4b87f97b4e6623e28 Mon Sep 17 00:00:00 2001 From: mattshoaf Date: Thu, 13 Sep 2018 13:02:39 -0500 Subject: [PATCH 11/11] activenet_registration module --- .../activenet_registration.info.yml | 8 + .../activenet_registration.module | 53 ++++++ .../activenet_registration.permissions.yml | 2 + .../activenet_registration.routing.yml | 7 + .../activenet_registration.services.yml | 12 ++ .../activenet_registration.settings.yml | 1 + .../src/DataStorage.php | 143 +++++++++++++++ .../src/DataStorageInterface.php | 10 ++ .../src/Form/SettingsForm.php | 65 +++++++ .../ActiveRegisterFormatter.php | 151 ++++++++++++++++ .../Field/FieldFormatter/SitesFormatter.php | 46 +++++ .../Field/FieldType/ActiveRegisterItem.php | 104 +++++++++++ .../src/Plugin/Field/FieldType/SitesItem.php | 46 +++++ .../FieldWidget/ActiveRegisterWidget.php | 170 ++++++++++++++++++ .../Plugin/Field/FieldWidget/SitesWidget.php | 75 ++++++++ .../activenet-activity-registration.html.twig | 19 ++ .../activenet-flex-registration.html.twig | 14 ++ .../templates/activenet-site.html.twig | 7 + 18 files changed, 933 insertions(+) create mode 100755 modules/custom/activenet_registration/activenet_registration.info.yml create mode 100755 modules/custom/activenet_registration/activenet_registration.module create mode 100755 modules/custom/activenet_registration/activenet_registration.permissions.yml create mode 100755 modules/custom/activenet_registration/activenet_registration.routing.yml create mode 100755 modules/custom/activenet_registration/activenet_registration.services.yml create mode 100755 modules/custom/activenet_registration/config/install/activenet_registration.settings.yml create mode 100755 modules/custom/activenet_registration/src/DataStorage.php create mode 100755 modules/custom/activenet_registration/src/DataStorageInterface.php create mode 100755 modules/custom/activenet_registration/src/Form/SettingsForm.php create mode 100755 modules/custom/activenet_registration/src/Plugin/Field/FieldFormatter/ActiveRegisterFormatter.php create mode 100755 modules/custom/activenet_registration/src/Plugin/Field/FieldFormatter/SitesFormatter.php create mode 100755 modules/custom/activenet_registration/src/Plugin/Field/FieldType/ActiveRegisterItem.php create mode 100755 modules/custom/activenet_registration/src/Plugin/Field/FieldType/SitesItem.php create mode 100755 modules/custom/activenet_registration/src/Plugin/Field/FieldWidget/ActiveRegisterWidget.php create mode 100755 modules/custom/activenet_registration/src/Plugin/Field/FieldWidget/SitesWidget.php create mode 100755 modules/custom/activenet_registration/templates/activenet-activity-registration.html.twig create mode 100755 modules/custom/activenet_registration/templates/activenet-flex-registration.html.twig create mode 100755 modules/custom/activenet_registration/templates/activenet-site.html.twig diff --git a/modules/custom/activenet_registration/activenet_registration.info.yml b/modules/custom/activenet_registration/activenet_registration.info.yml new file mode 100755 index 0000000000..f3b25c60e6 --- /dev/null +++ b/modules/custom/activenet_registration/activenet_registration.info.yml @@ -0,0 +1,8 @@ +name: ActiveNet Registration +type: module +descripton: Provide a entity for creating Active Community registrations +core: 8.x +package: OpenY +dependencies: + - activenet:activenet + - openy_socrates:openy_socrates diff --git a/modules/custom/activenet_registration/activenet_registration.module b/modules/custom/activenet_registration/activenet_registration.module new file mode 100755 index 0000000000..bcbed0cd54 --- /dev/null +++ b/modules/custom/activenet_registration/activenet_registration.module @@ -0,0 +1,53 @@ +' . t('Active Net Registration for communities') . ''; + $output .= '

' . t('Instructions about selections go here.') . '

'; + } +} + + +/** + * Implements hook_theme(). + */ +function activenet_registration_theme($existing, $type, $theme, $path) { + return [ + 'activenet_activity_registration' => [ + 'variables' => [ + 'name' => NULL, + 'registration_url' => NULL, + 'gender' => NULL, + 'site_name' => NULL, + 'date_start' => NULL, + 'date_end' => NULL, + 'date_pattern' => NULL, + ], + ], + 'activenet_flex_registration' =>[ + 'variables' => [ + 'name' => NULL, + 'registration_url' => NULL, + 'gender' => NULL, + 'site_name' => NULL, + ], + ], + 'activenet_site' =>[ + 'variables' => [ + 'site_id' => NULL, + 'site_name' => NULL, + ], + ], + ]; +} diff --git a/modules/custom/activenet_registration/activenet_registration.permissions.yml b/modules/custom/activenet_registration/activenet_registration.permissions.yml new file mode 100755 index 0000000000..92da197000 --- /dev/null +++ b/modules/custom/activenet_registration/activenet_registration.permissions.yml @@ -0,0 +1,2 @@ +administer activenet registrations: + title: 'Administer ActiveNet registrations' diff --git a/modules/custom/activenet_registration/activenet_registration.routing.yml b/modules/custom/activenet_registration/activenet_registration.routing.yml new file mode 100755 index 0000000000..8b6cb6f1c0 --- /dev/null +++ b/modules/custom/activenet_registration/activenet_registration.routing.yml @@ -0,0 +1,7 @@ +activenet_registration.settings: + path: '/admin/config/services/activenet/registration' + defaults: + _form: '\Drupal\activenet_registration\Form\SettingsForm' + _title: 'ActiveNet Communities Registration settings' + requirements: + _permission: 'administer activenet registration' diff --git a/modules/custom/activenet_registration/activenet_registration.services.yml b/modules/custom/activenet_registration/activenet_registration.services.yml new file mode 100755 index 0000000000..6d2264bf3d --- /dev/null +++ b/modules/custom/activenet_registration/activenet_registration.services.yml @@ -0,0 +1,12 @@ +services: + activenet_registration.cache: + class: Drupal\Core\Cache\CacheBackendInterface + factory: cache_factory:get + arguments: [activenet_registration] + activenet_registration.datastorage: + class: Drupal\activenet_registration\DataStorage + arguments: ['@activenet.client', '@activenet_registration.cache', '@config.factory'] + tags: + - + name: openy_cron_service + periodicity: 60 diff --git a/modules/custom/activenet_registration/config/install/activenet_registration.settings.yml b/modules/custom/activenet_registration/config/install/activenet_registration.settings.yml new file mode 100755 index 0000000000..69bb07f10a --- /dev/null +++ b/modules/custom/activenet_registration/config/install/activenet_registration.settings.yml @@ -0,0 +1 @@ +base_uri: '' diff --git a/modules/custom/activenet_registration/src/DataStorage.php b/modules/custom/activenet_registration/src/DataStorage.php new file mode 100755 index 0000000000..a9f5a163e7 --- /dev/null +++ b/modules/custom/activenet_registration/src/DataStorage.php @@ -0,0 +1,143 @@ +resetCache(); + $this->warmCache(); + \Drupal::logger('ActiveNet Registration')->info("Cron service run succeeded. New API call made."); + } + + /** + * DataStorage constructor. + * + * @param \Drupal\activenet\ActivenetClient $client + * Daxko client. + * @param \Drupal\Core\Cache\CacheBackendInterface $cache + * Cache backend. + * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory + */ + public function __construct(ActivenetClient $client, CacheBackendInterface $cache, ConfigFactoryInterface $config_factory) { + $this->client = $client; + $this->cache = $cache; + $this->configFactory = $config_factory; + } + + /** + * Delete all caches. + */ + public function resetCache() { + $this->cache->deleteAll(); + } + + /** + * Warm up all cache. + * + * @ingroup cache + */ + public function warmCache() { + $this->getSites(); + $this->getProgramTypes(); + $this->getActivityTypes(); + $this->getCategories(); + $this->getOtherCategories(); + } + + public function getSites() { + $cid = __METHOD__; + if ($cache = $this->cache->get($cid)) { + return $cache->data; + } + + $sites = $this->client->getSites(); + $this->cache->set($cid, $sites); + + return $sites; + } + + public function getProgramTypes() { + $cid = __METHOD__; + if ($cache = $this->cache->get($cid)) { + return $cache->data; + } + + $programs = $this->client->getFlexRegProgramTypes(); + $this->cache->set($cid, $programs); + + return $programs; + } + + public function getActivityTypes() { + $cid = __METHOD__; + if ($cache = $this->cache->get($cid)) { + return $cache->data; + } + + $sites = $this->client->getActivityTypes(); + $this->cache->set($cid, $sites); + + return $sites; + } + + public function getCategories() { + $cid = __METHOD__; + if ($cache = $this->cache->get($cid)) { + return $cache->data; + } + + $sites = $this->client->getActivityCategories(); + $this->cache->set($cid, $sites); + + return $sites; + } + + public function getOtherCategories() { + $cid = __METHOD__; + if ($cache = $this->cache->get($cid)) { + return $cache->data; + } + + $sites = $this->client->getActivityOtherCategories(); + $this->cache->set($cid, $sites); + + return $sites; + } + +} diff --git a/modules/custom/activenet_registration/src/DataStorageInterface.php b/modules/custom/activenet_registration/src/DataStorageInterface.php new file mode 100755 index 0000000000..1bb27668ae --- /dev/null +++ b/modules/custom/activenet_registration/src/DataStorageInterface.php @@ -0,0 +1,10 @@ +config('activenet_registration.settings'); + + $form_state->setCached(FALSE); + + $form['base_uri'] = [ + '#type' => 'url', + '#title' => $this->t('Active Communities base URL'), + '#default_value' => $config->get('base_uri'), + '#description' => t('Your Activity Communities base URL. It follows the format of https://apm.activecommunities.com/{organization name}.'), + ]; + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + /* @var $config \Drupal\Core\Config\Config */ + $config = $this->configFactory->getEditable('activenet_registration.settings'); + + $config->set('api_key', $form_state->getValue('api_key'))->save(); + if ($base_uri = $form_state->getValue('base_uri')) { + if (preg_match("#https?://#", $base_uri) === 0) { + $base_uri = 'https://' . $base_uri; + } + $config->set('base_uri', rtrim($base_uri, '/') . '/')->save(); + } + + parent::submitForm($form, $form_state); + } + +} diff --git a/modules/custom/activenet_registration/src/Plugin/Field/FieldFormatter/ActiveRegisterFormatter.php b/modules/custom/activenet_registration/src/Plugin/Field/FieldFormatter/ActiveRegisterFormatter.php new file mode 100755 index 0000000000..ebb83a6083 --- /dev/null +++ b/modules/custom/activenet_registration/src/Plugin/Field/FieldFormatter/ActiveRegisterFormatter.php @@ -0,0 +1,151 @@ +get(); + + $elements = []; + + $this->base_uri = \Drupal::config('activenet_registration.settings')->get('base_uri'); + + foreach ($items as $delta => $item) { + foreach($item as $param => $value) { + if(@$value->getValue()) { + switch($param) { + case 'site': + $args['site_ids'] = $value->getValue(); + break; + case 'program_type': + if($item->activity_flex == 'flex_reg') $args['program_type_id'] = $value->getValue(); + break; + case 'activity_type': + if($item->activity_flex == 'activity') $args['activity_type_id'] = $value->getValue(); + break; + case 'category': + $args['category_id'] = $value->getValue(); + break; + case 'other_category': + $args['other_category_id'] = $value->getValue(); + break; + case 'gender': + if($value->getValue() < 12) $args['gender'] = $value->getValue(); + break; + case 'activity_name': + ($item->activity_flex == 'activity' ? $args['activity_name'] = $value->getValue() : $args['program_name'] = $value->getValue()); + break; + } + } + } + + switch($item->activity_flex) { + case 'activity': + $args['activity_status_id'] = 0; + $args['first_date_range_from'] = date('Y-m-d', time() - (7 * 24 * 60 * 60)); + $activites = $client->getActivities($args); + $daysOfTheWeek ='/Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday/'; + + foreach($activites as $key => $activity){ + $start_date = new DrupalDateTime($activity->default_beginning_date); + $end_date = new DrupalDateTime($activity->default_ending_date); + preg_match_all($daysOfTheWeek, $activity->default_pattern_dates, $day_matches); + preg_match('/\d+:\d+ [APM]+/', $activity->default_pattern_dates, $start_time_match); + preg_match('/\d+h\d+m|\d+h|\d+m/', $activity->default_pattern_dates, $duration_match); + if(preg_match('/\d+h\d+m/', $duration_match[0])) { + $duration = preg_replace("/(\d+)h(\d+)m/", "+$1 hours $2 minutes", $duration_match[0]); + } + elseif(preg_match('/\d+h/', $duration_match[0])) { + $duration = preg_replace("/(\d+)h/", "+$1 hours", $duration_match[0]); + } + else { + $duration = preg_replace("/(\d+)m/", "+$1 minutes", $duration_match[0]); + } + $end_time = new DrupalDateTime($start_time_match[0]); + $end_time->modify($duration); + $date_pattern = $start_time_match[0] . ' - ' . $end_time->format('g:i A') . ', '; + foreach($day_matches[0] as $key => $day) { + if($key != 0 ) $date_pattern .= ', '; + $date_pattern .= $day; + } + $element = [ + '#theme' => 'activenet_activity_registration', + '#name' => $activity->activity_name, + '#registration_url' => $this->base_uri . 'Activity_Search/' . $activity->activity_id, + '#gender' => $activity->gender, + '#site_name' => $activity->site_name, + '#date_start' => $start_date->format('M j'), + '#date_end' => $end_date->format('M j'), + '#date_pattern' => $date_pattern, + '#cache' => [ + 'tags' => ['site:' . $activity->site_name, 'activity_id:' . $activity->activity_id], + 'keys' => ['activenet_registration', $activity->activity_id], + 'max-age' => 86400, + 'context' => 'route.name', + ], + ]; + + $elements[] = $element; + } + break; + + case 'flex': + $args['program_status_id'] = 0; + try{ + $programs = $client->getFlexRegPrograms($args); + foreach($programs as $key => $program){ + $element = [ + '#theme' => 'activenet_flex_registration', + '#name' => $program->program_name, + '#registration_url' => $this->base_uri . 'ActiveNet_Home?FileName=onlineDCProgramDetail.sdi&dcprogram_id=' . $program->program_id, + '#gender' => ['#markup' => '
' . $program->gender . '
'], + '#site_name' => $program->site_name, + '#cache' => [ + 'tags' => ['site:' . $program->site_name, 'program_id:' . $program->program_id], + 'keys' => ['activenet_registration', $program->program_id], + 'max-age' => 86400, + 'context' => 'route.name', + ], + ]; + $elements[] = $element; + } + } + catch(\Exception $e) { + + } + break; + } + + } + + return $elements; + } +} \ No newline at end of file diff --git a/modules/custom/activenet_registration/src/Plugin/Field/FieldFormatter/SitesFormatter.php b/modules/custom/activenet_registration/src/Plugin/Field/FieldFormatter/SitesFormatter.php new file mode 100755 index 0000000000..b05a69fdeb --- /dev/null +++ b/modules/custom/activenet_registration/src/Plugin/Field/FieldFormatter/SitesFormatter.php @@ -0,0 +1,46 @@ +getSites(); + + if(@$items[0]->getValue()['site']){ + $selectedSiteId = $items[0]->getValue()['site']; + + foreach($all_sites as $key => $site_array) { + if($site_array->site_id == $selectedSiteId) { + return [ + '#theme' => 'activenet_site', + '#site_id' => $selectedSiteId, + '#site_name' => $site_array->site_name, + ]; + } + } + } + else { + return []; + } + } +} diff --git a/modules/custom/activenet_registration/src/Plugin/Field/FieldType/ActiveRegisterItem.php b/modules/custom/activenet_registration/src/Plugin/Field/FieldType/ActiveRegisterItem.php new file mode 100755 index 0000000000..637fdcadd5 --- /dev/null +++ b/modules/custom/activenet_registration/src/Plugin/Field/FieldType/ActiveRegisterItem.php @@ -0,0 +1,104 @@ +setlabel(t('Activity/FlexReg')); + + $properties['activity_name'] = DataDefinition::create('string') + ->setlabel(t('Activity/Program Name')); + + // properites are all initiated as strings, due to a bug that won't allow null integers, https://www.drupal.org/project/drupal/issues/2925445#comment-12539383 + $properties['site'] = DataDefinition::create('string') + ->setLabel(t('Site')); + + $properties['program_type'] = DataDefinition::create('string') + ->setLabel(t('Program Type')); + + $properties['activity_type'] = DataDefinition::create('string') + ->setLabel(t('Activity Type')); + + $properties['category'] = DataDefinition::create('string') + ->setLabel(t('Category')); + + $properties['other_category'] = DataDefinition::create('string') + ->setLabel(t('Other Category')); + + $properties['gender'] = DataDefinition::create('string') + ->setLabel(t('Gender')); + + return $properties; + } + + /** + * {@inheritdoc} + */ + public static function schema(FieldStorageDefinitionInterface $field_definition) { + + $schema['columns']['activity_flex'] = [ + 'description' => 'Activity or Flex Registration type', + 'type' => 'varchar', + 'length' => 255, + ]; + + $schema['columns']['site'] = [ + 'description' => 'Site ID', + 'type' => 'int', + ]; + + $schema['columns']['activity_name'] = [ + 'description' => 'Activity Name', + 'type' => 'varchar', + 'length' => 255, + ]; + + $schema['columns']['program_type'] = [ + 'description' => 'Program type ID', + 'type' => 'int', + ]; + + $schema['columns']['activity_type'] = [ + 'description' => 'Program type ID', + 'type' => 'int', + ]; + + $schema['columns']['category'] = [ + 'description' => 'Category ID', + 'type' => 'int', + ]; + + $schema['columns']['other_category'] = [ + 'description' => 'Other Category ID', + 'type' => 'int', + ]; + + $schema['columns']['gender'] = [ + 'description' => 'Gender ID', + 'type' => 'int', + ]; + + return $schema; + } + +} diff --git a/modules/custom/activenet_registration/src/Plugin/Field/FieldType/SitesItem.php b/modules/custom/activenet_registration/src/Plugin/Field/FieldType/SitesItem.php new file mode 100755 index 0000000000..0e0174f791 --- /dev/null +++ b/modules/custom/activenet_registration/src/Plugin/Field/FieldType/SitesItem.php @@ -0,0 +1,46 @@ +setLabel(t('Site')); + + return $properties; + } + + /** + * {@inheritdoc} + */ + public static function schema(FieldStorageDefinitionInterface $field_definition) { + + $schema['columns']['site'] = [ + 'description' => 'Site ID', + 'type' => 'int', + ]; + + return $schema; + } + +} diff --git a/modules/custom/activenet_registration/src/Plugin/Field/FieldWidget/ActiveRegisterWidget.php b/modules/custom/activenet_registration/src/Plugin/Field/FieldWidget/ActiveRegisterWidget.php new file mode 100755 index 0000000000..47b23d915e --- /dev/null +++ b/modules/custom/activenet_registration/src/Plugin/Field/FieldWidget/ActiveRegisterWidget.php @@ -0,0 +1,170 @@ +storage = \Drupal::service('activenet_registration.datastorage'); + parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings); + } + + /** + * {@inheritdoc} + */ + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { + $item = $items->get($delta); + + $element['activity_flex'] = [ + '#title' => t('Activity/flex'), + '#type' => 'select', + '#empty_option' => '- Select Type -', + '#default_value' => isset($item->activity_flex) ? $item->activity_flex : '', + '#options' => [ + 'activity' => 'Activity', + 'flex' => 'Flex Reg Program', + ], + ]; + + $element['site'] = [ + '#title' => t('Site'), + '#type' => 'select', + '#empty_option' => '- Select Site -', + '#default_value' => isset($item->site) ? $item->site : '', + '#options' => $this->sitesSelect($this->storage->getSites()), + ]; + + $element['activity_name'] = [ + '#title' => t('Activity/Program Name'), + '#type' => 'textfield', + '#default_value' => isset($item->activity_name) ? $item->activity_name : '', + '#size' => 60, + '#maxlength' => 255, + '#description' => 'Names that fully or partially match the entered text', + ]; + + $element['program_type'] = [ + '#title' => t('Program type'), + '#type' => 'select', + '#empty_option' => '- Select Program Type -', + '#default_value' => isset($item->program_type) ? $item->program_type : '', + '#options' => $this->programSelect($this->storage->getProgramTypes()), + '#description' => 'Only used with Flex Registration Programs', + ]; + + $element['activity_type'] = [ + '#title' => t('Activity type'), + '#type' => 'select', + '#empty_option' => '- Select Activity Type -', + '#default_value' => isset($item->activity_type) ? $item->activity_type : '', + '#options' => $this->activitySelect($this->storage->getActivityTypes()), + '#description' => 'Only used with Activity registrations', + ]; + + $element['category'] = [ + '#title' => t("Category"), + '#type' => 'select', + '#empty_option' => '- Select Category -', + '#default_value' => isset($item->category) ? $item->category : '', + '#options' => $this->categorySelect($this->storage->getCategories()), + ]; + + $element['other_category'] = [ + '#title' => t("Other Category"), + '#type' => 'select', + '#empty_option' => '- Select Category -', + '#default_value' => isset($item->other_category) ? $item->other_category : '', + '#options' => $this->otherCategorySelect($this->storage->getOtherCategories()), + ]; + + $element['gender'] = [ + '#title' => t("Gender"), + '#type' => 'select', + '#default_value' => isset($item->gender) ? $item->gender : 12, + '#options' => [ + 12 => '- Select Gender -', //workaround for 0 being a valid gender selection + 0 => 'Coed', + 1 => 'Male', + 2 => 'Female', + ], + ]; + + return $element; + } + + private function sitesSelect($sites) { + foreach($sites as $site) { + $select[$site->site_id] = $site->site_name; + } + return $select; + } + + private function programSelect($programs) { + foreach($programs as $program) { + $select[$program->program_type_id] = $program->program_type_name; + } + return $select; + } + + private function activitySelect($activities) { + foreach($activities as $activity) { + $select[$activity->activity_type_id] = $activity->activity_type_name; + } + return $select; + } + + private function categorySelect($categories) { + foreach($categories as $category) { + $select[$category->category_id] = $category->activity_category_name; + } + return $select; + } + + private function otherCategorySelect($categories) { + foreach($categories as $category) { + $select[$category->other_category_id] = $category->other_category_name; + } + return $select; + } + +} diff --git a/modules/custom/activenet_registration/src/Plugin/Field/FieldWidget/SitesWidget.php b/modules/custom/activenet_registration/src/Plugin/Field/FieldWidget/SitesWidget.php new file mode 100755 index 0000000000..7601142b79 --- /dev/null +++ b/modules/custom/activenet_registration/src/Plugin/Field/FieldWidget/SitesWidget.php @@ -0,0 +1,75 @@ +storage = \Drupal::service('activenet_registration.datastorage'); + parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings); + } + + /** + * {@inheritdoc} + */ + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { + $item = $items->get($delta); + + $element['site'] = [ + '#title' => t('Site'), + '#type' => 'select', + '#empty_option' => '- Select Site -', + '#default_value' => isset($item->site) ? $item->site : '', + '#options' => $this->sitesSelect($this->storage->getSites()), + ]; + return $element; + } + + private function sitesSelect($sites) { + foreach($sites as $site) { + $select[$site->site_id] = $site->site_name; + } + return $select; + } + +} diff --git a/modules/custom/activenet_registration/templates/activenet-activity-registration.html.twig b/modules/custom/activenet_registration/templates/activenet-activity-registration.html.twig new file mode 100755 index 0000000000..ba7a15d7c3 --- /dev/null +++ b/modules/custom/activenet_registration/templates/activenet-activity-registration.html.twig @@ -0,0 +1,19 @@ +{# +Available variables + 'name' => 'null', + 'registration_url' => 'null', url to active communites registration link + 'gender' => 'null', + 'site_name' => 'null', + 'date_start' => NULL, + 'date_end' => NULL, + 'date_pattern' => NULL, +#} + + +

{{ name }}

+ {{ gender }} + {{ date_pattern }} + {{ date_start }} - {{ date_end }} + {{ site_name }} + {{ link('Register Now', registration_url) }} + \ No newline at end of file diff --git a/modules/custom/activenet_registration/templates/activenet-flex-registration.html.twig b/modules/custom/activenet_registration/templates/activenet-flex-registration.html.twig new file mode 100755 index 0000000000..4c72c66c10 --- /dev/null +++ b/modules/custom/activenet_registration/templates/activenet-flex-registration.html.twig @@ -0,0 +1,14 @@ +{# +Available variables + 'name' => 'null', + 'registration_url' => 'null', url to active communites registration link + 'gender' => 'null', + 'site_name' => 'null', +#} + + +

{{ name }}

+ {{ site_name }} + {{ gender }} + {{ link('Register Now', registration_url) }} + \ No newline at end of file diff --git a/modules/custom/activenet_registration/templates/activenet-site.html.twig b/modules/custom/activenet_registration/templates/activenet-site.html.twig new file mode 100755 index 0000000000..b6174ecfa0 --- /dev/null +++ b/modules/custom/activenet_registration/templates/activenet-site.html.twig @@ -0,0 +1,7 @@ +{# +Available variables: + site_id + site_name +#} + +

{{ site_name }}

\ No newline at end of file