Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
9e3d77e4
Commit
9e3d77e4
authored
3 years ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5195: updating node data service to use functions to get the data from the node
parent
d5761f08
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!172
Feature/istwcms 5128 ebremner theme node services
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Service/UwNodeContent.php
+163
-85
163 additions, 85 deletions
src/Service/UwNodeContent.php
with
163 additions
and
85 deletions
src/Service/UwNodeContent.php
+
163
−
85
View file @
9e3d77e4
...
...
@@ -50,27 +50,11 @@ class UwNodeContent {
// Get the flags for the node.
$node_flags
=
$this
->
getNodeFlags
(
$node
,
$view_mode
,
$content
,
$featured_image
);
// Setup the
teaser
data array, based on flags.
// Setup the
node
data array, based on flags.
switch
(
$node
->
getType
())
{
case
'uw_ct_blog'
:
// The list of tags for blogs.
$tag_list
=
[
'field_uw_blog_tags'
,
'field_uw_audience'
,
];
$content_data
=
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'url'
=>
TRUE
,
'date'
=>
$node_flags
[
'get_header'
]
?
'field_uw_blog_date'
:
NULL
,
'author'
=>
$node_flags
[
'get_header'
]
?
TRUE
:
NULL
,
'sources'
=>
$node_flags
[
'get_image'
]
?
'field_uw_blog_listing_page_image'
:
NULL
,
'hero'
=>
$node_flags
[
'get_image'
]
?
'field_uw_hero_image'
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'field_uw_blog_summary'
:
NULL
,
'tags'
=>
$node_flags
[
'get_footer'
]
?
$tag_list
:
NULL
,
];
$content_data
=
$this
->
getBlogContent
(
$node_flags
);
break
;
case
'uw_ct_event'
:
...
...
@@ -78,85 +62,23 @@ class UwNodeContent {
break
;
case
'uw_ct_news_item'
:
// The list of tags for news.
$tag_list
=
[
'field_uw_news_tags'
,
'field_uw_audience'
,
];
$content_data
=
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'url'
=>
TRUE
,
'date'
=>
$node_flags
[
'get_header'
]
?
'field_uw_news_date'
:
NULL
,
'sources'
=>
$node_flags
[
'get_image'
]
?
'field_uw_news_listing_page_image'
:
NULL
,
'hero'
=>
$node_flags
[
'get_image'
]
?
'field_uw_hero_image'
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'field_uw_news_summary'
:
NULL
,
'tags'
=>
$node_flags
[
'get_footer'
]
?
$tag_list
:
NULL
,
];
$content_data
=
$this
->
getNewsContent
(
$node_flags
);
break
;
case
'uw_ct_web_page'
:
$content_data
=
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'layout_builder__layout'
:
NULL
,
];
$content_data
=
$this
->
getWebPageContent
(
$node_flags
);
break
;
case
'uw_ct_catalog_item'
:
$tags
=
[
'Category'
=>
'field_uw_catalog_category'
,
'Faculty'
=>
'field_uw_catalog_faculty'
,
'Audience'
=>
'field_uw_audience'
,
];
$content_data
=
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'layout_builder__layout'
:
NULL
,
'catalog_tags'
=>
$node_flags
[
'get_footer'
]
?
$tags
:
NULL
,
];
$content_data
=
$this
->
getCatalogItemContent
(
$node_flags
);
break
;
case
'uw_ct_contact'
:
$content_data
=
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'position'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_contact_title'
:
NULL
,
'affiliation'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_contact_affiliation'
:
NULL
,
'image'
=>
$node_flags
[
'get_image'
]
?
'field_uw_ct_contact_image'
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'layout_builder__layout'
:
NULL
,
'email'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_email'
:
NULL
,
'location'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_location'
:
NULL
,
'phone'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_phone'
:
NULL
,
'additional_info'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_info'
:
NULL
,
'link_profile'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_link_profile'
:
NULL
,
'personal_webpage'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_link_persona'
:
NULL
,
'contact_for'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_contact_for'
:
NULL
,
'groups'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_group'
:
NULL
,
'url'
=>
TRUE
,
];
$content_data
=
$this
->
getContactContent
(
$node_flags
);
break
;
case
'uw_ct_profile'
:
$tag_list
=
[
'field_uw_ct_profile_type'
,
];
$content_data
=
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'position'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_profile_title'
:
NULL
,
'affiliation'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_profile_affiliation'
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'field_uw_profile_summary'
:
NULL
,
'image'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_profile_image'
:
NULL
,
'sources'
=>
$node_flags
[
'get_image'
]
?
'field_uw_ct_profile_image'
:
NULL
,
'tags'
=>
$node_flags
[
'get_footer'
]
?
$tag_list
:
NULL
,
'link_profile'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_profile_info_link'
:
NULL
,
'personal_webpage'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_profile_link_persona'
:
NULL
,
'url'
=>
TRUE
,
];
$content_data
=
$this
->
getProfileContent
(
$node_flags
);
break
;
}
...
...
@@ -221,6 +143,35 @@ class UwNodeContent {
return
$node_flags
;
}
/**
* Get the node content for blog content type.
*
* @param array $node_flags
* The flags for the node.
*
* @return array
* Array of content to get from the node.
*/
public
function
getBlogContent
(
array
$node_flags
):
array
{
// The list of tags for blogs.
$tag_list
=
[
'field_uw_blog_tags'
,
'field_uw_audience'
,
];
return
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'url'
=>
TRUE
,
'date'
=>
$node_flags
[
'get_header'
]
?
'field_uw_blog_date'
:
NULL
,
'author'
=>
$node_flags
[
'get_header'
]
?
TRUE
:
NULL
,
'sources'
=>
$node_flags
[
'get_image'
]
?
'field_uw_blog_listing_page_image'
:
NULL
,
'hero'
=>
$node_flags
[
'get_image'
]
?
'field_uw_hero_image'
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'field_uw_blog_summary'
:
NULL
,
'tags'
=>
$node_flags
[
'get_footer'
]
?
$tag_list
:
NULL
,
];
}
/**
* Get the node content for event content type.
*
...
...
@@ -310,4 +261,131 @@ class UwNodeContent {
return
$content_data
;
}
/**
* Get the node content for news content type.
*
* @param array $node_flags
* The flags for the node.
*
* @return array
* Array of content to get from the node.
*/
public
function
getNewsContent
(
array
$node_flags
):
array
{
// The list of tags for news.
$tag_list
=
[
'field_uw_news_tags'
,
'field_uw_audience'
,
];
return
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'url'
=>
TRUE
,
'date'
=>
$node_flags
[
'get_header'
]
?
'field_uw_news_date'
:
NULL
,
'sources'
=>
$node_flags
[
'get_image'
]
?
'field_uw_news_listing_page_image'
:
NULL
,
'hero'
=>
$node_flags
[
'get_image'
]
?
'field_uw_hero_image'
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'field_uw_news_summary'
:
NULL
,
'tags'
=>
$node_flags
[
'get_footer'
]
?
$tag_list
:
NULL
,
];
}
/**
* Get the node content for web page content type.
*
* @param array $node_flags
* The flags for the node.
*
* @return array
* Array of content to get from the node.
*/
public
function
getWebPageContent
(
array
$node_flags
):
array
{
return
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'layout_builder__layout'
:
NULL
,
];
}
/**
* Get the node content for catalog item content type.
*
* @param array $node_flags
* The flags for the node.
*
* @return array
* Array of content to get from the node.
*/
public
function
getCatalogItemContent
(
array
$node_flags
):
array
{
$tags
=
[
'Category'
=>
'field_uw_catalog_category'
,
'Faculty'
=>
'field_uw_catalog_faculty'
,
'Audience'
=>
'field_uw_audience'
,
];
return
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'layout_builder__layout'
:
NULL
,
'catalog_tags'
=>
$node_flags
[
'get_footer'
]
?
$tags
:
NULL
,
];
}
/**
* Get the node content for catalog item content type.
*
* @param array $node_flags
* The flags for the node.
*
* @return array
* Array of content to get from the node.
*/
public
function
getContactContent
(
array
$node_flags
):
array
{
return
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'position'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_contact_title'
:
NULL
,
'affiliation'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_contact_affiliation'
:
NULL
,
'image'
=>
$node_flags
[
'get_image'
]
?
'field_uw_ct_contact_image'
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'layout_builder__layout'
:
NULL
,
'email'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_email'
:
NULL
,
'location'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_location'
:
NULL
,
'phone'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_phone'
:
NULL
,
'additional_info'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_info'
:
NULL
,
'link_profile'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_link_profile'
:
NULL
,
'personal_webpage'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_link_persona'
:
NULL
,
'contact_for'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_contact_for'
:
NULL
,
'groups'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_contact_group'
:
NULL
,
'url'
=>
TRUE
,
];
}
/**
* Get the node content for profile content type.
*
* @param array $node_flags
* The flags for the node.
*
* @return array
* Array of content to get from the node.
*/
public
function
getProfileContent
(
array
$node_flags
):
array
{
$tag_list
=
[
'field_uw_ct_profile_type'
,
];
return
[
'title'
=>
$node_flags
[
'get_title'
]
?
TRUE
:
NULL
,
'position'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_profile_title'
:
NULL
,
'affiliation'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_profile_affiliation'
:
NULL
,
'content'
=>
$node_flags
[
'get_content'
]
?
'field_uw_profile_summary'
:
NULL
,
'image'
=>
$node_flags
[
'get_header'
]
?
'field_uw_ct_profile_image'
:
NULL
,
'sources'
=>
$node_flags
[
'get_image'
]
?
'field_uw_ct_profile_image'
:
NULL
,
'tags'
=>
$node_flags
[
'get_footer'
]
?
$tag_list
:
NULL
,
'link_profile'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_profile_info_link'
:
NULL
,
'personal_webpage'
=>
$node_flags
[
'get_footer'
]
?
'field_uw_ct_profile_link_persona'
:
NULL
,
'url'
=>
TRUE
,
];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment