if (method_exists($query, 'setFactory')) {
$query->setFactory($this);
}
+ $list->registerQuery($query);
return $query;
}
private $_driver;
/**
+ * The list of registered queries.
+ *
+ * @var array
+ */
+ private $_queries = array();
+
+ /**
* Constructor.
*
* @param Horde_Kolab_Storage_Driver $driver The primary connection driver.
*/
public function synchronize()
{
+ foreach ($this->_queries as $query) {
+ $query->synchronize();
+ }
+ }
+
+ /**
+ * Register a query to be updated if the underlying data changes.
+ *
+ * @param Horde_Kolab_Storage_Query $query The query to register.
+ *
+ * @return NULL
+ */
+ public function registerQuery(Horde_Kolab_Storage_Query $query)
+ {
+ $this->_queries[] = $query;
}
}
\ No newline at end of file
*/
public function synchronize()
{
- $this->_list->synchronize();
-
$this->_list_cache->store(
$this->_list->listFolders(),
$this->_list->listFolderTypes()
);
+ $this->_list->synchronize();
+
$this->_list_cache->save();
$this->_init = true;
}
+
+ /**
+ * Register a query to be updated if the underlying data changes.
+ *
+ * @param Horde_Kolab_Storage_Query $query The query to register.
+ *
+ * @return NULL
+ */
+ public function registerQuery(Horde_Kolab_Storage_Query $query)
+ {
+ $this->_list->registerQuery($query);
+ }
}
\ No newline at end of file
)
);
}
+
+ /**
+ * Register a query to be updated if the underlying data changes.
+ *
+ * @param Horde_Kolab_Storage_Query $query The query to register.
+ *
+ * @return NULL
+ */
+ public function registerQuery(Horde_Kolab_Storage_Query $query)
+ {
+ $this->_list->registerQuery($query);
+ }
}
\ No newline at end of file
*/
interface Horde_Kolab_Storage_Queriable
{
+ /**
+ * Register a query to be updated if the underlying data changes.
+ *
+ * @param Horde_Kolab_Storage_Query $query The query to register.
+ *
+ * @return NULL
+ */
+ public function registerQuery(Horde_Kolab_Storage_Query $query);
}
implements Horde_Kolab_Storage_Query
{
public $called = false;
+ public $synchronized = false;
/**
* Constructor.
*/
public function synchronize()
{
+ $this->synchronized = true;
}
}
\ No newline at end of file
);
$this->assertTrue($list instanceOf Horde_Kolab_Storage_Queriable);
}
+
+ public function testQuerySynchronization()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $list = new Horde_Kolab_Storage_List_Base(
+ $this->getNullMock(),
+ $factory
+ );
+ $query = $factory->createListQuery(
+ 'Horde_Kolab_Storage_Stub_FactoryQuery',
+ $list
+ );
+ $list->registerQuery($query);
+ $list->synchronize();
+ $this->assertTrue($query->synchronized);
+ }
}