🇯🇴Jordan @bmustafa

Account created on 20 November 2019, about 5 years ago
#

Recent comments

🇯🇴Jordan bmustafa

this is the content of the twig file that fails to be renamed into the subfolder under files/php/twig/...

<?php

use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;

/* navigation:toolbar-button */
class __TwigTemplate_3f53f98db4a201dcd7a99fc0f37dfa04 extends Template
{
    private Source $source;
    /**
     * @var array<string, Template>
     */
    private array $macros = [];

    public function __construct(Environment $env)
    {
        parent::__construct($env);

        $this->source = $this->getSourceContext();

        $this->parent = false;

        $this->blocks = [
            'content' => [$this, 'block_content'],
        ];
        $this->sandbox = $this->extensions[SandboxExtension::class];
        $this->checkSecurity();
    }

    protected function doDisplay(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        // line 1
        yield $this->extensions['Drupal\Core\Template\TwigExtension']->renderVar($this->extensions['Drupal\Core\Template\TwigExtension']->attachLibrary("core/components.navigation--toolbar-button"));
        yield $this->extensions['Drupal\Core\Template\TwigExtension']->renderVar($this->extensions['Drupal\Core\Template\ComponentsTwigExtension']->addAdditionalContext($context, "navigation:toolbar-button"));
        yield $this->extensions['Drupal\Core\Template\TwigExtension']->renderVar($this->extensions['Drupal\Core\Template\ComponentsTwigExtension']->validateProps($context, "navigation:toolbar-button"));
        // line 4
        $context["classes"] = ["toolbar-button", ((        // line 6
($context["icon"] ?? null)) ? (("toolbar-button--icon--" . $this->sandbox->ensureToStringAllowed(($context["icon"] ?? null), 6, $this->source))) : (""))];
        // line 9
        yield "
";
        // line 10
        if (is_iterable(($context["modifiers"] ?? null))) {
            // line 11
            yield "  ";
            $context["classes"] = Twig\Extension\CoreExtension::merge($this->sandbox->ensureToStringAllowed(($context["classes"] ?? null), 11, $this->source), Twig\Extension\CoreExtension::map($this->env, $this->sandbox->ensureToStringAllowed(($context["modifiers"] ?? null), 11, $this->source), function ($__modifier__) use ($context, $macros) { $context["modifier"] = $__modifier__; return ("toolbar-button--" . $this->sandbox->ensureToStringAllowed(($context["modifier"] ?? null), 11, $this->source)); }));
        }
        // line 13
        yield "
";
        // line 14
        if (is_iterable(($context["extra_classes"] ?? null))) {
            // line 15
            yield "  ";
            $context["classes"] = Twig\Extension\CoreExtension::merge($this->sandbox->ensureToStringAllowed(($context["classes"] ?? null), 15, $this->source), $this->sandbox->ensureToStringAllowed(($context["extra_classes"] ?? null), 15, $this->source));
        }
        // line 17
        yield "
";
        // line 18
        if ((($context["text"] ?? null) && (Twig\Extension\CoreExtension::length($this->env->getCharset(), ($context["text"] ?? null)) > 1))) {
            // line 19
            yield "  ";
            // line 21
            yield "  ";
            $context["icon_text"] = Twig\Extension\CoreExtension::join(Twig\Extension\CoreExtension::slice($this->env->getCharset(), $this->sandbox->ensureToStringAllowed(($context["text"] ?? null), 21, $this->source), 0, 2), "");
            // line 22
            yield "  ";
            $context["attributes"] = CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, ($context["attributes"] ?? null), "setAttribute", ["data-index-text", Twig\Extension\CoreExtension::lower($this->env->getCharset(), Twig\Extension\CoreExtension::first($this->env->getCharset(), $this->sandbox->ensureToStringAllowed(($context["text"] ?? null), 22, $this->source)))], "method", false, false, true, 22), "setAttribute", ["data-icon-text", ($context["icon_text"] ?? null)], "method", false, false, true, 22);
        }
        // line 24
        yield "
<";
        // line 25
        yield $this->extensions['Drupal\Core\Template\TwigExtension']->escapeFilter($this->env, ((array_key_exists("html_tag", $context)) ? (Twig\Extension\CoreExtension::default($this->sandbox->ensureToStringAllowed(($context["html_tag"] ?? null), 25, $this->source), "button")) : ("button")), "html", null, true);
        yield " ";
        yield $this->extensions['Drupal\Core\Template\TwigExtension']->escapeFilter($this->env, $this->sandbox->ensureToStringAllowed(CoreExtension::getAttribute($this->env, $this->source, ($context["attributes"] ?? null), "addClass", [($context["classes"] ?? null)], "method", false, false, true, 25), 25, $this->source), "html", null, true);
        yield ">
  ";
        // line 26
        if (($context["action"] ?? null)) {
            // line 27
            yield "    <span data-toolbar-action class=\"visually-hidden\">";
            yield $this->extensions['Drupal\Core\Template\TwigExtension']->escapeFilter($this->env, $this->sandbox->ensureToStringAllowed(($context["action"] ?? null), 27, $this->source), "html", null, true);
            yield "</span>
  ";
        }
        // line 29
        yield "  ";
        yield from $this->unwrap()->yieldBlock('content', $context, $blocks);
        // line 34
        yield "
</";
        // line 35
        yield $this->extensions['Drupal\Core\Template\TwigExtension']->escapeFilter($this->env, ((array_key_exists("html_tag", $context)) ? (Twig\Extension\CoreExtension::default($this->sandbox->ensureToStringAllowed(($context["html_tag"] ?? null), 35, $this->source), "button")) : ("button")), "html", null, true);
        yield ">
";
        $this->env->getExtension('\Drupal\Core\Template\TwigExtension')
            ->checkDeprecations($context, ["icon", "modifiers", "modifier", "extra_classes", "text", "html_tag", "action"]);        yield from [];
    }

    // line 29
    /**
     * @return iterable<null|scalar|\Stringable>
     */
    public function block_content(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        // line 30
        yield "    ";
        if (($context["text"] ?? null)) {
            // line 31
            yield "      <span class=\"toolbar-button__label\" data-toolbar-text>";
            yield $this->extensions['Drupal\Core\Template\TwigExtension']->escapeFilter($this->env, $this->sandbox->ensureToStringAllowed(($context["text"] ?? null), 31, $this->source), "html", null, true);
            yield "</span>
    ";
        }
        // line 33
        yield "  ";
        yield from [];
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName(): string
    {
        return "navigation:toolbar-button";
    }

    /**
     * @codeCoverageIgnore
     */
    public function isTraitable(): bool
    {
        return false;
    }

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo(): array
    {
        return array (  131 => 33,  125 => 31,  122 => 30,  115 => 29,  107 => 35,  104 => 34,  101 => 29,  95 => 27,  93 => 26,  87 => 25,  84 => 24,  80 => 22,  77 => 21,  75 => 19,  73 => 18,  70 => 17,  66 => 15,  64 => 14,  61 => 13,  57 => 11,  55 => 10,  52 => 9,  50 => 6,  49 => 4,  45 => 1,);
    }

    public function getSourceContext(): Source
    {
        return new Source("", "navigation:toolbar-button", "D:\\wamp64\\www\\seo_oxygen_backoffice\\drupal11/core/modules/navigation\\components\\toolbar-button\\toolbar-button.twig");
    }
    
    public function checkSecurity()
    {
        static $tags = array("set" => 4, "if" => 10, "block" => 29);
        static $filters = array("merge" => 11, "map" => 11, "length" => 18, "join" => 21, "slice" => 21, "lower" => 22, "first" => 22, "escape" => 25, "default" => 25);
        static $functions = array();

        try {
            $this->sandbox->checkSecurity(
                ['set', 'if', 'block'],
                ['merge', 'map', 'length', 'join', 'slice', 'lower', 'first', 'escape', 'default'],
                [],
                $this->source
            );
        } catch (SecurityError $e) {
            $e->setSourceContext($this->source);

            if ($e instanceof SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
                $e->setTemplateLine($tags[$e->getTagName()]);
            } elseif ($e instanceof SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
                $e->setTemplateLine($filters[$e->getFilterName()]);
            } elseif ($e instanceof SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
                $e->setTemplateLine($functions[$e->getFunctionName()]);
            }

            throw $e;
        }

    }
}
🇯🇴Jordan bmustafa

Yes i have disabled that per your advice, not sure why i got it enabled earlier.
however, the authentication fails with gmail, despite user name and password are correct.
i do not see that this module supports Oauth2 yet, can you please implement it, it is not difficult:

  1. Install the latest version of PHPMailer using Composer:
  2. composer require phpmailer/phpmailer
  3. Install the Gmail API client library using Composer:
  4. composer require google/apiclient:^2.0
  5. Obtain the OAuth2 credentials for your Gmail account using the Gmail API client library.
  6. Use the obtained credentials to authenticate PHPMailer with OAuth2 and send an email.

Here is the sample code to send email using PHPMailer with OAuth2 authentication:


require_once 'vendor/autoload.php';

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\OAuth;
use Google\Client;
use Google\Service\Gmail;

// Replace placeholders with actual values
define('CLIENT_SECRET_PATH', 'path/to/client_secret.json');
define('CREDENTIALS_PATH', 'path/to/credentials.json');
define('EMAIL_FROM', 'YOUR_EMAIL_ADDRESS_HERE');
define('NAME_FROM', 'YOUR_NAME_HERE');
define('EMAIL_TO', 'RECIPIENT_EMAIL_ADDRESS_HERE');
define('NAME_TO', 'RECIPIENT_NAME_HERE');
define('EMAIL_SUBJECT', 'EMAIL_SUBJECT_HERE');
define('EMAIL_BODY', 'EMAIL_BODY_HERE');

// Set up the Google API client
$client = new Client();
$client->setApplicationName('My Application Name');
$client->setScopes([Gmail::GMAIL_READONLY]);
$client->setAuthConfig(CLIENT_SECRET_PATH);
$client->setAccessType('offline');
$client->setPrompt('select_account consent');

// Create a new Gmail API client instance
$gmail = new Gmail($client);

// Obtain the OAuth2 credentials for your Gmail account
$authUrl = $client->createAuthUrl();
echo "Please visit this URL to authorize the application: $authUrl\n";
$authCode = readline("Enter the authorization code: ");
$accessToken = $client->fetchAccessTokenWithAuthCode($authCode);

// Store the credentials for later use
file_put_contents(CREDENTIALS_PATH, json_encode($accessToken));

// Create a new instance of PHPMailer
$mail = new PHPMailer();

// Set the SMTP settings for Gmail
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

// Set the OAuth2 authentication settings
$mail->setOAuth(
    new OAuth([
        'clientId' => $client->getConfig('client_id'),
        'clientSecret' => $client->getConfig('client_secret'),
        'refreshToken' => $accessToken['refresh_token'],
        'userName' => EMAIL_FROM,
    ])
);

// Set the email message properties
$mail->setFrom(EMAIL_FROM, NAME_FROM);
$mail->addAddress(EMAIL_TO, NAME_TO);
$mail->Subject = EMAIL_SUBJECT;
$mail->Body = EMAIL_BODY;

// Send the email
if (!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message sent successfully';
}

Make sure to replace the placeholder values with your actual credentials and message details before running the code.

🇯🇴Jordan bmustafa

Okay, I resolved by installing

drush entup

https://www.drupal.org/project/devel_entity_updates

then it fixed the mismatched fields

then i issued drush pmu rabbit_hole

then i got error , because memory 128mb was exceeded for php, so i increased, memory and finally got rid of that rabbit hole module, sorry, but i can't afford buggy modules in my site.

hope that module gets good care and extra polishing.

🇯🇴Jordan bmustafa

what a rabbit hole i fall in by installing this module, stuck here

🇯🇴Jordan bmustafa

i am getting this error too:

[29-Apr-2023 05:48:58 Asia/Dubai] Uncaught PHP Exception Error: "Call to undefined method Drupal\Core\Extension\ModuleHandler::getImplementations()" at D:\wamp64\www\seo_saja_drupal_backoffice\web\modules\contrib\libraries\libraries.module line 407

the module is not usable at this stage.

the above code suggestion did not work for, despite error gone, but the module does not function

Production build 0.71.5 2024