eventListener on frontend

EventListeners are global but how can I run an addClient event only on account creation on frontend and not on account creation of admin area?

PHP has nothing to do with EventListeners - this is a JavaScript topic. Either that or you’re using a PHP framework with a listener system. The question as it stands is too ambiguous to allow for a useful answer.

Aren’t you familiar with php eventListeners?
See this: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html
You must move back the thread to php forum, you did a wrong action, as you seem to be newbie in php.

You titled your thread “frontend”.

PHP is not frontend. It’s perfectly logical to assume you meant Javascript since you also gave us the keyword “eventListener”. A big Javascript term. You gave no detail in your thread. He wasn’t the only one who thought you meant Javascript. Reread your first post. There is no detail there. You forced presumptions from us.

I moved it back to PHP.

As Michael said - your first post was too ambiguous for us to help. You can blame only yourself for this.


I applogize. I meant “frontend” I meant the create account form/controller where some creates an account on site, not the create account manager in admin area! Sorry for bad English.

I meant I want to call addClient eventListener only when a user creates account on site, not when an admin creates user account in admin area. Account creation is possible from both admin area and from main site when a normal visitor sees the form. Call the eventListener only when a user creates it not when an admin creates it in admin area. How is it possible?

While I flagged it, I didn’t move it - only Advisors can do that. As for being a newbie, I’ve been working with PHP professionally for 10 years so, no - I am not - not by a long shot. Throwing such hyperbole around will not endear you to anyone.

I am familiar with the Subject/Observer pattern and have used it, but I haven’t dealt with Doctrine’s particular implementation of it. I’m not a fan of Doctrine in the slightest - I’ve had to work with it before and found it to be cumbersome and restraining at best. ORM systems are something I’m leery of in general, in my experience they rarely save any time and misused they can increase the work load on the application development team.

Calling such an “eventListener” is misleading. Barring websockets implementations, at the end of the day in PHP there will be one request by the client and one response by the server. Even if mislabeled, in the Subject-Observer pattern the subject notifies the observers when some action has taken place. This isn’t an event in the classic sense of the word which is always a user initiated action such as a mouse-click, keystroke or what have you. The event triggers its listeners which then drive the code forward from there - this is why JavaScript can be said to be an EDOOPL (Event-Driven Object Oriented Programming Language) though it should be noted that JavaScript’s inheritance model is very unlike that of PHP or most other programming languages. Since I heavily use both languages I tend to reserve the term events in that mindspace - it just doesn’t get used in PHP much. Most PHP programs use the term “hook” to describe a function called when an action inside a model or controller of the program takes place.

Thanks. That addUser eventListener/hook invoked whenever a new user entity saved, no matter created via account form or via admin area. How can I tell the script to call the entityListener only when a user added by account form and not when added via admin area.

I appreciate an answer to this http://stackoverflow.com/questions/27708285/how-to-apply-an-event-only-on-frontend/27724254
How to have the flag that user suggested me there? A constant is good as I said there? Or is there any better way?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.