File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
code/libraries/joomlatools-components/files/model Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
class ComFilesModelContainers extends KModelDatabase
17
17
{
18
+ public static $ containers = array ();
19
+
18
20
protected function _buildQueryWhere (KDatabaseQueryInterface $ query )
19
21
{
20
22
parent ::_buildQueryWhere ($ query );
@@ -25,4 +27,33 @@ protected function _buildQueryWhere(KDatabaseQueryInterface $query)
25
27
$ query ->where ('tbl.title LIKE :search ' )->bind (array ('search ' => '% ' .$ state ->search .'% ' ));
26
28
}
27
29
}
30
+
31
+ /**
32
+ * Override fetch method to handle caching of unique result
33
+ *
34
+ * @param KModelContext $context
35
+ * @return KModelEntityInterface
36
+ */
37
+ protected function _actionFetch (KModelContext $ context )
38
+ {
39
+ $ state = $ this ->getState ();
40
+
41
+ if ($ state ->isUnique () && $ state ->has ('slug ' ))
42
+ {
43
+ $ slug = $ state ->slug ;
44
+
45
+ if (!isset (self ::$ containers [$ slug ]))
46
+ {
47
+ $ container = parent ::_actionFetch ($ context );
48
+
49
+ if (!$ container ->isNew ()) {
50
+ self ::$ containers [$ slug ] = $ container ;
51
+ }
52
+ }
53
+ else $ container = self ::$ containers [$ slug ];
54
+ }
55
+ else $ container = parent ::_actionFetch ($ context );
56
+
57
+ return $ container ;
58
+ }
28
59
}
You can’t perform that action at this time.
0 commit comments