Where have I to define email for UrlGenerator? - lumen

In my lumen 8.0 app I want to add Resets Passwords functionality
reading Trying to reset Passwords in Lumen article but I got error :
: Route [password.reset] not defined. at /mnt/_work_sdb8/wwwroot/LumenProjects/PublishPagesAPI/vendor/laravel/lumen-framework/src/Routing/UrlGenerator.php:231)
and checking related code I see in Notifications/ResetPassword.php:
public function toMail($notifiable)
{
\Log::info( varDump($notifiable, ' -1 $notifiable::') );
\Log::info( varDump(static::$toMailCallback, ' -2 static::$toMailCallback::') );
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
}
\Log::info( varDump(static::$createUrlCallback, ' -3 static::$createUrlCallback::') );
if (static::$createUrlCallback) {
$url = call_user_func(static::$createUrlCallback, $notifiable, $this->token);
} else {
$url = url(route('password.reset', [
'token' => $this->token,
'email' => $notifiable->getEmailForPasswordReset(),
], false));
}
return $this->buildMailMessage($url);
}
and checking log I see :
[2021-07-01 13:35:04] local.INFO: NULL : -2 static::$toMailCallback:: : NULL
[2021-07-01 13:35:04] local.INFO: NULL : -3 static::$createUrlCallback:: : NULL
Looks like in some config file I have to set these variables?
Could you please point where and which parameters?
Also as this article was written for lumex 5, if Notifications good decision for lumen 8?
Thanks!

Valid decision was to update config/auth.php with :
'password' => [
'users' => [
'provider' => 'users',
'email' => 'auth.emails.password',
'table' => 'passwords_resets',
'expire' => 60,
],
]

Related

yii2 detailview conditional row class

I would like to change class for one single attribute in detailview, based on a condition:
If I wouldn't want to make it conditional, it would be working like so:
[
'attribute' => 'ungueltig',
'format' => 'boolean',
'contentOptions' => [
'class' => 'danger',
]
],
I want this one to change to conditional, and I have tried a lot of different ways, e.g.:
[
'attribute' => 'ungueltig',
'format' => 'boolean',
'contentOptions' => function ($model) {
if ($model->ungueltig == 1) {
return ['class' => 'danger'];
} else {
return '';
}
},
],
(I would think this is the most logical solution, but nothing happens, so page is loading fine but without class danger at the attribute, no error message)
or
[
'attribute' => 'ungueltig',
'format' => 'boolean',
'contentOptions' => ['class' => function ($model) {
if ($model->ungueltig == 1) {
return 'danger';
} else {
return '';
}
},]
],
= error message: htmlspecialchars() expects parameter 1 to be string, object given
so I have no clue and I don't even find any help on the web. Can you please point me to the right direction? Many thanks!
You should simply try :
'contentOptions' => [
'class' => ($model->ungueltig == 1) ? 'danger' : '',
],
DetailView display only one model, you don't need any function here.

Send html in email with Catalyst and Catalyst::Plugin::Email

I have been reading about Catalyst framework and I am trying to send an email with HTML content without success.
I tried to use Catalyst::Plugin::Email, just as the example here. The email is sent, but all the content is showed in plain text.
sub send_email : Local {
my ($self, $c) = #_;
$c->email(
header => [
To => 'me#localhost',
Subject => 'A TT Email',
],
body => $c->view('Web')->render($c, 'email.tt', {
additional_template_paths => [ $c->config->{root} . '/email_templates'],
email_tmpl_param1 => 'foo'
}
),
);
# Redirect or display a message
}
I also read about Catalyst::View::Email::Template, but I chouldn't install it.
Any idea?
I am now available to send HTML emails with Catalyst::Plugin::Email. From documentation:
"email() accepts the same arguments as Email::MIME::Creator's create()."
Looking into Email::MIME::Creator, the create method structure is:
my $single = Email::MIME->create(
header_str => [ ... ],
body_str => '...',
attributes => { ... },
);
my $multi = Email::MIME->create(
header_str => [ ... ],
parts => [ ... ],
attributes => { ... },
);
"Back to attributes. The hash keys correspond directly to methods or modifying a message from Email::MIME::Modifier. The allowed keys are: content_type, charset, name, format, boundary, encoding, disposition, and filename. They will be mapped to "$attr_set" for message modification."
This is the code it is working:
sub send_email : Local {
my ($self, $c) = #_;
$c->email(
header => [
To => 'me#localhost',
Subject => 'A TT Email',
],
body => $c->view('Web')->render($c, 'email.tt', {
additional_template_paths => [ $c->config->{root} . '/email_templates'],
email_tmpl_param1 => 'foo'
}
),
attributes => {
content_type => 'text/html',
charset => 'utf-8'
},
);
# Redirect or display a message
}

What are the correct parameters for Magento Product Attribute creation in Perl

I've got several calls working already, but for the life of me I can't figure out how to make product_attribute.create work. I'm always getting a 102 Invalid request parameters or 623 Wrong Method Signature.
making the call like this my $res = $self->_useragent->call( call => $self->_session, #{$payload} ); (note: useragent is a XML::RPC object.
This Dumper $payload;
$VAR1 = [
'product_attribute.create',
[
'test',
{
'frontend_label' => [
{
'label' => 'Test ME',
'store_id' => 0
}
],
'scope' => 'store',
'frontend_input' => 'text'
}
]
];
I've read the API Documentation but figuring out what the call should look like in Perl is tricky.
I'm not familiar with the XML-RPC library you're using in perl, but he error you're seeing is a Magento API exception, configured in
<!--File: app/code/core/Mage/Catalog/etc/api.xml -->
<!-- ... -->
<invalid_parameters>
<code>102</code>
<message>Invalid request parameters.</message>
</invalid_parameters>
<!-- ... -->
Using the exception's name, you can find the place Magento threw it
#File: app/code/core/Mage/Catalog/Model/Product/Attribute/Api.php
//...
if (empty($data['attribute_code']) || !is_array($data['frontend_label'])) {
$this->_fault('invalid_parameters');
}
//...
So, my guess is your call is correct, you're just missing an attribute_code.
After some digging through Magento's code, I copied this from the test suite and it converted to perl, it appears to work. maybe all attributes are required.
$VAR1 = [
'product_attribute.create',
[
{
'default_value' => '1',
'is_configurable' => 0,
'used_in_product_listing' => 0,
'is_visible_on_front' => 0,
'apply_to' => [
'simple'
],
'is_comparable' => 0,
'is_used_for_promo_rules' => 0,
'is_required' => 0,
'scope' => 'store',
'is_unique' => 0,
'frontend_input' => 'text',
'is_searchable' => 0,
'attribute_code' => 'unique_code',
'is_visible_in_advanced_search' => 0,
'frontend_label' => [
{
'label' => 'some label',
'store_id' => '0'
}
]
}
]
];
Further experimentation somewhat based on Alan Storm's Answer, suggest that the following fields are required, as I was not able to successfully create a request without all of these fields at minimum being defined.
$VAR1 = [
'product_attribute.create',
[
{
'frontend_input' => 'text',
'attribute_code' => 'test1374438470',
'frontend_label' => [
{
'store_id' => 0,
'label' => 'Test ME'
}
]
}
]
];

How to create sub category on Magento APi

I am currently using Magento ver. 1.5.0.1. Can anyone tell me how do i create a sub category using soapv2.
Here my code format
category_data = { "name" => "LIGHTING", "is_active" => 1 }
soap.call('catalogCategoryCreate',session,4,category_data,1, "include_in_menu")
I got some errors when i run this code.
: Attribute "include_in_menu" is required. (SOAP::FaultError)
Is that any solution for this problem.
Thanks.
category_data = { "name" => "LIGHTING", "is_active" => 1, "include_in_menu" => 1 }
This is how you can create category using SOAP V2
<?php
$host = "192.168.0.10/~aliasgar/magentoext/index.php"; //our online shop url
$client = new SoapClient("http://".$host."/api/v2_soap/?wsdl"); //soap handle
$apiuser= "aliasgar"; //webservice user login
$apikey = "aliasgar"; //webservice user pass
try {
$sess_id= $client->login($apiuser, $apikey); //we do login
$result = $client->catalogCategoryCreate($sess_id, 3, array(
'name' => 'Test Category',
'is_active' => 1,
'available_sort_by' => array('position'),
'default_sort_by' => 'position',
'include_in_menu' => '1',
));
var_dump ($result);
}
catch (Exception $e) { //while an error has occured
echo "==> Error: ".$e->getMessage(); //we print this
exit();
}
?>
Here 3 in the catalogCategoryCreate function is the parent category id.

Zend Framework open id extensions with google

How to use openid extensions with google? I have something like this, I allready applied some patches which are basically the same as here: http://ak33m.com/?p=71
It does work without extensions?
$extensions = new Zend_OpenId_Extension_Sreg(array(
'nickname' => false,
'email' => true,
'fullname' => false
),
null,
'1.1'
);
if ($form->isValid($post)) {
$open_id_adapter = new App_Auth_Adapter_OpenId($post['openid_identifier'],null, null, null, $extensions);
$result = $auth->authenticate($open_id_adapter);
} else {
$open_id_adapter = new App_Auth_Adapter_OpenId(null, null, null, null, $extensions);
$result = $auth->authenticate($open_id_adapter);
}
if ($result->isValid()) {
$this->_helper->flashMessenger->addMessage(array(
'message' => 'U bent ingelogd',
'status' => 'success'
));
}
Maybe having a look at an example ZF 1.11 application that uses OpenID (including google) for authentication will clarify how to make it work (source code is also available).