コード例 #1
0
ファイル: ListTest.php プロジェクト: Konafets/oelib
 /**
  * @test
  */
 public function purgeCurrentForModelWithUidRemovesModelFromGetUids()
 {
     $model = new Tx_Oelib_Tests_Unit_Fixtures_TestingModel();
     $model->setUid(1);
     $this->subject->add($model);
     $this->modelStorage[] = $model;
     $this->subject->rewind();
     $this->subject->purgeCurrent();
     self::assertSame('', $this->subject->getUids());
 }
コード例 #2
0
ファイル: DataMapper.php プロジェクト: Konafets/oelib
 /**
  * Finds all records that are related to $model via the field $key.
  *
  * @param Tx_Oelib_Model $model
  *        the model to which the matches should be related
  * @param string $relationKey
  *        the key of the field in the matches that should contain the UID
  *        of $model
  * @param Tx_Oelib_List<Tx_Oelib_Model> $ignoreList
  *        related records that should _not_ be returned
  *
  * @return Tx_Oelib_List<Tx_Oelib_Model> the related models, will be empty if there are no matches
  */
 public function findAllByRelation(Tx_Oelib_Model $model, $relationKey, Tx_Oelib_List $ignoreList = NULL)
 {
     if (!$model->hasUid()) {
         throw new InvalidArgumentException('$model must have a UID.', 1331319915);
     }
     if ($relationKey === '') {
         throw new InvalidArgumentException('$key must not be empty.', 1331319921);
     }
     $ignoreClause = '';
     if ($ignoreList !== NULL && !$ignoreList->isEmpty()) {
         $ignoreUids = $ignoreList->getUids();
         // deals with the case of $ignoreList having only models without UIDs
         if ((string) $ignoreUids !== '') {
             $ignoreClause = ' AND uid NOT IN(' . $ignoreUids . ')';
         }
     }
     return $this->findByWhereClause($relationKey . ' = ' . $model->getUid() . $ignoreClause);
 }