disable Doctrine entity event - doctrine-orm

I need create another new Entity in entity preFlush event in case when current entity was changed. In preFlush I don't have computed change set, if I trigger compute change set, to avoid infinite loop preFlush listener should be disabled.
How can I do that? Does another solution to know if entity was really changed exists?

Related

make a record read-only in vTiger once it is saved

I have a question please..
how can I make a record become read-only once a particular field has a particular value. for eg. status field has the value "validate"
Think you :)
Vtiger does not offer that functionality through configuration means. However you can create a "before save" event handler. That is code that gets executed every time a record gets saved (but just before the saving is final).
In a nutshell, you have to first create the handler (a php class that extends the VTEventHandler class), then inside that class create the function handleEvent($eventName, $entityData). Inside the function you would write your logic. Finally, you have to register your handler by calling vtlib's Vtiger_Event::register.
In your event handler you can check what the value of the field was before being edited and after it was edited (but before being saved). So, if the field value prior to editing was "validate", in your code you just have to make sure that value stays that way.
You can find more on event handlers here: https://wiki.vtiger.com/index.php/Eventing

Running functions on an emberjs component

I am wondering what is the best way to control behaviour on a component.
In my case I have a {{stop-watch}} component.
I want to start, stop and reset the component via the routes using the {{stop-watch}} in their template. The start and reset function should allow me to somehow pass the number of seconds to run for.
How can this be done when a component only really supports bindings and not the ability to execute behaviour?
This is the only way I can think of doing it. In this case; isStarted,isStopped and isReset would be boolean variables and I would toggle them to control the component.
{{stop-watch start=isStarted stop=isStopped reset=isReset timeout=timoutSeconds}}
Toggle like this for each property binding in the controller
this.set('isStarted', !this.get('isStarted'));
Observe like this for each property in the component
startUpdated : function() {
//start the timer
}.property('start')
In my opinion the above solution is very inelegant and verbose and there must be a better way to achieve this.
Are the any best practices for this scenario?
You should have a model that possesses a state and methods to control the state.
You set up an instance of the model in the route, then you'll be able to control it both in the controller and the stop-watch component.
The component will automatically update its looks based on the properties of the model, and will be able to call methods on the model via actions on the component.

Is there a way to uninstall eventfilter in qt?

I need event filter only for some time, is there a way of uninstalling it later on?
Please read about how the event system works in Qt here. This is crucial for the basic understanding, particularly this paragraph:
The QObject::installEventFilter() function enables this by setting up an event filter, causing a nominated filter object to receive the events for a target object in its QObject::eventFilter() function. An event filter gets to process events before the target object does, allowing it to inspect and discard the events as required. An existing event filter can be removed using the QObject::removeEventFilter() function.
Having that read, you can see that there is a counter-part for installEventFilter, not surprisingly, it is called removeEventFilter. Here is the Qt 5 documentation to it:
void QObject::removeEventFilter(QObject * obj)
Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.
All event filters for this object are automatically removed when this object is destroyed.
It is always safe to remove an event filter, even during event filter activation (i.e. from the eventFilter() function).
Yes there is. It's a function called QObject::removeEventFilter.
From Qt Docu:
void QObject::removeEventFilter ( QObject * obj )
Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.
All event filters for this object are automatically removed when this object is destroyed.
It is always safe to remove an event filter, even during event filter activation (i.e. from the eventFilter() function).

QStateMachine immediate transition from dummy state

In order to set an object property depending on a transition I need two intermediate states that immediately transition further:
A initial state
Ta Tb different transitions
Aa Ab (these are only used to set an objects property depending on transition)
TB TB both should immediately "transit"
B objects property used via entered()/exited() signals
(Alternatively, B probably could be duplicated to set each respective property directly.)
Could a state's entered() signal be used as its own transition source?
Simply add an unconditional transition to the state:
TB->addTransition(B);
This is idiomatic and also cheaper than using a QSignalTransition coupled to the entered() signal.
Ref: http://doc.qt.io/qt-5/statemachine-api.html#targetless-transitions
Yes, the QState's entered() signal can be used as transition source.

Ember.js textField change event

I just start to learn ember.js
Why this code http://jsfiddle.net/alexchetv/RVNzP/ don't work properly -- App.MyTextField.change() execution is triggered only after MyTextField loses focus?
Alternative code with the same functionality works as expected.
Keep in mind that handlers on your Ember.Views (change, select, click, etc) are bound to normal HTML DOM events. "onchange" only gets called on an input field when the field loses focus and has changed, not any time the value is modified. You should observe 'value' if you want to be notified of changes to the displayed value.
Here's a working solution.
What I've done is made formDirty a computed value, which recomputes upon changes in the input. Ember, unlike the native "change" event, updates the the Input's value on each keystroke (copy/paste event etc).
Ember's binding makes sure the peopleController is always updated with the input value, thus also updating the computed field formDirty.
Note that if you add more inputs, you must tell the computed property to listen to its events, e.g.
formDirty: function() {
return !Ember.empty(this.get('fName')) && !Ember.empty(this.get('lName'));;
}.property('lName', 'fName').cacheable() // <- dependencies
cacheable() is used for performance sake only, meaning don't computed again until the dependencies change.