/** * Returns a specific collection referenced by uid. * * @param integer $uid * @return mixed */ public function render($uid) { if (null !== $uid) { /** @var \TYPO3\CMS\Core\Collection\AbstractRecordCollection $collection */ $collection = $this->collectionRepository->findByUid($uid); if (null !== $collection) { $collection->loadContents(); } return $collection; } return null; }
/** * Finds a record collection by uid. * * @todo the parent function throws already an exception if not found * @param integer $uid The uid to be looked up * @return NULL|\TYPO3\CMS\Core\Resource\Collection\AbstractFileCollection * @throws \RuntimeException */ public function findByUid($uid) { $object = parent::findByUid($uid); if ($object === NULL) { throw new \RuntimeException('Could not find row with uid "' . $uid . '" in table "' . $this->table . '"', 1314354065); } return $object; }
/** * Finds a record collection by uid. * * @param int $uid The uid to be looked up * @return NULL|Collection\AbstractFileCollection * @throws ResourceDoesNotExistException */ public function findByUid($uid) { $object = parent::findByUid($uid); if ($object === null) { throw new ResourceDoesNotExistException('Could not find row with uid "' . $uid . '" in table "' . $this->table . '"', 1314354066); } return $object; }
/** * @test */ public function doesFindByTypeAndTableNameReturnObjects() { $testUid = rand(1, 1000); $testTable = uniqid('sys_collection_'); $type = \TYPO3\CMS\Core\Collection\RecordCollectionRepository::TYPE_Static; $this->databaseMock->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnCallback(array($this, 'getRowsCallback'))); $this->getRowsCallbackReturnValue = array(array('uid' => $testUid, 'type' => $type, 'table_name' => $this->testTableName), array('uid' => $testUid, 'type' => $type, 'table_name' => $this->testTableName)); $objects = $this->fixture->findByTypeAndTableName($type, $testTable); $this->assertEquals(2, count($objects)); $this->assertInstanceOf('TYPO3\\CMS\\Core\\Collection\\StaticRecordCollection', $objects[0]); $this->assertInstanceOf('TYPO3\\CMS\\Core\\Collection\\StaticRecordCollection', $objects[1]); }