Skip to content
Snippets Groups Projects
Commit 26472640 authored by Augusto Fagioli's avatar Augusto Fagioli
Browse files

fix #3212580

parent 9f70567b
Branches
No related tags found
No related merge requests found
......@@ -52,15 +52,13 @@ function aws_polly_help($route_name, RouteMatchInterface $route_match) {
function aws_polly_node_presave(NodeInterface $node) {
$config = _validate_aws_configuration();
if (!$config) { return; }
//dump($config);exit;
$ready = aws_polly_node_is_ready_for_polly ($node);
if (!$ready) { die ("nodo non prnto pe rpolly");return; }
if (!$config) {
return;
}
if (aws_polly_node_is_ready_for_polly($node) == TRUE) {
\Drupal::messenger()->addWarning('Audio fields will be processed by AWS Polly');
}
// A. Let's polly node title
if (\Drupal::currentUser()->hasPermission('polly node title')) {
......@@ -108,9 +106,7 @@ function aws_polly_add_polly_to_field ( $node, $text, $field_name ) {
return $node;
}
// @TODO: add missing voices (anyting via AWS API?)
// @todo add missing voices (anyting via AWS API?)
function aws_polly_voices ($options) {
switch ($options['language_code']) {
......@@ -162,31 +158,15 @@ function _validate_aws_configuration() {
}
function aws_polly_node_is_ready_for_polly ($node) {
$ready = false;
$check = Array('enabled' => null,'has_field' => null);
$ready = FALSE;
$check = ['enabled' => null,'has_field' => null];
//A node type is enabled
$check['enabled'] = \Drupal::state()->get('aws_polly_enabled' . $node->type->entity->Id(), null);
// Do we need this check here?
//B Entity has Field check
//B1 Entity has teaser field
//$check['has_field_title'] = $node->hasField('field_' . AWS_POLLY_TITLE_FIELD_NAME);
//B2 Entity has content field
//$check['has_field_content'] = $node->hasField('field_' . AWS_POLLY_CONTENT_FIELD_NAME);
if( $check['enabled'] == 1
//&& $check['has_field_title'] == true
//&& $check['has_field_content'] == true
) {
$ready = true;
if( $check['enabled'] == 1) {
$ready = TRUE;
}
return $ready;
}
......@@ -66,7 +66,7 @@ class AwsPollySettingsForm extends ConfigFormBase {
'#type' => 'details',
'#title' => $this->t('Global Settings'),
'#description' => $this->t('Config applicable through out the site'),
'#open' => FALSE,
'#open' => TRUE,
];
// @TODO - be more dynamic here
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment