protected static function resolveDynamicSearchMetadata($searchModel, $metadata, SearchAttributesDataCollection $dataCollection) { $sanitizedDynamicSearchAttributes = $dataCollection->getSanitizedDynamicSearchAttributes(); if ($sanitizedDynamicSearchAttributes == null) { return $metadata; } $dynamicStructure = $dataCollection->getDynamicStructure(); if ($sanitizedDynamicSearchAttributes != null) { $dynamicSearchMetadataAdapter = new DynamicSearchDataProviderMetadataAdapter($metadata, $searchModel, Yii::app()->user->userModel->id, $sanitizedDynamicSearchAttributes, $dynamicStructure); $metadata = $dynamicSearchMetadataAdapter->getAdaptedDataProviderMetadata(); } return $metadata; }
public function testResolveFilteredByFromSourceData() { $searchModel = new AFilteredBySearchFormTestModel(new A()); $dataCollection = new SearchAttributesDataCollection($searchModel); $dataCollection->resolveFilteredByFromSourceData(); $this->assertEmpty($searchModel->filteredBy); $_GET['AFilteredBySearchFormTestModel']['filteredBy'] = 'all'; $dataCollection->resolveFilteredByFromSourceData(); $this->assertEquals('all', $searchModel->filteredBy); //Since the sourceDate dont have the filteredBy, no new value will be set $dataCollection->setSourceData(array()); $dataCollection->resolveFilteredByFromSourceData(); $this->assertEquals('all', $searchModel->filteredBy); $dataCollection->setSourceData(array('AFilteredBySearchFormTestModel' => array('filteredBy' => 'none'))); $dataCollection->resolveFilteredByFromSourceData(); $this->assertEquals('none', $searchModel->filteredBy); }
public function testKanbanBoardMethods() { $searchModel = new AAASearchFormTestModel(new AAA()); $kanbanBoard = new KanbanBoard(new AAA(), 'industry'); $kanbanBoard->setGroupByAttributeVisibleValues(array('a', 'b')); $kanbanBoard->setSelectedTheme('someTheme'); $searchModel->setKanbanBoard($kanbanBoard); $dataCollection = new SearchAttributesDataCollection($searchModel); $this->assertTrue($dataCollection->hasKanbanBoard()); $this->assertEquals($kanbanBoard, $dataCollection->getKanbanBoard()); $this->assertFalse($dataCollection->shouldClearStickyForKanbanBoard()); $this->assertEquals(array('a', 'b'), $dataCollection->getKanbanBoardGroupByAttributeVisibleValuesFromModel()); $this->assertEquals('someTheme', $dataCollection->getKanbanBoardSelectedThemeFromModel()); }
/** * @param SearchAttributesDataCollection $dataCollection * @param array $stickyData */ protected static function resolveKanbanBoardDataByCollection(SearchAttributesDataCollection $dataCollection, &$stickyData) { if ($dataCollection->hasKanbanBoard() && $dataCollection->getKanbanBoard()->getIsActive() && !$dataCollection->shouldClearStickyForKanbanBoard()) { $stickyData[KanbanBoard::GROUP_BY_ATTRIBUTE_VISIBLE_VALUES] = $dataCollection->getKanbanBoardGroupByAttributeVisibleValuesFromModel(); $stickyData[KanbanBoard::SELECTED_THEME] = $dataCollection->getKanbanBoardSelectedThemeFromModel(); } elseif ($dataCollection->hasKanbanBoard() && $dataCollection->shouldClearStickyForKanbanBoard()) { unset($stickyData[KanbanBoard::GROUP_BY_ATTRIBUTE_VISIBLE_VALUES]); unset($stickyData[KanbanBoard::SELECTED_THEME]); } }