Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wcms/uw_cfg_common
1 result
Show changes
Commits on Source (40)
......@@ -136,6 +136,7 @@ class UWService implements UWServiceInterface {
'uw_ct_news_item',
'uw_ct_profile',
'uw_ct_web_page',
'uw_ct_service',
];
break;
......@@ -147,6 +148,7 @@ class UWService implements UWServiceInterface {
'uw_ct_news_item',
'uw_ct_profile',
'uw_ct_catalog_item',
'uw_ct_service',
];
break;
......
......@@ -80,6 +80,10 @@ class UwNodeContent {
case 'uw_ct_profile':
$content_data = $this->getProfileContent($node_flags);
break;
case 'uw_ct_service':
$content_data = $this->getServiceContent($node_flags);
break;
}
return $this->uwNodeData->getNodeData($node, $view_mode, $content_data);
......@@ -526,6 +530,63 @@ class UwNodeContent {
return $content_data;
}
/**
* Get the node content for service content type.
*
* @param array $node_flags
* The flags for the node.
*
* @return array
* Array of content to get from the node.
*/
public function getServiceContent(array $node_flags): array {
// Get the content data.
$content_data = $this->setupContentData($node_flags);
if ($node_flags['get_header']) {
$content_data['header']['status'] = $this->addToContentData('select', 'field_uw_service_status');
}
// Setup the actual content.
if ($node_flags['get_content']) {
$content_data['content'] = $this->addToContentData('content', 'field_uw_service_summary');
}
// Get the footer for the profile.
if ($node_flags['get_footer']) {
$content_data['footer']['service_information']['has_children'] = TRUE;
$content_data['footer']['service_information']['status'] = $this->addToContentData('select', 'field_uw_service_status');
$content_data['footer']['service_information']['categories'] = $this->addToContentData('terms', ['field_uw_service_category']);
$content_data['footer']['service_details']['has_children'] = TRUE;
$content_data['footer']['service_details']['popularity'] = $this->addToContentData('plain_text', 'field_uw_service_popularity');
$content_data['footer']['service_details']['use_service'] = $this->addToContentData(
'terms',
[
'field_uw_service_audience',
]
);
$content_data['footer']['service_details']['whats_available'] = $this->addToContentData('multiple_plain_text', 'field_uw_service_available');
$content_data['footer']['service_details']['request_service'] = $this->addToContentData('formatted_text', 'field_uw_service_request');
$content_data['footer']['service_details']['minimum_notice'] = $this->addToContentData('plain_text', 'field_uw_service_notice');
$content_data['footer']['service_details']['average_length'] = $this->addToContentData('plain_text', 'field_uw_service_length');
$content_data['footer']['service_details']['pricing_cost'] = $this->addToContentData('formatted_text', 'field_uw_service_cost');
$content_data['footer']['service_details']['support'] = $this->addToContentData('formatted_text', 'field_uw_service_support');
$content_data['footer']['service_hours']['has_children'] = TRUE;
$content_data['footer']['service_hours']['hours'] = $this->addToContentData('hours', 'field_uw_service_hours');
$content_data['footer']['location_info'] = [
'has_children' => TRUE,
'address' => $this->addToContentData('address', 'field_uw_service_location', 'Location address'),
'map' => $this->addToContentData('map', 'field_uw_service_location_coord', 'Location coordinates'),
];
}
return $content_data;
}
/**
* Gets the most recent date.
*
......
......@@ -103,7 +103,14 @@ class UwNodeFieldValue {
// Office hours field type.
if ($type == 'hours') {
return $node->$field_name->view();
$hours = $node->$field_name->view();
if (isset($hours['#title'])) {
return $hours;
}
else {
return [];
}
}
// Date field type (smart dates).
......@@ -111,6 +118,11 @@ class UwNodeFieldValue {
return $this->getDates($node, $field_name, $view_mode);
}
// Select list field.
if ($type == 'select') {
return $node->$field_name->value;
}
// Taxonomy terms field type.
if ($type == 'terms') {
return $this->getTermsField($node, $field_name);
......@@ -132,8 +144,13 @@ class UwNodeFieldValue {
}
// Plain text field type (textbox).
if ($type == 'plain_text') {
return $node->$field_name->value;
if ($type == 'plain_text' || $type == 'multiple_plain_text') {
if ($type == 'multiple_plain_text') {
return $this->getPlainText($node, $field_name, TRUE);
}
else {
return $this->getPlainText($node, $field_name);
}
}
// Source or hero image field type.
......@@ -237,6 +254,44 @@ class UwNodeFieldValue {
return $tags;
}
/**
* Gets a plain text field or fields.
*
* @param \Drupal\node\Entity\Node $node
* The node.
* @param string $field_name
* The field name.
* @param bool $multiple
* Flag if multiple plain text.
*
* @return mixed
* Plain text values.
*/
public function getPlainText(Node $node, string $field_name, bool $multiple = FALSE) {
$plain_text = [];
// If there are no multiple plain text, just return value.
// If there are multiple plain text, step through and
// get the values.
if (!$multiple) {
return $node->$field_name->value;
}
else {
// Get the values of the plain text field.
$values = $node->$field_name->getValue();
// Step through each and get the actual value.
foreach ($values as $value) {
$plain_text[] = $value['value'];
}
// Return array of plain text.
return $plain_text;
}
}
/**
* Prepares image for theme.
*
......@@ -497,6 +552,8 @@ class UwNodeFieldValue {
*
* @return array
* List of terms with name and link.
*
* @throws \Drupal\Core\Entity\EntityMalformedException
*/
public function getTermsFromEntityField(EntityReferenceFieldItemListInterface $values, string $type = NULL): array {
......@@ -586,6 +643,7 @@ class UwNodeFieldValue {
* A converted date to a string.
*/
public function getDate(array $date, string $type): string {
$return_date = '';
if ($type == 'event') {
......@@ -608,6 +666,7 @@ class UwNodeFieldValue {
$return_date = date(self::DATE_FORMAT_DATE_ONLY, $date['value']) . ' (all day)';
}
}
return $return_date;
}
......
......@@ -384,7 +384,7 @@ function uw_cfg_common_webform_create(WebformInterface $webform) {
// Set so that uw_cfg_common_webform_build_access_denied_alter() will run.
// This value is tested for in Webform::preRenderWebformElement().
$webform->setSetting('form_access_denied', 'page');
$webform->setSetting('form_access_denied', WebformInterface::ACCESS_DENIED_PAGE);
}
/**
......