Skip to content
Snippets Groups Projects
Commit fc279232 authored by Igor Biki's avatar Igor Biki
Browse files

Merge branch 'feature/ISTWCMS-4183-l26yan-Create-timeline-block' into '8.x-1.x'

Feature/istwcms 4183 l26yan create timeline block

See merge request !9
parents 7ad9eef8 c02dc407
No related branches found
No related tags found
1 merge request!9Feature/istwcms 4183 l26yan create timeline block
Showing
with 194 additions and 89 deletions
...@@ -35,7 +35,8 @@ blocks: ...@@ -35,7 +35,8 @@ blocks:
weight: 0 weight: 0
image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/fullwidthimage.svg image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/fullwidthimage.svg
image_alt: '' image_alt: ''
- block_id: 'inline_block:uw_cbl_image_gallery' -
block_id: 'inline_block:uw_cbl_image_gallery'
weight: 0 weight: 0
image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/imagegallery.svg image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/imagegallery.svg
image_alt: '' image_alt: ''
...@@ -49,3 +50,8 @@ blocks: ...@@ -49,3 +50,8 @@ blocks:
weight: 0 weight: 0
image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/relatedlinks.svg image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/relatedlinks.svg
image_alt: '' image_alt: ''
-
block_id: 'inline_block:uw_cbl_timeline'
weight: 0
image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/timeline.svg
image_alt: ''
...@@ -21,3 +21,4 @@ permissions: ...@@ -21,3 +21,4 @@ permissions:
- 'view paragraph content uw_para_fact_text' - 'view paragraph content uw_para_fact_text'
- 'view paragraph content uw_para_facts_and_figures' - 'view paragraph content uw_para_facts_and_figures'
- 'view paragraph content uw_para_ff' - 'view paragraph content uw_para_ff'
- 'view paragraph content uw_para_timeline'
...@@ -24,4 +24,5 @@ permissions: ...@@ -24,4 +24,5 @@ permissions:
- 'view paragraph content uw_para_fact_text' - 'view paragraph content uw_para_fact_text'
- 'view paragraph content uw_para_facts_and_figures' - 'view paragraph content uw_para_facts_and_figures'
- 'view paragraph content uw_para_ff' - 'view paragraph content uw_para_ff'
- 'view paragraph content uw_para_timeline'
- 'view the administration theme' - 'view the administration theme'
...@@ -38,6 +38,7 @@ permissions: ...@@ -38,6 +38,7 @@ permissions:
- 'create paragraph content uw_para_fact_text' - 'create paragraph content uw_para_fact_text'
- 'create paragraph content uw_para_facts_and_figures' - 'create paragraph content uw_para_facts_and_figures'
- 'create paragraph content uw_para_ff' - 'create paragraph content uw_para_ff'
- 'create paragraph content uw_para_timeline'
- 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type' - 'create terms in uw_tax_event_type'
- 'create terms in uw_vocab_audience' - 'create terms in uw_vocab_audience'
...@@ -63,6 +64,7 @@ permissions: ...@@ -63,6 +64,7 @@ permissions:
- 'delete paragraph content uw_para_fact_text' - 'delete paragraph content uw_para_fact_text'
- 'delete paragraph content uw_para_facts_and_figures' - 'delete paragraph content uw_para_facts_and_figures'
- 'delete paragraph content uw_para_ff' - 'delete paragraph content uw_para_ff'
- 'delete paragraph content uw_para_timeline'
- 'edit any uw_ct_blog content' - 'edit any uw_ct_blog content'
- 'edit any uw_ct_catalog_item content' - 'edit any uw_ct_catalog_item content'
- 'edit any uw_ct_event content' - 'edit any uw_ct_event content'
...@@ -103,6 +105,7 @@ permissions: ...@@ -103,6 +105,7 @@ permissions:
- 'update paragraph content uw_para_fact_text' - 'update paragraph content uw_para_fact_text'
- 'update paragraph content uw_para_facts_and_figures' - 'update paragraph content uw_para_facts_and_figures'
- 'update paragraph content uw_para_ff' - 'update paragraph content uw_para_ff'
- 'update paragraph content uw_para_timeline'
- 'use uw_workflow transition needs_review' - 'use uw_workflow transition needs_review'
- 'use workbench access' - 'use workbench access'
- 'view all media revisions' - 'view all media revisions'
......
...@@ -39,6 +39,7 @@ permissions: ...@@ -39,6 +39,7 @@ permissions:
- 'create paragraph content uw_para_fact_text' - 'create paragraph content uw_para_fact_text'
- 'create paragraph content uw_para_facts_and_figures' - 'create paragraph content uw_para_facts_and_figures'
- 'create paragraph content uw_para_ff' - 'create paragraph content uw_para_ff'
- 'create paragraph content uw_para_timeline'
- 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type' - 'create terms in uw_tax_event_type'
- 'create terms in uw_vocab_audience' - 'create terms in uw_vocab_audience'
...@@ -64,6 +65,7 @@ permissions: ...@@ -64,6 +65,7 @@ permissions:
- 'delete paragraph content uw_para_fact_text' - 'delete paragraph content uw_para_fact_text'
- 'delete paragraph content uw_para_facts_and_figures' - 'delete paragraph content uw_para_facts_and_figures'
- 'delete paragraph content uw_para_ff' - 'delete paragraph content uw_para_ff'
- 'delete paragraph content uw_para_timeline'
- 'edit any uw_ct_blog content' - 'edit any uw_ct_blog content'
- 'edit any uw_ct_catalog_item content' - 'edit any uw_ct_catalog_item content'
- 'edit any uw_ct_event content' - 'edit any uw_ct_event content'
...@@ -104,6 +106,7 @@ permissions: ...@@ -104,6 +106,7 @@ permissions:
- 'update paragraph content uw_para_fact_text' - 'update paragraph content uw_para_fact_text'
- 'update paragraph content uw_para_facts_and_figures' - 'update paragraph content uw_para_facts_and_figures'
- 'update paragraph content uw_para_ff' - 'update paragraph content uw_para_ff'
- 'update paragraph content uw_para_timeline'
- 'use uw_workflow transition archived' - 'use uw_workflow transition archived'
- 'use uw_workflow transition draft' - 'use uw_workflow transition draft'
- 'use uw_workflow transition needs_review' - 'use uw_workflow transition needs_review'
......
...@@ -40,6 +40,7 @@ permissions: ...@@ -40,6 +40,7 @@ permissions:
- 'create paragraph content uw_para_fact_text' - 'create paragraph content uw_para_fact_text'
- 'create paragraph content uw_para_facts_and_figures' - 'create paragraph content uw_para_facts_and_figures'
- 'create paragraph content uw_para_ff' - 'create paragraph content uw_para_ff'
- 'create paragraph content uw_para_timeline'
- 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type' - 'create terms in uw_tax_event_type'
- 'create terms in uw_vocab_audience' - 'create terms in uw_vocab_audience'
...@@ -83,6 +84,7 @@ permissions: ...@@ -83,6 +84,7 @@ permissions:
- 'delete paragraph content uw_para_fact_text' - 'delete paragraph content uw_para_fact_text'
- 'delete paragraph content uw_para_facts_and_figures' - 'delete paragraph content uw_para_facts_and_figures'
- 'delete paragraph content uw_para_ff' - 'delete paragraph content uw_para_ff'
- 'delete paragraph content uw_para_timeline'
- 'delete terms in uw_tax_event_tags' - 'delete terms in uw_tax_event_tags'
- 'delete terms in uw_tax_event_type' - 'delete terms in uw_tax_event_type'
- 'delete terms in uw_vocab_audience' - 'delete terms in uw_vocab_audience'
...@@ -134,6 +136,7 @@ permissions: ...@@ -134,6 +136,7 @@ permissions:
- 'update paragraph content uw_para_fact_text' - 'update paragraph content uw_para_fact_text'
- 'update paragraph content uw_para_facts_and_figures' - 'update paragraph content uw_para_facts_and_figures'
- 'update paragraph content uw_para_ff' - 'update paragraph content uw_para_ff'
- 'update paragraph content uw_para_timeline'
- 'use uw_workflow transition archived' - 'use uw_workflow transition archived'
- 'use uw_workflow transition draft' - 'use uw_workflow transition draft'
- 'use uw_workflow transition needs_review' - 'use uw_workflow transition needs_review'
......
...@@ -43,4 +43,4 @@ ...@@ -43,4 +43,4 @@
box-shadow: none; box-shadow: none;
border: 1px solid #bfbfba; border: 1px solid #bfbfba;
padding: 1rem; padding: 1rem;
} }
\ No newline at end of file
...@@ -17,7 +17,7 @@ class UwNodeAccessCheck implements AccessInterface { ...@@ -17,7 +17,7 @@ class UwNodeAccessCheck implements AccessInterface {
* A custom access check. * A custom access check.
* *
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* * Route matching.
* @param \Drupal\Core\Session\AccountInterface $account * @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account. * Run access checks for this account.
* *
...@@ -29,22 +29,26 @@ class UwNodeAccessCheck implements AccessInterface { ...@@ -29,22 +29,26 @@ class UwNodeAccessCheck implements AccessInterface {
// Get the node object, which is in the route match variable. // Get the node object, which is in the route match variable.
$node = $route_match->getParameter('node'); $node = $route_match->getParameter('node');
// Check if this is a sidebar content type and if the user has permission to edit the content type. // Check if this is a sidebar content type and if the user has permission
// We want to throw a 404 (NotFoundHttpException) if they do not have access. This is the case when // to edit the content type. We want to throw a 404 (NotFoundHttpException)
// a user is not logged in, and when they do not have permission to edit it. // if they do not have access. This is the case when a user is not logged
// in, and when they do not have permission to edit it.
if ($node && $node->bundle() == 'uw_ct_sidebar' && !$account->hasPermission('edit any uw_ct_sidebar content')) { if ($node && $node->bundle() == 'uw_ct_sidebar' && !$account->hasPermission('edit any uw_ct_sidebar content')) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
// Check if this is a sidebar content type and if the user has permission to edit the content type. // Check if this is a sidebar content type and if the user has permission
// We want to throw a 404 (NotFoundHttpException) if they do not have access. This is the case when // to edit the content type. We want to throw a 404 (NotFoundHttpException)
// a user is not logged in, and when they do not have permission to edit it. // if they do not have access. This is the case when a user is not logged
// in, and when they do not have permission to edit it.
if ($node && $node->bundle() == 'uw_ct_site_footer' && !$account->hasPermission('edit any uw_ct_site_footer content')) { if ($node && $node->bundle() == 'uw_ct_site_footer' && !$account->hasPermission('edit any uw_ct_site_footer content')) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
// We have to return some type of access, so we are going to return allowed, if they do not have access, // We have to return some type of access, so we are going to return
// the new exception is going to be thrown above. // allowed, if they do not have access, the new exception is going to be
// thrown above.
return AccessResult::allowed(); return AccessResult::allowed();
} }
} }
...@@ -54,7 +54,6 @@ class UwContentModerationForm extends ConfirmFormBase { ...@@ -54,7 +54,6 @@ class UwContentModerationForm extends ConfirmFormBase {
); );
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -84,9 +83,9 @@ class UwContentModerationForm extends ConfirmFormBase { ...@@ -84,9 +83,9 @@ class UwContentModerationForm extends ConfirmFormBase {
$options = ['absolute' => TRUE]; $options = ['absolute' => TRUE];
// Return the URL back to the node. // Return the URL back to the node.
$url = Url::fromRoute('entity.node.canonical', ['node' => $this->nid], $options); $url = Url::fromRoute('entity.node.canonical', ['node' => $this->nid], $options);
// Adding the redirect back to the node // Adding the redirect back to the node.
$form_state->setRedirectUrl($url); $form_state->setRedirectUrl($url);
// Set the message that the permissions have been saved. // Set the message that the permissions have been saved.
...@@ -122,4 +121,5 @@ class UwContentModerationForm extends ConfirmFormBase { ...@@ -122,4 +121,5 @@ class UwContentModerationForm extends ConfirmFormBase {
// Return the URL back to the node. // Return the URL back to the node.
return Url::fromRoute('entity.node.canonical', ['node' => $this->nid], $options); return Url::fromRoute('entity.node.canonical', ['node' => $this->nid], $options);
} }
} }
...@@ -34,4 +34,5 @@ class Uw2ColumnLayout extends UwColumnLayoutBase { ...@@ -34,4 +34,5 @@ class Uw2ColumnLayout extends UwColumnLayoutBase {
return $form; return $form;
} }
} }
...@@ -37,4 +37,5 @@ class Uw3ColumnLayout extends UwColumnLayoutBase { ...@@ -37,4 +37,5 @@ class Uw3ColumnLayout extends UwColumnLayoutBase {
return $form; return $form;
} }
} }
...@@ -37,4 +37,5 @@ class Uw4ColumnLayout extends UwColumnLayoutBase { ...@@ -37,4 +37,5 @@ class Uw4ColumnLayout extends UwColumnLayoutBase {
return $form; return $form;
} }
} }
...@@ -17,7 +17,10 @@ class UwColumnLayoutBase extends LayoutDefault implements PluginFormInterface { ...@@ -17,7 +17,10 @@ class UwColumnLayoutBase extends LayoutDefault implements PluginFormInterface {
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set the column class in the config. // Set the column class in the config.
$this->configuration['column_class'] = $form_state->getValue(['layout_settings', 'column_class'], NULL); $this->configuration['column_class'] = $form_state->getValue(
['layout_settings', 'column_class'],
NULL
);
} }
/** /**
......
<?php <?php
namespace Drupal\uw_cfg_common\Routing; namespace Drupal\uw_cfg_common\Routing;
use Drupal\Core\Routing\RouteSubscriberBase; use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouteCollection;
/** /**
* Listens to the dynamic route events. * Listens to the dynamic route events.
*/ */
class UwNodeAccessRouteSubscriber extends RouteSubscriberBase { class UwNodeAccessRouteSubscriber extends RouteSubscriberBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function alterRoutes(RouteCollection $collection) { protected function alterRoutes(RouteCollection $collection) {
// Change the route associated with node (/node/{nid}). // Change the route associated with node (/node/{nid}).
if ($route = $collection->get('entity.node.canonical')) { if ($route = $collection->get('entity.node.canonical')) {
$route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access'); $route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access');
} }
} }
} }
\ No newline at end of file
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
namespace Drupal\uw_cfg_common\Service; namespace Drupal\uw_cfg_common\Service;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
/** /**
* Class UWService * Class UWService.
*
* UW Service that holds common functionality used by uw blocks.
* *
* @package Drupal\uw_cfg_common\Service * @package Drupal\uw_cfg_common\Service
*/ */
......
...@@ -6,9 +6,9 @@ use Drupal\Core\Entity\EntityInterface; ...@@ -6,9 +6,9 @@ use Drupal\Core\Entity\EntityInterface;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
/** /**
* Interface UWServiceInterface * Interface UWServiceInterface.
* *
* Interface that is collection of common functions used throughout custom blocks. * Interface that is collection of common functions used in custom blocks.
* *
* @package Drupal\uw_cfg_common\Service * @package Drupal\uw_cfg_common\Service
*/ */
...@@ -41,4 +41,5 @@ interface UWServiceInterface { ...@@ -41,4 +41,5 @@ interface UWServiceInterface {
* Array of variables and their values. * Array of variables and their values.
*/ */
public function getTeaserContent(NodeInterface $node, array $variables_to_get, string $teaser_type): array; public function getTeaserContent(NodeInterface $node, array $variables_to_get, string $teaser_type): array;
} }
...@@ -6,6 +6,8 @@ use Drupal\user\Entity\Role; ...@@ -6,6 +6,8 @@ use Drupal\user\Entity\Role;
/** /**
* Class UwPermissions. * Class UwPermissions.
*
* UW Specific permissions.
*/ */
class UwPermissions { class UwPermissions {
...@@ -54,65 +56,135 @@ class UwPermissions { ...@@ -54,65 +56,135 @@ class UwPermissions {
// Blog permissions. // Blog permissions.
'Blog' => [ 'Blog' => [
'Use content type' => 'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_blog'), UwPermissions::buildRolePermissionsListContentType(
'uw_ct_blog'
),
'Create/edit tags' => 'Create/edit tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_blog_tags', ['create', 'edit']), UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_blog_tags',
['create', 'edit']
),
'Delete tags' => 'Delete tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_blog_tags', ['delete']), UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_blog_tags',
['delete']
),
], ],
// Catalog permissions. // Catalog permissions.
'Catalog' => [ 'Catalog' => [
'Use content type' => UwPermissions::buildRolePermissionsListContentType('uw_ct_catalog_item'), 'Use content type' =>
'Create/edit audience' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_audience', ['create', 'edit']), UwPermissions::buildRolePermissionsListContentType(
'Delete audience' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_audience', ['delete']), 'uw_ct_catalog_item'
'Create/edit categories' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_catalog_categories', ['create', 'edit']), ),
'Delete categories' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_catalog_categories', ['delete']), 'Create/edit audience' =>
'Create/edit catalogs' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_catalogs', ['create', 'edit']), UwPermissions::buildRolePermissionsListTaxonomyTerm(
'Delete catalogs' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_catalogs', ['delete']), 'uw_vocab_audience',
['create', 'edit']
),
'Delete audience' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_audience',
['delete']
),
'Create/edit categories' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_catalog_categories',
['create', 'edit']
),
'Delete categories' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_catalog_categories',
['delete']
),
'Create/edit catalogs' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_catalogs',
['create', 'edit']
),
'Delete catalogs' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_catalogs',
['delete']
),
], ],
// Event permissions. // Event permissions.
'Event' => [ 'Event' => [
'Use content type' => UwPermissions::buildRolePermissionsListContentType('uw_ct_event'), 'Use content type' =>
'Create/edit tags' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_tax_event_tags', ['create', 'edit']), UwPermissions::buildRolePermissionsListContentType(
'Delete tags' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_tax_event_tags', ['delete']), 'uw_ct_event'
'Create/edit types' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_tax_event_type', ['create', 'edit']), ),
'Delete types' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_tax_event_type', ['delete']), 'Create/edit tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_tax_event_tags',
['create', 'edit']
),
'Delete tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_tax_event_tags',
['delete']
),
'Create/edit types' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_tax_event_type',
['create', 'edit']
),
'Delete types' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_tax_event_type',
['delete']
),
], ],
// News permissions. // News permissions.
'News' => [ 'News' => [
'Use content type' => 'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_news_item'), UwPermissions::buildRolePermissionsListContentType(
'uw_ct_news_item'
),
'Create/edit tags' => 'Create/edit tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_news_tags', ['create', 'edit']), UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_news_tags',
['create', 'edit']
),
'Delete tags' => 'Delete tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_news_tags', ['delete']), UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_news_tags',
['delete']
),
], ],
// Sidebar permissions. // Sidebar permissions.
'Sidebar' => [ 'Sidebar' => [
'Use content type' => 'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_sidebar'), UwPermissions::buildRolePermissionsListContentType(
'uw_ct_sidebar'
),
], ],
// Site footer permissions. // Site footer permissions.
'Site footer' => [ 'Site footer' => [
'Use content type' => 'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_site_footer'), UwPermissions::buildRolePermissionsListContentType(
'uw_ct_site_footer'
),
], ],
// Special alert permissions. // Special alert permissions.
'Special alert' => [ 'Special alert' => [
'Use content type' => 'Use content type' =>
UwPermissions::buildRolePermissionsListCustom('administer special alert'), UwPermissions::buildRolePermissionsListCustom(
'administer special alert'
),
], ],
// Web page permissions. // Web page permissions.
'Web page' => [ 'Web page' => [
'Use content type' => 'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_web_page'), UwPermissions::buildRolePermissionsListContentType(
'uw_ct_web_page'
),
], ],
]; ];
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Install, update and uninstall for Configuration of all common WCMS. * Install, update and uninstall for Configuration of all common WCMS.
*/ */
use Drupal\taxonomy\Entity\Term;
use Drupal\uw_cfg_common\UwPermissions\UwPermissions; use Drupal\uw_cfg_common\UwPermissions\UwPermissions;
/** /**
...@@ -53,7 +54,7 @@ function uw_cfg_common_install() { ...@@ -53,7 +54,7 @@ function uw_cfg_common_install() {
'Site manager', 'Site manager',
'Content author', 'Content author',
'Content editor', 'Content editor',
], ],
'Delete catalogs' => [ 'Delete catalogs' => [
'Site manager', 'Site manager',
], ],
...@@ -137,29 +138,29 @@ function uw_cfg_common_install() { ...@@ -137,29 +138,29 @@ function uw_cfg_common_install() {
'Future undergraduate students', 'Future undergraduate students',
'Future graduate students', 'Future graduate students',
], ],
'Faculty', 'Faculty' => 'Faculty',
'Staff', 'Staff' => 'Staff',
'Alumni', 'Alumni' => 'Alumni',
'Parents', 'Parents' => 'Parents',
'Donors | Friends | Supporters', 'Donors | Friends | Supporters' => 'Donors | Friends | Supporters',
'Employers', 'Employers' => 'Employers',
'International', 'International' => 'International',
'Media', 'Media' => 'Media',
]; ];
$weight = 0; $weight = 0;
foreach ($terms as $key => $term) { foreach ($terms as $key => $term) {
if (is_array($term)) { if (is_array($term)) {
$parent = _uw_cfg_common_create_term($key, 'uw_vocab_audience', $weight, []); $parent = _uw_cfg_common_create_term($key, 'uw_vocab_audience', $weight, []);
foreach ($term as $child) { foreach ($term as $child) {
_uw_cfg_common_create_term($child, 'uw_vocab_audience', $weight, [$parent]); _uw_cfg_common_create_term($child, 'uw_vocab_audience', $weight, [$parent]);
} }
} }
else { else {
_uw_cfg_common_create_term($term, 'uw_vocab_audience', $weight, []); _uw_cfg_common_create_term($term, 'uw_vocab_audience', $weight, []);
} }
$weight++; $weight++;
} }
} }
...@@ -179,20 +180,24 @@ function uw_cfg_common_install() { ...@@ -179,20 +180,24 @@ function uw_cfg_common_install() {
* $term_id = _nodemaker_term_create('My Term', 'my_vocab', 0, [999]); * $term_id = _nodemaker_term_create('My Term', 'my_vocab', 0, [999]);
* @endcode * @endcode
* *
* @param string $term * @param string $taxonomy_name
* - Term Name. * - Term Name.
* @param string $vocabulary * @param string $vocab_machine_name
* - System id of the vocabulary term will be added to. * - System id of the vocabulary term will be added to.
* @param array $parent * @param string|int $weight
* - Taxonomy term weight.
* @param array $parent_tid
* - Array of term ids to be assigned as parent. * - Array of term ids to be assigned as parent.
* *
* @return int|null * @return int|null
* - Returns the term id of the created term on success, null on failure. * - Returns the term id of the created term on success, null on failure.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/ */
function _uw_cfg_common_create_term($taxonomy_name, $vocab_machine_name, $weight, array $parent_tid = []) { function _uw_cfg_common_create_term($taxonomy_name, $vocab_machine_name, $weight, array $parent_tid = []) {
// Create the taxonomy term. // Create the taxonomy term.
$new_term = Drupal\taxonomy\Entity\Term::create([ $new_term = Term::create([
'name' => $taxonomy_name, 'name' => $taxonomy_name,
'vid' => $vocab_machine_name, 'vid' => $vocab_machine_name,
'parent' => $parent_tid, 'parent' => $parent_tid,
......
...@@ -201,7 +201,7 @@ function uw_cfg_common_preprocess_node(&$variables) { ...@@ -201,7 +201,7 @@ function uw_cfg_common_preprocess_node(&$variables) {
$access_result = $plugin_block->access(\Drupal::currentUser()); $access_result = $plugin_block->access(\Drupal::currentUser());
// Return empty render array if user doesn't have access. // Return empty render array if user doesn't have access.
// $access_result can be boolean or an AccessResult class // $access_result can be boolean or an AccessResult class.
if (is_object($access_result) && $access_result->isForbidden() || is_bool($access_result) && !$access_result) { if (is_object($access_result) && $access_result->isForbidden() || is_bool($access_result) && !$access_result) {
return []; return [];
} }
...@@ -211,4 +211,3 @@ function uw_cfg_common_preprocess_node(&$variables) { ...@@ -211,4 +211,3 @@ function uw_cfg_common_preprocess_node(&$variables) {
$variables['uw_content_moderation_form'] = $render; $variables['uw_content_moderation_form'] = $render;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment