我试图从SensioGeneratorBundle覆盖Resources/crud/actions/delete.php.twig
。
我在app/Resources/SensioGeneratorBundle/skeleton/crud/actions/delete.php.twig
创建了这个文件:
{% extends "@SensioGenerator/Resources/crud/actions/delete.php.twig" %}
{% block form %}
/**
* Creates a form to delete a {{ entity }} entity by id.
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('{{ route_name_prefix }}_delete', array('id' => $id)))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Supprimer'))
->getForm()
;
}
{% endblock form %}
问题是无法识别@SensioGenerator
:
命名空间没有注册路径" SensioGenerator" in" crud / controller.php.twig"在第58行。
我尝试在app/config/config.yml
中手动注册命名空间:
twig:
[...]
paths:
"%kernel.root_dir%/../vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/": SensioGenerator
但仍然无法正常工作。想法?
答案 0 :(得分:1)
为什么你没有像在文档中那样做? SensioGeneratorDocs
{% extends "skeleton/crud/actions/delete.php.twig" %}
{% block form %}
/**
* Creates a form to delete a {{ entity }} entity by id.
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('{{ route_name_prefix }}_delete', array('id' => $id)))
->add('submit', 'submit', array('label' => 'Supprimer'))
->getForm()
;
}
{% endblock form %}
答案 1 :(得分:0)
如果您使用的项目基于或类似于Symfony Standard Edition,则只会为 [System.Web.Http.HttpGet]
public List<Users> Get()
{
List<Users> user= (from m in new DataAccessLayer.MapRepository().GetUsersRelatingTo("UserName")
select new CommonLayer.Views.Markers
{
ID= m.UserID,
}).ToList();
return users;
}
环境加载SensioGeneratorBundle。
这已在composer.json和AppKernel中配置。
因此,请确保您的执行正在使用dev
环境或更改这些配置,以便始终加载该包。