Hey, I've got a table in my DB full of events that my application needs to
process at various times.

Table structure is something like:

ID | type | time
--------------------
1      1        17-04-2012 22:20:10
2      1        17-04-2012 22:22:07

So before, when I was doing everything procedurally, I would have a cronjob
that ran every 1 minute, looped through the DB and processed each one. As
that's only every minute, the users weren't always 100% up to date and need
to be, so they'd also process the events everytime they loaded a page.

So now I'm attempting to recreate my app with ZF2 I'm a little confused as
to where this global code is suppoesd to exist. Eventually I want the code
to be run server-side, which I guess would require a NodeJS server listening
to the events and running the PHP code at the correct times to process them
but for now I'll have to have it checking on every page load again.

So, where can I put this? At the moment I'm thinking, a model called
GameEventManager.php and DIing it into every single controller then run at
the top of each action $this->gameEventManager->processEvents();

But that's pretty annoying having to Copy and Paste everything, also when it
comes to cronning it, what am I meant to call as it requires all the web-app
to inject everything, right? Right now I'm thinking Curl the website to get
that call done.

If I'm to use ZF2 events, where can this code exist? The only place I know
that runs on every page load is Module.php, so I guess I would need to
create an event there, but can it access all the DI stuff?

Thanks, Dom

--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-and-Application-events-tp4565914p4565914.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to