• <tfoot id='SBrWj'></tfoot>
  • <i id='SBrWj'><tr id='SBrWj'><dt id='SBrWj'><q id='SBrWj'><span id='SBrWj'><b id='SBrWj'><form id='SBrWj'><ins id='SBrWj'></ins><ul id='SBrWj'></ul><sub id='SBrWj'></sub></form><legend id='SBrWj'></legend><bdo id='SBrWj'><pre id='SBrWj'><center id='SBrWj'></center></pre></bdo></b><th id='SBrWj'></th></span></q></dt></tr></i><div id='SBrWj'><tfoot id='SBrWj'></tfoot><dl id='SBrWj'><fieldset id='SBrWj'></fieldset></dl></div>
        <legend id='SBrWj'><style id='SBrWj'><dir id='SBrWj'><q id='SBrWj'></q></dir></style></legend>

        <small id='SBrWj'></small><noframes id='SBrWj'>

          <bdo id='SBrWj'></bdo><ul id='SBrWj'></ul>
      1. Symfony 2:在 ContainerAwareCommand 中禁用 Doctrine 事件侦听器

        Symfony 2: Disable Doctrine event listener in ContainerAwareCommand(Symfony 2:在 ContainerAwareCommand 中禁用 Doctrine 事件侦听器)
        • <small id='d9r9I'></small><noframes id='d9r9I'>

            <tbody id='d9r9I'></tbody>

              • <bdo id='d9r9I'></bdo><ul id='d9r9I'></ul>
                <legend id='d9r9I'><style id='d9r9I'><dir id='d9r9I'><q id='d9r9I'></q></dir></style></legend>
                <i id='d9r9I'><tr id='d9r9I'><dt id='d9r9I'><q id='d9r9I'><span id='d9r9I'><b id='d9r9I'><form id='d9r9I'><ins id='d9r9I'></ins><ul id='d9r9I'></ul><sub id='d9r9I'></sub></form><legend id='d9r9I'></legend><bdo id='d9r9I'><pre id='d9r9I'><center id='d9r9I'></center></pre></bdo></b><th id='d9r9I'></th></span></q></dt></tr></i><div id='d9r9I'><tfoot id='d9r9I'></tfoot><dl id='d9r9I'><fieldset id='d9r9I'></fieldset></dl></div>

                1. <tfoot id='d9r9I'></tfoot>
                  本文介绍了Symfony 2:在 ContainerAwareCommand 中禁用 Doctrine 事件侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用在配置文件中注册的几个 Doctrine 侦听器进行一些自动更新(created_on、updated_on 时间戳等).目前我已经实现了额外的功能,需要在数据库中存储准备好的值以便于搜索.

                  I am using several Doctrine listeners registered in configuration file for some automatic updates (created_on, updated_on timestamps etc.). Currently I have implemented additional functionality that requires stashing prepared values in the database for easier searching.

                  我正在考虑使用 update Symfony 命令来准备这些值而不是 SQL 更新脚本(实际上,任何类型的更改或更新值的创建方式都不需要只运行这个命令).然而,这也会触发前面提到的 EventListeners.

                  I am thinking about update Symfony command that would prepare these values instead of SQL update script (actually any sort of change or update in the way the value is crated would than require just running this single command). However this would also trigger the EventListeners mentioned earlier.

                  有没有办法为单个命令禁用特定的 EventLister?

                  Is there a way how to disable particular EventLister for single Command?

                  推荐答案

                  这样的事情应该可以解决问题:

                  something like this should do the trick :

                  $searchedListener = null;
                  $em = $this->getDoctrine()->getManager();
                  foreach ($em->getEventManager()->getListeners() as $event => $listeners) {
                      foreach ($listeners as $key => $listener) {
                          if ($listener instanceof ListenerClassYouLookFor) {
                              $searchedListener = $listener;
                              break 2;
                          }
                      }
                  }
                  if ($searchedListener) {
                      $evm = $em->getEventManager();
                      $evm->removeEventListener(array('onFlush'), $searchedListener);
                  }
                  else { //listener not found
                  
                  }
                  

                  这篇关于Symfony 2:在 ContainerAwareCommand 中禁用 Doctrine 事件侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                  How to parse django style template tags(如何解析 django 样式模板标签)
                  What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                  How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                  What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                  php in background exec() function(php 后台 exec() 函数)
                    1. <tfoot id='NsqpT'></tfoot>

                          <tbody id='NsqpT'></tbody>

                        <small id='NsqpT'></small><noframes id='NsqpT'>

                        <i id='NsqpT'><tr id='NsqpT'><dt id='NsqpT'><q id='NsqpT'><span id='NsqpT'><b id='NsqpT'><form id='NsqpT'><ins id='NsqpT'></ins><ul id='NsqpT'></ul><sub id='NsqpT'></sub></form><legend id='NsqpT'></legend><bdo id='NsqpT'><pre id='NsqpT'><center id='NsqpT'></center></pre></bdo></b><th id='NsqpT'></th></span></q></dt></tr></i><div id='NsqpT'><tfoot id='NsqpT'></tfoot><dl id='NsqpT'><fieldset id='NsqpT'></fieldset></dl></div>

                      • <legend id='NsqpT'><style id='NsqpT'><dir id='NsqpT'><q id='NsqpT'></q></dir></style></legend>

                            <bdo id='NsqpT'></bdo><ul id='NsqpT'></ul>