我正在尝试更改应用程序的默认语言环境.到目前为止我尝试过的事情:
app/config/parameters.ini
这是实施.Locale类似乎没有被覆盖,因为调用\Locale::getDefault()
不执行此方法.
<?php
use Symfony\Component\Locale\Stub\StubLocale;
class Locale extends StubLocale
{
static public function getDefault()
{
return 'et_EE';
}
}
Run Code Online (Sandbox Code Playgroud)
在尝试了所有这些方法后,\Locale::getDefault()
仍然会返回en
.我需要它et_EE
在适当的语言环境中返回渲染表单小部件,例如国家或语言.
我该怎么做呢?能够在以后支持多个语言环境也很棒.谢谢.
我正在尝试从app/Resources/views
目录导入一些宏,但Symfony似乎没有找到模板.
我尝试了以下方法,所有这些方法都返回错误Unable to find template
.
{% import '::macros.twig' as macros %}
{% import '/app/Resources/views/macros.twig' as macros %}
{% import '/app/Resources/views/macros.twig' as macros %}
Run Code Online (Sandbox Code Playgroud)
如何从中导入宏app/Resources/views
?
namespace Topxia\LiftBundle\Form;
use Symfony\Component\Validator\Constraint as Assert;
class AddUser {
/**
* @Assert\NotBlank(message="???????")
*/
public $username;
/**
* @Assert\NotBlank(message="????????")
*/
public $name;
/**
* @Assert\NotBlank(message="??????")
* @Assert\MinLength(limit=4,message="?????")
* @Assert\MaxLength(limit=24,message="?????")
*/
public $password;
/**
* @Assert\NotBlank(message="??????")
*/
public $rpassword;
/**
* @Assert\NotBlank(message="???????")
* @Assert\Email(message="???????")
*/
public $email;
/**
* @Assert\NotBlank(message="k3????????")
*/
public $num;
/**
* @Assert\NotBlank()
* @Assert\Choice({"0", "1", "2", "3", "4"})
*/
public $roles;
public $changePassword;
}
Run Code Online (Sandbox Code Playgroud)
<?php
// src/Topxia/LiftBundle/Form/AddUserType.php
namespace Topxia\LiftBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class AddUserType extends AbstractType{
public …
Run Code Online (Sandbox Code Playgroud) static public function check( $securityContext)
{
$user = $securityContext->getToken()->getUser();
if(is_object($user) && [...])
return **$this**->redirect(**$this**->generateUrl('route_recruteur_monespace'));
return $user->getRecruteur();
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用新的Controller() - >但它不起作用,所以如何从静态方法调用redirect().谢谢.