Skip to content
Snippets Groups Projects
Commit b44e45dd authored by Alex Skrypnyk's avatar Alex Skrypnyk Committed by Deployer Robot
Browse files

Fixed coding standards. (#1244)

parent a95a07e8
No related branches found
No related tags found
No related merge requests found
Showing
with 204 additions and 74 deletions
......@@ -15,6 +15,7 @@ dependencies:
- drupal:config
- drupal:content_moderation
- drupal:datetime_range
- drupal:focal_point
- drupal:help
- drupal:image
- drupal:inline_form_errors
......
......@@ -578,3 +578,47 @@ function civictheme_post_update_add_background_promo_component(array &$sandbox):
}
);
}
/**
* Enable focal_point and set configurations.
*/
function civictheme_post_update_enable_focal_point_configurations_2(): void {
\Drupal::getContainer()->get('module_installer')->install(['focal_point']);
$image_field_configs = [
'image.style.civictheme_navigation_card' => 'image_style',
'image.style.civictheme_promo_card' => 'image_style',
'image.style.civictheme_promo_banner' => 'image_style',
'image.style.civictheme_topic_desktop' => 'image_style',
'image.style.civictheme_topic_mobile' => 'image_style',
'image.style.civictheme_publication_card' => 'image_style',
'image.style.civictheme_subject_card' => 'image_style',
'image.style.civictheme_slider_slide' => 'image_style',
'image.style.civictheme_event_card' => 'image_style',
'image.style.civictheme_campaign' => 'image_style',
];
\Drupal::classResolver(CivicthemeUpdateHelper::class)->deleteConfig($image_field_configs);
$config_path = \Drupal::service('extension.list.theme')->getPath('civictheme') . '/config/install';
\Drupal::classResolver(CivicthemeUpdateHelper::class)->createConfigs($image_field_configs, $config_path);
$new_form_config = [
'field_c_m_image' => [
'type' => 'image_focal_point',
'region' => 'content',
'settings' => [
'progress_indicator' => 'throbber',
'preview_image_style' => 'civictheme_medium',
'preview_link' => TRUE,
'offsets' => '50,50',
],
],
];
\Drupal::classResolver(CivicthemeUpdateHelper::class)->updateFormDisplayConfig('media', 'civictheme_image', $new_form_config);
\Drupal::classResolver(CivicthemeUpdateHelper::class)->updateFormDisplayConfig('media', 'civictheme_image', $new_form_config, NULL, 'media_library');
$old_field_configs = [
'image.style.civictheme_thumbnail' => 'image_style',
];
\Drupal::classResolver(CivicthemeUpdateHelper::class)->deleteConfig($old_field_configs);
}
......@@ -5,12 +5,12 @@ dependencies:
- field.field.media.civictheme_image.field_c_m_caption
- field.field.media.civictheme_image.field_c_m_image
- field.field.media.civictheme_image.field_c_m_media_tags
- image.style.civictheme_thumbnail
- image.style.civictheme_medium
- media.type.civictheme_image
- workflows.workflow.civictheme_editorial
module:
- content_moderation
- image
- focal_point
- path
id: media.civictheme_image.default
targetEntityType: media
......@@ -32,12 +32,14 @@ content:
placeholder: ''
third_party_settings: { }
field_c_m_image:
type: image_image
type: image_focal_point
weight: 1
region: content
settings:
progress_indicator: throbber
preview_image_style: civictheme_thumbnail
preview_image_style: civictheme_medium
preview_link: true
offsets: '50,50'
third_party_settings: { }
field_c_m_media_tags:
type: entity_reference_autocomplete
......
......@@ -6,22 +6,24 @@ dependencies:
- field.field.media.civictheme_image.field_c_m_caption
- field.field.media.civictheme_image.field_c_m_image
- field.field.media.civictheme_image.field_c_m_media_tags
- image.style.civictheme_thumbnail
- image.style.civictheme_medium
- media.type.civictheme_image
module:
- image
- focal_point
id: media.civictheme_image.media_library
targetEntityType: media
bundle: civictheme_image
mode: media_library
content:
field_c_m_image:
type: image_image
type: image_focal_point
weight: 5
region: content
settings:
progress_indicator: throbber
preview_image_style: civictheme_thumbnail
preview_image_style: civictheme_medium
preview_link: true
offsets: '50,50'
third_party_settings: { }
name:
type: string_textfield
......
langcode: en
status: true
dependencies:
module:
- focal_point
name: civictheme_campaign
label: Campaign
effects:
dd0cef2a-f164-4c8e-ab0c-3898ec0f139b:
uuid: dd0cef2a-f164-4c8e-ab0c-3898ec0f139b
id: focal_point_scale_and_crop
weight: 1
data:
width: 100
height: 100
crop_type: focal_point
langcode: en
status: true
dependencies:
module:
- focal_point
name: civictheme_event_card
label: 'Event Card'
effects:
14a3c5a2-905e-44b1-a1ce-597a189fa83d:
uuid: 14a3c5a2-905e-44b1-a1ce-597a189fa83d
id: focal_point_scale_and_crop
weight: 1
data:
width: 100
height: 100
crop_type: focal_point
langcode: en
status: true
dependencies: { }
dependencies:
module:
- focal_point
name: civictheme_medium
label: Medium
effects:
bddf0d06-42f9-4c75-a700-a33cafa25ea0:
uuid: bddf0d06-42f9-4c75-a700-a33cafa25ea0
id: image_scale
weight: 0
057ded4a-e764-4232-91d2-79c07a5da33b:
uuid: 057ded4a-e764-4232-91d2-79c07a5da33b
id: focal_point_scale_and_crop
weight: 2
data:
width: 220
height: 220
upscale: false
crop_type: focal_point
langcode: en
status: true
dependencies: { }
dependencies:
module:
- focal_point
name: civictheme_navigation_card
label: 'Navigation card'
effects:
b8e5a34c-7858-461d-9db3-c71f97aeca04:
uuid: b8e5a34c-7858-461d-9db3-c71f97aeca04
id: image_scale_and_crop
weight: 1
78add4a6-10e9-47fe-8da5-38defcbc1446:
uuid: 78add4a6-10e9-47fe-8da5-38defcbc1446
id: focal_point_scale_and_crop
weight: 2
data:
width: 200
height: 200
anchor: center-center
crop_type: focal_point
langcode: en
status: true
dependencies: { }
dependencies:
module:
- focal_point
name: civictheme_promo_banner
label: 'Promo banner'
effects:
a85d68b7-a682-4599-87c7-88befc578ee1:
uuid: a85d68b7-a682-4599-87c7-88befc578ee1
id: image_scale_and_crop
weight: 1
9d278735-f586-4231-8297-ade6e71cffc7:
uuid: 9d278735-f586-4231-8297-ade6e71cffc7
id: focal_point_scale_and_crop
weight: 2
data:
width: 476
height: 520
anchor: center-center
crop_type: focal_point
langcode: en
status: true
dependencies: { }
dependencies:
module:
- focal_point
name: civictheme_promo_card
label: 'Promo card'
effects:
be9e65ef-2aa0-46f9-a42e-53694e9e5f5b:
uuid: be9e65ef-2aa0-46f9-a42e-53694e9e5f5b
id: image_scale_and_crop
weight: 1
6549b68e-52d6-4bbd-b186-1425e10f2c59:
uuid: 6549b68e-52d6-4bbd-b186-1425e10f2c59
id: focal_point_scale_and_crop
weight: 2
data:
width: 376
height: 240
anchor: center-center
crop_type: focal_point
langcode: en
status: true
dependencies:
module:
- focal_point
name: civictheme_publication_card
label: 'Publication Card'
effects:
f4003087-2cd4-4a11-9187-1b7272544544:
uuid: f4003087-2cd4-4a11-9187-1b7272544544
id: focal_point_scale_and_crop
weight: 1
data:
width: 100
height: 100
crop_type: focal_point
langcode: en
status: true
dependencies:
module:
- focal_point
name: civictheme_slider_slide
label: 'Slider Slide'
effects:
5143132c-afdd-4410-a619-7718b9f7f7e8:
uuid: 5143132c-afdd-4410-a619-7718b9f7f7e8
id: focal_point_scale_and_crop
weight: 1
data:
width: 100
height: 100
crop_type: focal_point
langcode: en
status: true
dependencies:
module:
- focal_point
name: civictheme_subject_card
label: 'Subject Card'
effects:
c5ec6c21-ddb9-4b47-b9b4-f5206e0afb9d:
uuid: c5ec6c21-ddb9-4b47-b9b4-f5206e0afb9d
id: focal_point_scale_and_crop
weight: 1
data:
width: 100
height: 100
crop_type: focal_point
langcode: en
status: true
dependencies: { }
name: civictheme_thumbnail
label: Thumbnail
effects:
1cfec298-8620-4749-b100-ccb6c4500779:
uuid: 1cfec298-8620-4749-b100-ccb6c4500779
id: image_scale
weight: 0
data:
width: 100
height: 100
upscale: false
langcode: en
status: true
dependencies: { }
dependencies:
module:
- focal_point
name: civictheme_topic_desktop
label: 'Topic desktop'
effects:
b871b9ed-7922-4361-9034-9b29e4cd2239:
uuid: b871b9ed-7922-4361-9034-9b29e4cd2239
id: image_scale_and_crop
weight: 1
66f42c49-2741-4203-95e9-ca75b00a9705:
uuid: 66f42c49-2741-4203-95e9-ca75b00a9705
id: focal_point_scale_and_crop
weight: 2
data:
width: 276
height: 224
anchor: center-center
crop_type: focal_point
langcode: en
status: true
dependencies: { }
dependencies:
module:
- focal_point
name: civictheme_topic_mobile
label: 'Topic mobile'
effects:
f2e908d5-26ff-4a5a-a971-97e44e8d2c6a:
uuid: f2e908d5-26ff-4a5a-a971-97e44e8d2c6a
id: image_scale_and_crop
weight: 1
51a9c965-4ec0-4438-94c8-6fb37dfe3594:
uuid: 51a9c965-4ec0-4438-94c8-6fb37dfe3594
id: focal_point_scale_and_crop
weight: 2
data:
width: 213
height: 200
anchor: center-center
crop_type: focal_point
......@@ -7,12 +7,14 @@
declare(strict_types=1);
use Drupal\civictheme\CivicthemeConstants;
/**
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_campaign(array &$variables): void {
_civictheme_preprocess_paragraph__paragraph_field__title($variables);
_civictheme_preprocess_paragraph__paragraph_field__image($variables);
_civictheme_preprocess_paragraph__paragraph_field__image($variables, CivicthemeConstants::CAMPAIGN_IMAGE_STYLE);
_civictheme_preprocess_paragraph__paragraph_field__image_position($variables);
_civictheme_preprocess_paragraph__paragraph_field__topics($variables);
_civictheme_preprocess_paragraph__paragraph_field__date($variables);
......
......@@ -19,7 +19,7 @@ use Drupal\civictheme\CivicthemeConstants;
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_promo_card(array &$variables): void {
_civictheme_preprocess_paragraph__paragraph_field__image($variables);
_civictheme_preprocess_paragraph__paragraph_field__image($variables, CivicthemeConstants::PROMO_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__paragraph_field__title($variables);
_civictheme_preprocess_paragraph__paragraph_field__summary($variables);
_civictheme_preprocess_paragraph__paragraph_field__link($variables);
......@@ -33,7 +33,7 @@ function civictheme_preprocess_paragraph__civictheme_promo_card(array &$variable
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_promo_card_ref(array &$variables): void {
_civictheme_preprocess_paragraph__node_field__image($variables);
_civictheme_preprocess_paragraph__node_field__image($variables, CivicthemeConstants::PROMO_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__node_field__title($variables);
_civictheme_preprocess_paragraph__node_field__summary($variables);
_civictheme_preprocess_paragraph__node_field__link($variables);
......@@ -50,7 +50,7 @@ function _civictheme_preprocess_node__civictheme_promo_card(array &$variables):
/** @var \Drupal\node\NodeInterface $node */
$node = $variables['node'];
_civictheme_preprocess_paragraph__node_field__image($variables);
_civictheme_preprocess_paragraph__node_field__image($variables, CivicthemeConstants::PROMO_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__node_field__title($variables);
_civictheme_preprocess_paragraph__node_field__link($variables);
_civictheme_preprocess_paragraph__node_field__topics($variables);
......@@ -80,7 +80,7 @@ function _civictheme_preprocess_node__civictheme_promo_card(array &$variables):
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_event_card(array &$variables): void {
_civictheme_preprocess_paragraph__paragraph_field__image($variables);
_civictheme_preprocess_paragraph__paragraph_field__image($variables, CivicthemeConstants::EVENT_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__paragraph_field__title($variables);
_civictheme_preprocess_paragraph__paragraph_field__summary($variables);
_civictheme_preprocess_paragraph__paragraph_field__date_range($variables);
......@@ -95,7 +95,7 @@ function civictheme_preprocess_paragraph__civictheme_event_card(array &$variable
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_event_card_ref(array &$variables): void {
_civictheme_preprocess_paragraph__node_field__image($variables);
_civictheme_preprocess_paragraph__node_field__image($variables, CivicthemeConstants::EVENT_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__node_field__title($variables);
_civictheme_preprocess_paragraph__node_field__location($variables);
_civictheme_preprocess_paragraph__node_field__summary($variables);
......@@ -109,7 +109,7 @@ function civictheme_preprocess_paragraph__civictheme_event_card_ref(array &$vari
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_navigation_card(array &$variables): void {
_civictheme_preprocess_paragraph__paragraph_field__image($variables);
_civictheme_preprocess_paragraph__paragraph_field__image($variables, CivicthemeConstants::NAVIGATION_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__paragraph_field__title($variables);
_civictheme_preprocess_paragraph__paragraph_field__summary($variables);
_civictheme_preprocess_paragraph__paragraph_field__link($variables);
......@@ -122,7 +122,7 @@ function civictheme_preprocess_paragraph__civictheme_navigation_card(array &$var
* Implements template_preprocess_node().
*/
function _civictheme_preprocess_node__civictheme_navigation_card(array &$variables): void {
_civictheme_preprocess_paragraph__node_field__image($variables);
_civictheme_preprocess_paragraph__node_field__image($variables, CivicthemeConstants::NAVIGATION_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__node_field__title($variables);
_civictheme_preprocess_paragraph__node_field__summary($variables, 'civictheme_navigation_card');
_civictheme_preprocess_paragraph__node_field__link($variables);
......@@ -136,7 +136,7 @@ function _civictheme_preprocess_node__civictheme_navigation_card(array &$variabl
function civictheme_preprocess_paragraph__civictheme_navigation_card_ref(array &$variables): void {
_civictheme_preprocess_paragraph__node_field__title($variables);
_civictheme_preprocess_paragraph__node_field__summary($variables);
_civictheme_preprocess_paragraph__node_field__image($variables);
_civictheme_preprocess_paragraph__node_field__image($variables, CivicthemeConstants::NAVIGATION_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__node_field__link($variables);
_civictheme_preprocess_paragraph__paragraph_field__theme($variables);
}
......@@ -145,7 +145,7 @@ function civictheme_preprocess_paragraph__civictheme_navigation_card_ref(array &
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_publication_card(array &$variables): void {
_civictheme_preprocess_paragraph__paragraph_field__image($variables);
_civictheme_preprocess_paragraph__paragraph_field__image($variables, CivicthemeConstants::PUBLICATION_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__paragraph_field__title($variables);
_civictheme_preprocess_paragraph__paragraph_field__summary($variables);
_civictheme_preprocess_paragraph__paragraph_field__theme($variables);
......@@ -166,7 +166,7 @@ function civictheme_preprocess_paragraph__civictheme_publication_card(array &$va
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_subject_card(array &$variables): void {
_civictheme_preprocess_paragraph__paragraph_field__image($variables);
_civictheme_preprocess_paragraph__paragraph_field__image($variables, CivicthemeConstants::SUBJECT_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__paragraph_field__title($variables);
_civictheme_preprocess_paragraph__paragraph_field__link($variables);
_civictheme_preprocess_paragraph__paragraph_field__theme($variables);
......@@ -176,7 +176,7 @@ function civictheme_preprocess_paragraph__civictheme_subject_card(array &$variab
* Implements template_preprocess_paragraph().
*/
function civictheme_preprocess_paragraph__civictheme_subject_card_ref(array &$variables): void {
_civictheme_preprocess_paragraph__node_field__image($variables);
_civictheme_preprocess_paragraph__node_field__image($variables, CivicthemeConstants::SUBJECT_CARD_IMAGE_STYLE);
_civictheme_preprocess_paragraph__node_field__title($variables);
_civictheme_preprocess_paragraph__node_field__link($variables);
_civictheme_preprocess_paragraph__paragraph_field__theme($variables);
......
......@@ -100,22 +100,22 @@ function _civictheme_preprocess_paragraph__paragraph_field__fill_width(array &$v
/**
* Pre-process for Image paragraph field.
*/
function _civictheme_preprocess_paragraph__paragraph_field__image(array &$variables): void {
function _civictheme_preprocess_paragraph__paragraph_field__image(array &$variables, string $image_style = NULL): void {
$media = civictheme_get_field_value($variables['paragraph'], 'field_c_p_image', TRUE);
if ($media) {
$variables['image'] = civictheme_media_image_get_variables($media);
$variables['image'] = civictheme_media_image_get_variables($media, $image_style);
}
}
/**
* Pre-process for Thumbnail node field.
*/
function _civictheme_preprocess_paragraph__node_field__image(array &$variables): void {
function _civictheme_preprocess_paragraph__node_field__image(array &$variables, string $image_style = NULL): void {
$node = $variables['node'] ?? civictheme_get_field_value($variables['paragraph'], 'field_c_p_reference', TRUE);
if ($node) {
$media = civictheme_get_field_value($node, 'field_c_n_thumbnail', TRUE);
if ($media) {
$variables['image'] = civictheme_media_image_get_variables($media);
$variables['image'] = civictheme_media_image_get_variables($media, $image_style);
}
}
}
......
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