1. Go to this page and download the library: Download xorgxx/neox-notify-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
myController.php
....
use NeoxNotify\NeoxNotifyBundle\notify\NotificationStrategyFactory;
use NeoxNotify\NeoxNotifyBundle\notify\notificationQueue;
....
#[Route('/{id}/send', name: 'app_admin_tokyo_crud_send', methods: ['GET'])]
public function send( Request $request, Tokyo $tokyo, NotificationStrategyFactory $notificationStrategyFactory): Response
{
$urlToken = $this->generateUrl("app_home_tokyo_switch",["token" => $tokyo->getToken()], UrlGeneratorInterface::ABSOLUTE_URL);
// Create listing Queue
$notificationQueue = new NotificationQueue();
// Create and configure email strategy
$notification = $notificationStrategyFactory->EmailStrategy();
// $notification->setRecipient(new Recipient($tokyo->getEmail())); < --- This will set by default valeur
$notification->setTemplate("tokyo");
$notification->Subject('Test ONLY !!');
$notification->content('....');
$notification->setContext('urlToken',$urlToken);
// put in Queue
$notificationQueue->addNotification($notification);
......
}
myController.php
....
use NeoxNotify\NeoxNotifyBundle\Attribute\NeoxNotifyAlert;
....
#[Route('/{id}/send', name: 'app_admin_tokyo_crud_send', methods: ['GET'])]
#[NeoxNotifyAlert(channels: ["email", "sms"], template: 'default', subject: 'Download file', content: '....', contexts: ["name" => "windev"])]
public function send( Request $request, Tokyo $tokyo, NotificationStrategyFactory $notificationStrategyFactory): Response
{
......
}
all is set by default! attributes :
channels: ["email", "sms"] -> chose witch channel you want to use.
template: 'default' -> template name in folder "emails: Partial\emails\"
subject: 'Download file' -> subject of email
content: '....' -> content/body email, sms, ....
------------ !!!! SUBJECT and CONTEXTS are special !!!! ------------------------------
contexts: [ "name" => "file", "opt" => "[attributes.file;attributes.controller]"],
subject: "Download file [attributes.file;attributes.controller]"
In subject | add "xxxxx xxxxx [attributes.file;attributes.controller]" in subject it will read in the Request object -> attribute-get("file")
In contexts: [ "opt" => "[attributes.file;attributes.controller]"] it will read in the Request object -> attribute-get("file") and pass (neox_file, neox_controller) to twig in [template: 'default']
$key = "name"
$value = "trying for conflicts avoid"
public function setContext($key, $value): void
{
// Add a prefix to the key to avoid conflicts in the template
$prefixedKey = "neox_" . $key;
// Set the value in the context array
$this->context[$prefixedKey] = $value;
}
<p style="line-height: 100%; font-size: 18px;"><em><strong>{{ "-----" ~ neox_name|default("Message interne") ~ "-----"}}</strong></em></p>
as you can see in code if you setTemplate() to what eve "xxx/xxxx/xxx.tmh.twig it will set.
// try to fund way to be able to have custom path to template
// $option->getTemplate() == "default" ; null ; "xxxx/xxxxx/default.html.twig"
$value = $option->getTemplate();
$Template = match (true) {
str_contains($value, '/') => $value,
default => $this->neoxTemplate['emails'] . "/" . ($option->getTemplate() ? : 'default'). '.html.twig',
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.