/** * @test */ public function addSimpleObjectTest() { $newBlogTitle = 'aDi1oogh'; $newBlog = $this->objectManager->create('ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog'); $newBlog->setTitle($newBlogTitle); /** @var \ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository $blogRepository */ $this->blogRepository->add($newBlog); $this->persistentManager->persistAll(); $newBlogCount = $this->getDatabaseConnection()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_blog', 'title = \'' . $newBlogTitle . '\''); $this->assertSame(1, $newBlogCount); }
/** * @test */ public function addObjectSetsDefinedLanguageTest() { $newBlogTitle = 'aDi1oogh'; $newBlog = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog'); $newBlog->setTitle($newBlogTitle); $newBlog->_setProperty('_languageUid', -1); /** @var \ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository $blogRepository */ $this->blogRepository->add($newBlog); $this->persistentManager->persistAll(); $newBlogRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', 'tx_blogexample_domain_model_blog', 'title = \'' . $newBlogTitle . '\''); $this->assertEquals(-1, $newBlogRecord['sys_language_uid']); }
/** * @test * @expectedException \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException */ public function addChecksObjectType() { $this->repository->_set('objectType', 'ExpectedObjectType'); $this->repository->add(new \stdClass()); }
/** * @param object $object */ public function add($object) { $this->internalObjectCounter++; parent::add($object); if ($this->internalObjectCounter % $this->persistCacheAfterItems === 0) { $this->persistenceManager->persistAll(); } }
/** * (non-PHPdoc) * * @see \TYPO3\CMS\Extbase\Persistence\Repository::add() */ public function add($object) { parent::add($object); $this->objectManager->get('Tx_Yag_PageCache_PageCacheManager')->markObjectUpdated($object); }
/** * Adds an object to this repository * * @param Document $object The object to add * @throws NoDatabaseSelectedException if the given object and the repository have no database set * @return void * @api */ public function add($object) { if (!$object->_getDb()) { $currentDatabase = $this->getDatabase(); if (!$currentDatabase) { throw new NoDatabaseSelectedException('The given object and the repository have no database set', 1389257938); } $object->_setDb($currentDatabase); } $this->willChangeDocument($object); parent::add($object); $this->didChangeDocument($object); }
/** * call an event before adding an event to the repo * * @see Classes/Persistence/Tx_Extbase_Persistence_Repository::add() */ public function add($object) { $object->preCreate(); parent::add($object); }
/** * @param $fileObject * @param string $key * @return \TYPO3\CMS\Extbase\Error\Error|void * @throws \Exception */ public function add($fileObject, $key = '') { $baseStoragePath = $this->getBaseStoragePath($key); if ($fileObject->getIsSaved() == false) { $relativeDestinationPath = $this->getRelativeDestinationPath($fileObject, $baseStoragePath); $destinationFilename = $this->getDestinationFilename($fileObject); $results = $this->moveToDestination($relativeDestinationPath, $destinationFilename, $fileObject, true); if ($results instanceof \TYPO3\CMS\Extbase\Error\Error) { return $results; } else { $fileObject->setIsSaved(true); return parent::add($fileObject); } } else { return parent::add($fileObject); } }
/** * Adds the incoming pair to the persistence layer * * @param PairInterface $pair Pair to persist * * @return void * * @throws IllegalObjectTypeException If incoming object is not of expected type */ public function attach(PairInterface $pair) { parent::add($pair); }