-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/8.x-1.0-aplha1' into 8.x-1.x
- Loading branch information
Showing
13 changed files
with
847 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Module hooks. | ||
*/ | ||
|
||
/** | ||
* Implements hook_theme(). | ||
*/ | ||
function opening_hours_theme($existing, $type, $theme, $path) { | ||
return [ | ||
'opening_hours_opennow' => [ | ||
'template' => 'opening-hours-opennow', | ||
'path' => $path . '/templates', | ||
'variables' => [ | ||
'serviceId' => NULL, | ||
'channelId' => NULL, | ||
], | ||
], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
configure opening hours: | ||
title: 'Configure Opening Hours Service' | ||
description: 'Give access to the Opening Hours service configuration page.' | ||
restrict access: TRUE | ||
restrict access: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
services: | ||
opening_hours.client: | ||
class: Drupal\opening_hours\Services\ClientService | ||
arguments: [ '@config.factory' ] | ||
opening_hours.service: | ||
class: StadGent\Services\OpeningHours\Service\Service\ServiceService | ||
factory: Drupal\opening_hours\Services\ServiceFactory::createServiceService | ||
arguments: [ '@opening_hours.client' ] | ||
opening_hours.channel: | ||
class: StadGent\Services\OpeningHours\Service\Channel\ChannelService | ||
factory: Drupal\opening_hours\Services\ServiceFactory::createChannelService | ||
arguments: [ '@opening_hours.client' ] | ||
opening_hours.channel_opening_hours: | ||
class: StadGent\Services\OpeningHours\Service\Channel\ChannelService | ||
factory: Drupal\opening_hours\Services\ServiceFactory::createChannelOpeningHoursService | ||
arguments: [ '@opening_hours.client' ] | ||
opening_hours.channel_opening_hours_html: | ||
class: StadGent\Services\OpeningHours\Service\Channel\ChannelService | ||
factory: Drupal\opening_hours\Services\ServiceFactory::createChannelOpeningHoursHtmlService | ||
arguments: [ '@opening_hours.client' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Drupal\opening_hours\Controller; | ||
|
||
use Drupal\Core\Controller\ControllerBase; | ||
use Drupal\Core\StringTranslation\TranslationInterface; | ||
use StadGent\Services\OpeningHours\Service\Service\ServiceService; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Controller to get AutoComplete functionality when searching for a Service. | ||
* | ||
* @package Drupal\opening_hours\Controller | ||
*/ | ||
class ServiceController extends ControllerBase { | ||
/** | ||
* The Opening Hours Service service. | ||
* | ||
* @var \StadGent\Services\OpeningHours\Service\Service\ServiceService | ||
*/ | ||
protected $serviceService; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param \Drupal\Core\StringTranslation\TranslationInterface $stringTranslation | ||
* The String translation service. | ||
* @param \StadGent\Services\OpeningHours\Service\Service\ServiceService $serviceService | ||
* The Opening hours Service service. | ||
*/ | ||
public function __construct(TranslationInterface $stringTranslation, ServiceService $serviceService) { | ||
$this->setStringTranslation($stringTranslation); | ||
$this->serviceService = $serviceService; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function create(ContainerInterface $container) { | ||
/* @var $stringTranslation \Drupal\Core\StringTranslation\TranslationInterface */ | ||
$stringTranslation = $container->get('string_translation'); | ||
|
||
/* @var $serviceService \StadGent\Services\OpeningHours\Service\Service\ServiceService */ | ||
$serviceService = $container->get('opening_hours.service'); | ||
|
||
return new static($stringTranslation, $serviceService); | ||
} | ||
|
||
/** | ||
* Lookup Services through an autocomplete field. | ||
* | ||
* @param \Symfony\Component\HttpFoundation\Request $request | ||
* The current request object containing the search string. | ||
* | ||
* @return \Symfony\Component\HttpFoundation\JsonResponse | ||
* A JSON response containing the autocomplete suggestions. | ||
*/ | ||
public function autocomplete(Request $request) { | ||
$matches = []; | ||
|
||
$search = $request->query->get('q'); | ||
$services = $this->serviceService->searchByLabel($search); | ||
/* @var $service \StadGent\Services\OpeningHours\Value\Service */ | ||
foreach ($services as $service) { | ||
$value = sprintf('%s [%d]', $service->getLabel(), $service->getId()); | ||
|
||
$matches[] = [ | ||
'value' => $value, | ||
'label' => $service->getLabel(), | ||
]; | ||
} | ||
|
||
return new JsonResponse($matches); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Drupal\opening_hours\Plugin\Field\FieldFormatter; | ||
|
||
use Drupal\Core\Field\FormatterBase; | ||
use Drupal\Core\Field\FieldItemListInterface; | ||
|
||
/** | ||
* Open Now formatter for the opening_hours field item. | ||
* | ||
* @FieldFormatter( | ||
* id = "opening_hours_opennow", | ||
* label = @Translation("Open now"), | ||
* field_types = { | ||
* "opening_hours" | ||
* } | ||
* ) | ||
*/ | ||
class OpenNowFormatter extends FormatterBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function viewElements(FieldItemListInterface $items, $langcode) { | ||
$element = []; | ||
|
||
foreach ($items as $delta => $item) { | ||
$element[$delta] = [ | ||
'#theme' => 'opening_hours_opennow', | ||
'#serviceId' => $item->service, | ||
'#channelId' => $item->channel, | ||
]; | ||
} | ||
|
||
return $element; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Drupal\opening_hours\Plugin\Field\FieldType; | ||
|
||
use Drupal\Core\Field\FieldItemBase; | ||
use Drupal\Core\Field\FieldStorageDefinitionInterface; | ||
use Drupal\Core\TypedData\DataDefinition; | ||
|
||
/** | ||
* Provides a field type "Entrance Fee". | ||
* | ||
* @FieldType( | ||
* id = "opening_hours", | ||
* label = @Translation("Opening Hours"), | ||
* description = @Translation("Adds a field to select the Service and its Channel to show its opening hours for."), | ||
* category = @Translation("Web services"), | ||
* module = "opening_hours", | ||
* default_formatter = "opening_hours_opennow", | ||
* default_widget = "opening_hours", | ||
* column_groups = { | ||
* "service" = { | ||
* "label" = @Translation("Service"), | ||
* "translatable" = TRUE | ||
* }, | ||
* "channel" = { | ||
* "label" = @Translation("Channel"), | ||
* "translatable" = TRUE | ||
* }, | ||
* }, | ||
* ) | ||
*/ | ||
class OpeningHoursItem extends FieldItemBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function schema(FieldStorageDefinitionInterface $field_definition) { | ||
return [ | ||
'columns' => [ | ||
'service' => [ | ||
'description' => 'The service record ID.', | ||
'type' => 'int', | ||
'unsigned' => TRUE, | ||
'not null' => FALSE, | ||
], | ||
'channel' => [ | ||
'description' => 'The channel record ID.', | ||
'type' => 'int', | ||
'unsigned' => TRUE, | ||
'not null' => FALSE, | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { | ||
$properties = []; | ||
$properties['service'] = DataDefinition::create('string'); | ||
$properties['channel'] = DataDefinition::create('string'); | ||
return $properties; | ||
} | ||
|
||
} |
Oops, something went wrong.