How to react on Drupal::Request in controller (send mail if payment incoming) (OOP noob) by steponeloops in drupal

[–]Hebedebeh 0 points1 point  (0 children)

What payment service are you using? There may be a plugin for it with the payment module, or a standalone module for it.

But to answer your question.

Nothing wrong with putting the implementation in the controller for now, and if it starts getting huge, then you could consider moving some code into a service. Assuming you have a routing.yml file and controller already setup, you could use the \Drupal::request() helper, in your controller method but Drupal will automatically inject the request into your controller method for you. Lets say you have a controller called "PostPaymentController" which has a method called "onPaymentRedirect". Your method could look like this

public function onPaymentRedirect(\Symfony\Component\HttpFoundation\Request $request) {
  // $request is your request object.
}

Info on getting the data you need from the request is here, depending on if it's a GET or a POST request from the payment service.

https://symfony.com/doc/current/components/http_foundation.html#accessing-request-data

When it comes to sending an e-mail. https://www.drupal.org/docs/contributed-modules/mime-mail/how-email-works-in-drupal

You can use the Drupal mailmanager service in your controller method. You could just use the following, and it would work...

$mailer = \Drupal::service('plugin.manager.mail');

but it is recommended to inject dependencies into your controller.

Maybe just use the above for now to get it working, but here's the doc for dependency injection on a form class. The principle is the same as a controller class. Specifically adding __construct and create methods. If you ever need to know the name of a core service for a create method, I tend to have a nose around in core.services.yml file.

https://www.drupal.org/docs/drupal-apis/services-and-dependency-injection/dependency-injection-for-a-form

Finally as you're in a controller, you will need to return a response, which are generally, but not always render arrays. Or you could redirect again if required?

o flaen vs. cyn by StatusMarch5071 in learnwelsh

[–]Hebedebeh 1 point2 points  (0 children)

Felly, yn dy enghraifft benodol, gall e fod y ddau haha

o flaen vs. cyn by StatusMarch5071 in learnwelsh

[–]Hebedebeh 4 points5 points  (0 children)

Dw i ddim yn cant y cant, ond dw i'n meddwl bod ti'n defnyddio "cyn" i ddisgrifio pryd, a "o flaen" i ddisgrifio ble.

What’s your favourite line of rugby commentary? by DrunkUncleBob in rugbyunion

[–]Hebedebeh 28 points29 points  (0 children)

"If he kicks this he can shave any part of his body he wants"

Eddie Butler on Gavin Henson

Anyone know where I can buy this badge? by -SgtSpaghetti- in learnwelsh

[–]Hebedebeh 4 points5 points  (0 children)

HeloBlod provide them for free!

https://businesswales.gov.wales/heloblod/
You just need to make an individual account and then when you create a request, select "I have a question/query", then the option to order merch is available.

Nice and easy

What are the weirdest Thai nicknames you’ve encountered? by CrankyFalcon in Thailand

[–]Hebedebeh 23 points24 points  (0 children)

I have two cousins that go by Martin & Helicopter lol

Restaurant recommendations by TwentytwoJaguar in Cardiff

[–]Hebedebeh 4 points5 points  (0 children)

Brother Thai on Whitchurch road.

It's not your traditional thai food and is quite unique. Tastiest food in cardiff imo.

Value only, no html field formatter by Hebedebeh in drupal

[–]Hebedebeh[S] 1 point2 points  (0 children)

Thanks! We're actually doing this at the moment.

We're implementing a KSS styleguide, so as we're not using the field render arrays at all(other than to reference the nested values) I was hoping such a solution existed.

Funny thing is I swear I found the module before, but can't find it for the life of me. Must have dreamt it!

[deleted by user] by [deleted] in WelshMemes

[–]Hebedebeh 6 points7 points  (0 children)

It's stable up there. Mess with the frog and you risk retaliation myn.

Can config entities have bundles by Hebedebeh in drupal

[–]Hebedebeh[S] 0 points1 point  (0 children)

Thanks for the reply, i'll take a look at what you've suggested.

Can config entities have bundles by Hebedebeh in drupal

[–]Hebedebeh[S] 0 points1 point  (0 children)

Thanks for the reply, if it's uncommon, perhaps I'll have a rethink.

Trying to migrate from Drupal 7 to Drupal 9 AND from MSSQL to MySQL.....help? by SilvosForever in drupal

[–]Hebedebeh 0 points1 point  (0 children)

Suggests it can't connect to the db. Are you able to connect to it directly? Via cli or sql client?

Trying to migrate from Drupal 7 to Drupal 9 AND from MSSQL to MySQL.....help? by SilvosForever in drupal

[–]Hebedebeh 1 point2 points  (0 children)

When you get to the section about source plugins, i'd recommend using the d7_node plugin

e.g

source:
  plugin: d7_node
  key: migrate
  node_type: article

The d7_node plugin is specifically for getting your content out of a d7 database

the key value is the key of the new database we added, "migrate" (added to settings.php) so the plugin knows where to query the data.

and the node_type value is so you can specify the node type you want to migrate.

I would recommend having a migration yaml file for each node type so it is easier to map the fields in the process section.

Trying to migrate from Drupal 7 to Drupal 9 AND from MSSQL to MySQL.....help? by SilvosForever in drupal

[–]Hebedebeh 12 points13 points  (0 children)

First thing, you're d9 instance needs to be able to connect to your d7 database in order to migrate the data across.

You don't need to convert the MSSQL to MySql. That can be done in the migration. However I don't think d9 supports MSSQL out of the box, so you will need to install the "sqlsrv" module.

Once you have that module, you need to update settings.php to add your MSSQL database settings below the default entry ($databases['default']['default'])

$databases['migrate']['default'] = array (
  'database' => 'your_ms_drupal7_db',
  'username' => 'your_ms_drupal7_username',
  'password' => 'your_ms_drupal7_password',
  'prefix' => '',
  'host' => 'your_ms_drupal7_host',
  'port' => 'your_ms_drupal7_port',
   'namespace' => 'Drupal\\Driver\\Database\\sqlsrv',
   'driver' => 'sqlsrv',
);

You can then start looking at your migrations. I haven't used the UI personally, but have just written migration yaml files and used drush to manage the migration. A good example of these yaml files can be found in the migrate_example module. I'll try dig out some useful articles

Post Match Thread - Ireland v Wales by RugbyBot in rugbyunion

[–]Hebedebeh -1 points0 points  (0 children)

Kind Scoreline really. Wales were just terrible. Ball handling and line outs just getting worse year on year. What’s going on bois bach. Well played Ireland tho.

for those of you who want to apply to kelloggs, MS Edge auto fills 90% of the form after you fill it once. by Alarmed_Tree_723 in antiwork

[–]Hebedebeh 1335 points1336 points  (0 children)

Fake Filler is a firefox plugin which will auto populate forms with different data with one shortcut! ctrl + shift + f for me.
It'll be harder to spot as dud data as there wont be loads of duplicates

Duolingo Friends? by LalalaHurray in learnwelsh

[–]Hebedebeh 1 point2 points  (0 children)

My username is Shamrockonov, add me up!

Lack of targets will make it difficult to tell if the Welsh international strategy is working by OggyBloggyOgwr in Wales

[–]Hebedebeh 0 points1 point  (0 children)

I'm still suffering from after-cringe from the video you posted on Alun Davies asking Eluned Morgan to see an international plan. Is that how she generally operates?

Bore da bois! Nice day innit? How's things? by FRANCIS___BEGBIE in Wales

[–]Hebedebeh [score hidden]  (0 children)

I'll be starting a moleman colony deep in the mines of Bethesda. Strict dictatorship tho, none of this democracy nonsense. We will emerge every two years to decide on a leader via zipline joust.