How to change standard Yii2 app name ("My Application")? - yii2

I've tried to search the information according to this, but couldn't find any useful ones.. I just created email sending in Yii2 and the email sends as a "My Application", I guess it's because standard Yii::$app->name is like that. Could someone tell me how to change it?

Yii::$app->name value is assigned in your application config
You can change the id and name attribute in your config file
'id' => 'your-applicatio-id',
'name' => 'Your application Name',
these attributesa are store in different file depend by the template you are using
in basic templae you can set these values in
yourapp/confi/web.php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'your-id',
'name' => 'Your Name',
......
in advanced template you can set these values in
backend/config/main.php
and in
frontend/config/main.php
You can use it in common config file too
common/config/main.php

Related

How to set custom metadata for Google Cloud Storage using JSON?

I am trying to add custom metadata to all uploads from my site to GCS.
I found something but I can't get it to work, in the Service Account JSON I added:
"metadata": {
"customMeta": "text here"
}
But it is not working, am I missing something here?
Thannks.
UPDATE
I am using Wordpress and a plugin called WP-Stateless, I asked the plugin author and he directed me to [link] (https://github.com/wpCloud/wp-stateless/blob/v2.2/lib/classes/class-utility.php) I tried adding a couple of lines, but after I saved it and tried uploading something, I checked the GCS console and there is no new metadata.
/* Add Google Storage metadata to our attachment */
$fileLink = $bucketLink . '/' . ( !empty($media['name']) ? $media['name'] : $file );
$cloud_meta = array(
'id' => $media[ 'id' ],
'name' => !empty($media['name']) ? $media['name'] : $file,
'fileLink' => $fileLink,
'storageClass' => $media[ 'storageClass' ],
'mediaLink' => $media[ 'mediaLink' ],
'selfLink' => $media[ 'selfLink' ],
'bucket' => ud_get_stateless_media()->get( 'sm.bucket' ),
'object' => $media,
'sizes' => array(),
'newDATA' => $_newData[ 'some text' ],
);
But I uploaded something and check GCS but there was now newDATA some text in the metadata for the file I uploaded.
As the documentation says, request body can have metadata field with JSON object having key/value pairs for metadata. Or metadata.key fields with specific values:
metadata - object - User-provided metadata, in key/value pairs.
metadata.(key) - string - An individual metadata entry. writable
Here is an example that worked for me (notice the metadata within metadata)
const file = bucket.file(filename);
await file.save(JSON.stringify(data), { metadata: { metadata: { user: 'user1' }}});

Transactional Emails - Default Styling and Variables in Magento 1.9

I'm looking for 2 specific variables.
Wishlist - The var_message variable has some styling to it that im trying to edit.
Abandoned Carts - pulls on this extension URL : connector/email/basket/code/secret/quote_id/*****
And im unable to find the location of the file that is accessed by that URL or command.
Any assistance that can be provided would be greatly appreciated.
Also if someone could tell me how i might trace the locations of these things without "Just knowing" that would be grand too.
Kind Regards,
the correct variable name is message (not var_message)
variable message is populated in controller Mage_Wishlist_IndexController
inside method sendAction
here it is:
$emailModel = Mage::getModel('core/email_template');
$sharingCode = $wishlist->getSharingCode();
foreach ($emails as $email) {
$emailModel->sendTransactional(
Mage::getStoreConfig('wishlist/email/email_template'),
Mage::getStoreConfig('wishlist/email/email_identity'),
$email,
null,
array(
'customer' => $customer,
'salable' => $wishlist->isSalable() ? 'yes' : '',
'items' => $wishlistBlock,
'addAllLink' => Mage::getUrl('*/shared/allcart', array('code' => $sharingCode)),
'viewOnSiteLink' => Mage::getUrl('*/shared/index', array('code' => $sharingCode)),
'message' => $message
)
);
}
$wishlist->setShared(1);
$wishlist->save();
and the actual content of the message comes from a form input and gets fetched over here:
$message = nl2br(htmlspecialchars((string) $this->getRequest()->getPost('message')));
there is no actual styling or css assigned to it. In fact most of styles are defined inline in email templates

Yii2: Translate Application Name

How to properly translate the name of the application in Yii2?
We can easily set the application name in main-local.php (or config/main.php) like so:
$config = [
'name' => 'My Application Name',
// ...
];
But how would we translate it?
Using something like \Yii::t('app.name', 'My Application Name') does not work because the configuration file is parsed before the application language is even determined or set.
The easiest way is to do translation on actual usage of application name:
<?= \Yii::t('app.name', Yii::$app->name) ?>
For messages extraction you may use fake translation in comment. Not sure about Poedit, but built-in Yii extractor support this some time ago:
$config = [
// \Yii::t('app.name', 'My Application Name')
'name' => 'My Application Name',
// ...
];
In worst case you may create separate file for such fake translations only for messages extraction, and don't include it on actual execution.

How to change default template in Yii2?

I am using the Yii 2 Advanced Application Template, the AdminLTE Asset Bundle and the Gii code generator.
Here is my example:
I need to change the template so I can remove the "Create Lab Tipos Movimientos" button (and modify some things more).
I am removing every button after Gii create the CRUD but I would like to change the template so Gii can do it automatically.
Once you have create your own template for gii
You can change the default template for gii assigning the new template values in main.php (main-local.php)
assigning the proper parameter to gii module
.....
$config['modules']['gii'] = [
//'class' => 'yii\gii\Module',
'class' => 'your_gii_module_path\Module',
'allowedIPs' => ['127.0.0.1', '::1', ],
'generators' => [ //here
'crud' => [ // generator name
//'class' => 'yii\gii\generators\crud\Generator', // generator class
'class' => 'your_gii_module_path\generators\crud\Generator', // generator class
'templates' => [ //setting for out templates
// template name => path to template
'your_crud_entry' => 'your_absolute_path_\your_gii_module_path\generators\crud\default',
]
]
],
];
.......
I have not done it myself, but I found this Guide by SamDark in Github that explains how to create your own template. This is the url: https://github.com/yiisoft/yii2-gii/blob/master/docs/guide/topics-creating-your-own-templates.md
Additionally, if you just want to eliminate the "Create Lab Tipos Movimiento" button you can try modifying the current template which if I am not wrong is located inside the folder vendor/yiisoft/yii2-gii/generators/crud/default/views and the file should be index.php. There you can try deleting or better yet commenting the part of the code that says:
<p>
<?= "<?= " ?>Html::a(<?= $generator->generateString('Create ' . Inflector::camel2words(StringHelper::basename($generator->modelClass))) ?>, ['create'], ['class' => 'btn btn-success']) ?>
</p>
I suggest you to make a copy of the files you modify just in case anything goes wrong.
Hope this helps you.
Have a great day.
EDIT:
Additionally following the answer of schmunk to a very similar question in stack overflow found here: How to use custom templates in gii (using Yii 2)
There is apparently a Gii extension in beta phase to help you in this situation called yii2-giiant found here: https://github.com/schmunk42/yii2-giiant (maybe there are similar extensions that are in a more advanced phase of development, google search should help with that)

CakePHP redirect with form parameter

In CakePHP 3.1 I am redirecting to login page after a database update and I want to pass back the email so that form input is already populated.
I can do it the standard way with using the controller and action in the redirect.
Instead I am using just a url string
return $this->redirect('/login',['?' => ['email' => $email]]);
This gives me the error Unknown status code
The redirect method expects a status code as the second parameter. You will need to provide and array-based URL as the first parameter or append the query var to the current string.
return $this->redirect('/login?email=' . $email);
return $this->redirect([
'controller' => 'Users',
'action' => 'login',
'?' => [
'email' => $email
]
]);