/**
  * @expectedException \Dewdrop\Fields\Exception
  */
 public function testExceptionIsThrownWhenModifierDoesNotReturnASelectObject()
 {
     $modifier = $this->getMock('\\Dewdrop\\Fields\\Helper\\SelectModifierInterface', array('modifySelect', 'setPrefix', 'getPrefix', 'matchesName'), array());
     $select = $this->model->select()->from('dewdrop_test_fruits');
     $modifier->expects($this->any())->method('modifySelect')->will($this->returnValue(null));
     $this->listing->registerSelectModifier($modifier);
     $this->listing->getModifiedSelect($this->getFields());
 }
Exemple #2
0
 /**
  * Get a \Dewdrop\Fields\Listing object that allows the component to
  * retrieve records for viewing.  The Listing handles applying user sorts
  * and filters.
  *
  * @return Listing
  */
 public function getListing()
 {
     if (!$this->listing) {
         $this->listing = new Listing($this->getPrimaryModel()->selectAdminListing(), $this->getPrimaryModel()->field('user_id'));
         $model = $this->getPrimaryModel();
         $columns = $model->getMetadata('columns');
         if (array_key_exists('deleted', $columns)) {
             $deletedRecordsModifier = new DeletedRecordsModifier($this->getRequest(), $model->field('deleted'));
             $this->listing->registerSelectModifier($deletedRecordsModifier);
         }
     }
     return $this->listing;
 }
 /**
  * Using the Listing's fetchData() method, grab an array of IDs.  Depending upon
  * the selection mode the user has chosen, we may or may not paginate the result
  * set.
  *
  * @param bool $usePagination
  * @return array
  */
 private function fetchIdsFromListing($usePagination)
 {
     $out = [];
     if (!$usePagination) {
         $pagination = $this->listing->getSelectModifierByName('SelectPaginate');
         $this->listing->removeSelectModifierByName('SelectPaginate');
     }
     foreach ($this->listing->fetchData($this->fields) as $row) {
         $out[] = $row[$this->listing->getPrimaryKey()->getName()];
     }
     if (!$usePagination && isset($pagination)) {
         $this->listing->registerSelectModifier($pagination);
     }
     return $out;
 }