Symfony控制器执行多个时间 [英] Symfony Controller executed multiple Time
问题描述
当用户访问我的页面时,我会在我的控制器的showAction中发送一个 visitedEvent 。
此事件必须增加数据库中的视图计数器。
When a user access to my page, i dispatch an visitedEvent in my showAction of my controller. This event must increment a view counter in my database.
我的问题是我的控制器似乎被多次(两次)显示我的页面。我的计数器总是递增两倍!
My problem is that my controller seem to be called multiple times (two times) to show my page. My counter is always incremented twice !
我确信我的事件只在这里发送(它不是在其他控制器中发送)
I'm certain that my event is only dispatched here (its not dispatch in an other controller)
问题是什么?
我如何创建一个只增加一次的计数器?
WHAT IS THE PROBLEM ??? how can i create a counter who is incremented only once time ?!
Think's
推荐答案
经过多次搜索,我在我的视图中发现了一个 src =#
女巫会导致此问题。
After many search, I've found in my view an image with src="#"
witch cause this issue.
想想全部为您的帮助!
这篇关于Symfony控制器执行多个时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!