In this entry, let's learn about XCube_ActionFilter. ActionFilter is the idea borrowed from mojavi2. If you know not mojavi2 but C or assembly, you may remember the technic that you push function pointers to an array, and call these in order after. ActionFilter is like that techinc. Legacy_Controller creates an instance of various sub-classes of XCube_ActionFilter, and pushes these instances to mFilterChain which is a member property of the controller.

Ok now, see the class design of XCube_ActionFilter. Keep in mind that this design may be changed a little until the regular version of XOOPS Cube.
XCube_ActionFilter has two member functions, which are preFilter() and preBlockFilter(). These two member functions shall be called by Legacy_Controller, at the specific timing. preFilter() is called at the first part of executeCommon() of Legacy_Controller. I call executeCommon() 'common process' because it's like common.php of XOOPS2.

In preFilter(), you can't use the database instance, because this member function is just first part of the common process. Yes, this member function is called before Legacy_Controller tries to create an instance of the database class.

What is preFilter() used for? You can use it to insert your logic in the first part of the common process. Because Legacy_Controller sets up itself little the instant of preFilter(), the use of preFilter() may be limited. You can use many instances to access resources of XOOPS Cube in preBlockFilter(), but in preFilter() you can't do it.

Therefore, you may use preFilter() instead of the mainfile.php hack like XoopsProtector. In other words, you may use preFilter() for the logic which is too late if it's called at the timing of preBlockFilter().

preBlockFilter() is called just before Legacy_Controller begins the preparation of block. preBlockFilter() is convenience, because you can use many functions and many instances in this member function. For example, it's easy to access the database through the database instance or XoopsObject handlers. Perhaps, preBlockFilter() might be used in 99% of all cases.

Front page   Freeze Diff Backup Copy Rename ReloadPrint View   New Page Page list Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom) Powered by xpWiki
Counter: 16819, today: 3, yesterday: 1
Princeps date: 2007-01-14 (Sun) 11:29:12
Last-modified: 2007-01-14 (Sun) 11:29:12 (JST) (4605d) by Anonymous

Welcome | News | Overview | Documentation | Forum | Tutorialstop
Brasilian | French | German | Greek | Japanese | Korean | Russian | T-Chinese
Powered by XOOPS Cube 2001-2011 The XOOPS Cube Project