Ejemplo n.º 1
0
 /**
  * @param \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult $categories
  * @return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult
  */
 protected function removeExcludeCategories(\TYPO3\CMS\Extbase\Persistence\Generic\QueryResult $categories)
 {
     $excludeCategories = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->settings['excludeCategories']);
     if (count($excludeCategories)) {
         /** @var $category \Evoweb\SfBooks\Domain\Model\Category */
         foreach ($categories as $category) {
             if (in_array($category->getUid(), $excludeCategories)) {
                 $categories->offsetUnset($categories->key());
             }
         }
     }
     return $categories;
 }
 /**
  * Enhances the default initialize function and overlays the found
  * "NewsOther" records with the actual news
  */
 protected function initialize()
 {
     if (!is_array($this->queryResult)) {
         parent::initialize();
         $this->queryResult = $this->getOverlayedNews();
     }
 }
Ejemplo n.º 3
0
 /**
  * Loads the objects this QueryResult is supposed to hold
  *
  * @return void
  */
 protected function initialize()
 {
     parent::initialize();
     if (!$this->shuffled) {
         shuffle($this->queryResult);
         $this->shuffled = true;
     }
 }
Ejemplo n.º 4
0
 /**
  * @test
  */
 public function iteratorMethodsAreCorrectlyImplemented()
 {
     $array1 = array('foo' => 'Foo1', 'bar' => 'Bar1');
     $array2 = array('foo' => 'Foo2', 'bar' => 'Bar2');
     $this->assertEquals($array1, $this->queryResult->current());
     $this->assertTrue($this->queryResult->valid());
     $this->queryResult->next();
     $this->assertEquals($array2, $this->queryResult->current());
     $this->assertTrue($this->queryResult->valid());
     $this->assertEquals(1, $this->queryResult->key());
     $this->queryResult->next();
     $this->assertFalse($this->queryResult->current());
     $this->assertFalse($this->queryResult->valid());
     $this->assertNull($this->queryResult->key());
     $this->queryResult->rewind();
     $this->assertEquals(0, $this->queryResult->key());
     $this->assertEquals($array1, $this->queryResult->current());
 }
 /**
  * Debugs a SQL query from a QueryResult
  *
  * @param \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult $queryResult
  * @param boolean $explainOutput
  * @return void
  */
 public function debugQuery(\TYPO3\CMS\Extbase\Persistence\Generic\QueryResult $queryResult, $explainOutput = false)
 {
     $GLOBALS['TYPO3_DB']->debugOuput = 2;
     if ($explainOutput) {
         $GLOBALS['TYPO3_DB']->explainOutput = true;
     }
     $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true;
     $queryResult->toArray();
     var_dump($GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
     $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = false;
     $GLOBALS['TYPO3_DB']->explainOutput = false;
     $GLOBALS['TYPO3_DB']->debugOuput = false;
 }
Ejemplo n.º 6
0
 /**
  * Get a list with all default fields
  *
  * @param QueryResult $mails
  * @return array
  */
 protected function getDefaultFieldListFromFirstMail(QueryResult $mails = null)
 {
     $fieldList = array();
     if ($mails !== null) {
         /** @var Mail $mail */
         $mail = $mails->getFirst();
         if ($mail !== null) {
             foreach ($mail->getForm()->getPages() as $page) {
                 /** @var Field $field */
                 foreach ($page->getFields() as $field) {
                     if ($field->isBasicFieldType()) {
                         $fieldList[] = $field->getUid();
                     }
                 }
             }
         }
     }
     return $fieldList;
 }