/** * @param OrmResultAfter $event */ public function onResultAfter(OrmResultAfter $event) { if (!$this->paginationManager->isEnabled()) { return; } $dataGrid = $event->getDatagrid(); if (!$this->paginationManager->isDatagridApplicable($dataGrid)) { return; } // clear all data as long as we can't guarantee that storage data is valid $entityName = $this->getEntityName($dataGrid); $this->storage->clearData($entityName); }
/** * @param boolean $enabled * @param boolean $request * @param array $source * @param boolean $expected * * @dataProvider clearDataDataProvider */ public function testClearData($enabled, $request, $source, $expected) { $this->setEnabled($enabled); if (true === $request) { $this->setRequest(); } $this->setStorage($source['storage_data']); $result = $this->storage->clearData(self::ENTITY_NAME, $source['scope']); $viewScopesIds = $this->storage->getEntityIds($this->entity, EntityPaginationManager::VIEW_SCOPE); $editScopesIds = $this->storage->getEntityIds($this->entity, EntityPaginationManager::EDIT_SCOPE); $this->assertEquals($expected['result'], $result); if ($expected['result'] === true) { $this->assertEquals($expected['view_scope_ids'], $viewScopesIds); $this->assertEquals($expected['edit_scope_ids'], $editScopesIds); } }