Problem of custom module translation prestashop 1.7.8.1 - module

I have built my own module and in the BO when I search my module and trying to translate it I am redirected to
"shopadmin/index.php/improve/international/translations/?lang=fr&type=modules&locale=fr-FR&selected=Module_Name&_token=OeEwKt4lWTUTcBerD-_w7LXvoA1Dyl3lcu3cBrYtkaA"
instead of
"shopadmin/index.php?controller=AdminTranslations&type=modules&module=ag_jsccustom&lang=fr&token=a74aaad65ca627b7ca6bfdc37235594f"
Anyone can help me with this weird issue?

I found the solution. You have to add this function to your module’s main class:
public function isUsingNewTranslationSystem()
{
return false;
}

Related

Laravel 8 Fortify binding implementations of the PasswordResetResponse contracts within register method of FortifyServiceProvider not working

I am trying to customize the redirect of PasswordResetResponse but its not working. Currently within register method of FortifyServiceProvider I have following code
$this->app->instance(PasswordResetResponse::class, new class implements PasswordResetResponse{
public function toResponse($request): \Illuminate\Http\RedirectResponse
{
return redirect(route('admin.login));
}
});
Redirect responses for login and logout(LoginResponse, LogoutResponse) are working fine but PasswordResetResponse is not working. Is there anything I am missing?
maybe
$this->app->instance(...);
↓
$this->app->singleton(...);

Symfony 3.4 : "Could not load type ... : class does not exist"

Sorry, I'm a beginner at Symfony and I've tried to find an answer but nothing worked. I'm using Symfony3.4 which was updated from Symfony 2.8 a few months ago.
Now, I'm trying to do a rather simple thing : using a formType in a Controller, but no matter what, Symfony keeps showing the following error : Could not load type "Cha\GeneralBundle\Form\StripePaymentType": class does not exist.
Here's my StripePaymentType -really, really basic:
namespace Cha\GeneralBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class StripePaymentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', TextType::class);
}
public function getBlockPrefix()
{
return 'cha_stripe_payment_form';
}
}
Here's my Controller action, once again, a basic thing (I didn't even write any code in there, because of this strange error) :
public function upgradeOfferPaymentAction(Offers $offers)
{
$form = $this->createForm(StripePaymentType::class);
return $this->render(
'#ChaGeneral/Offers/offer_payment.html.twig', array(
'form' => $form->createView()
));
}
I tried to use my form as a service but it did not work either :
cha.stripe.payment.form:
class: Cha\GeneralBundle\Form\StripePaymentType
tags:
- { name: cha_stripe_payment_form }
I'm probably missing something but I can't figure what...
Thank in advance for your help!
You must add this line at the top of the form class:
use Symfony\Component\Form\Extension\Core\Type\TextType;
Revert the SF version is not a solution, is just dodge the problem.
Well, finally I found what caused this problem : somebody did a composer update and we updated from Symfony 3.4.13 to Symfony 3.4.14. A simple revert did the trick, now everything is working again.
Thanks a lot for your help!

Migration from Joomla 2.5 to Joomla 3.4.5 results in strange server error 500

I installed a brand new, clean Joomla 3.4.5 and then installed a component written by myself, which worked totally fine in Joomla 2.5. In Joomla 3 however, I get server error 500... in some cases...
I narrowed the error down to the following weird situation:
The component is called com_confighdv (I'm extending Joomla core's com_config). I added a view called JustaName, existing of two files:
admin/views/justaname/view.html.php:
<?php
class ConfigHdVViewJustaName extends JViewLegacy
{
}
?>
admin/views/justaname/tmpl/default.php:
Hello world!
This works fine when I go to index.php?option=com_confighdv&view=justaname.
Then I change the view's name from JustaName to Component:
The view's folder becomes: admin/views/component/
Class declaration becomes: class ConfigHdVViewComponent extends JViewLegacy {}
Now, when I go to index.php?option=com_confighdv&view=component I get a server error 500 :s
I really don't know what to do with this. Help is very much appreciated!
Solved! Switching to Joomla's maximum error reporting provided the explanation:
Fatal error: Class ConfigHdVModelComponent contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JModelForm::getForm) in /xxx/administrator/components/com_confighdv/models/component.php on line 18
So, the problem is not in the view, but in the model that belongs to the Component view!
I accidentally created this problem myself, by reducing the model declaration to what I thought was the absolute minimum:
class ConfigHdVModelComponent extends JModelAdmin
{
{
While this is not allowed, because you always have to define the getForm method, so:
class ConfigHdVModelComponent extends JModelAdmin
{
public function getForm($data = array(), $loadData = true)
{
}
{

addJS function not working for admin in prestashop

I am trying to add javascript file in prestashop admin using backOfficeHeader hook using a module but nothing happened. My code is given below.
public function install()
{
if (!parent::install()
|| !$this->registerHook('backOfficeHeader'))
return false;
return parent::install() &&
$this->registerHook('backOfficeHeader');
}
public function hookBackOfficeHeader() {
$this->context->controller->addJS(_MODULE_DIR_.$this->module->name.'js/hs_custom.js');
}
If you are using PS 1.5 or 1.6 you should use hook "actionAdminControllerSetMedia".
Your module installer should check which prestashop version is used and then register the needed hook.
if (version_compare(substr(_PS_VERSION_, 0, 3), '1.5', '<'))
$this->registerHook('BackOfficeHeader');
else
$this->registerHook('actionAdminControllerSetMedia');
Then you need to addJS on each hook in its version format:
PS>=1.5
public function hookActionAdminControllerSetMedia($params) {
$this->context->controller->addJS($this->_path.'views/js/hs_custom.js');
}
PS<=1.4
public function hookBackOfficeHeader($params) {
Tools::addJS($this->_path.'views/js/hs_custom.js');
}
did u try to check addJS path? I think nothing more can be possible if other JS files working.
Try to use $this->_path.
$this->context->controller->addJS($this->_path.'views/js/hs_custom.js');
1) Output path and check if it is valid.
2) Reload page and check network. Page load your script or not?
3) Remember to reset module if u change something with hooks.
4) Check module hooks.
You did several mistakes.
This is the invalid access to the property: $this->module->name. Must be $this->name. I.e., the correct code to generate a path to JavaScript file is:
_MODULE_DIR_ . $this->name . '/js/hs_custom.js'
Or like this (shorted):
$this->_path . 'js/hs_custom.js'
You are also did the double installation of the module and of the hook.
You can use the hook BackOfficeHeader, but the hook ActionAdminControllerSetMedia is preferred.
So, the correct example to add a JS and a CSS files for a back-office (i.e. for AdminController) via a module class is:
public function hookActionAdminControllerSetMedia($params)
{
// Adds your's CSS file from a module's directory
$this->context->controller->addCSS($this->_path . 'views/css/example.css');
// Adds your's JavaScript file from a module's directory
$this->context->controller->addJS($this->_path . 'views/js/example.js');
}
Here is the detailed information, how to register JavaScript in a back-office (in admin pages).
I also met this problem, there is no error and warning, all grammar is right. But cannot find my js File.
I found the reason finally. In my case there is nothing in JS file and system passes this file which has no content always.
For me "this->_path" dosn't work. My solution is to use $_SERVER['DOCUMENT_ROOT']
public function hookActionAdminControllerSetMedia($params)
{
// add necessary javascript to products back office
if($this->context->controller->controller_name == 'AdminProducts' && Tools::getValue('id_product'))
{
$this->context->controller->addJS($_SERVER['DOCUMENT_ROOT']."/modules/apl/views/js/jquery.ui.touch-punch.min.js");
}
}

Translation of Zend_Validation in ZF2

I have a strange Problem in Zend Framework 2. I've used the Zend Skeleton Application (https://github.com/zendframework/ZendSkeletonApplication) and added PhlyContact as Vendor Module (https://github.com/weierophinney/PhlyContact). I changed the Translation-Type to PhpArray so that i can use the Zend_Validate.php located in the resources-dir of the ZF2-Dist.
Everything translates EXCEPT the validation Messages :/ So i guess i am missing something:
I must pass the Translator to Zend_Validate (but how and where?)
The Translation should use a Text-Domain, but doesn't
When i remember right in ZF1 you had to set the Translator to default to pass it to Zend_Validate. Any Ideas on that !?
have a look at these methods
\Zend\Validator\AbstractValidator::setDefaultTranslator();
\Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain();
You can even do this with only one line (2nd parameter is text domain):
AbstractValidator::setDefaultTranslator($translator, 'default');
Example within Module.php:
use Zend\Validator\AbstractValidator;
class Module
{
public function onBootstrap(MvcEvent $e)
{
$translator = ....
AbstractValidator::setDefaultTranslator($translator, 'default');
}
}