Example #1
0
 public function testQuery()
 {
     $data = $this->handler->buildData($this->lang)->getData();
     $max = count($data);
     if ($max > 50) {
         $max = 50;
     }
     for ($i = 0; $i < $max;) {
         $content = ContentQuery::create()->findPk($data[$i]["id"]);
         $this->assertNotNull($content);
         $content->setLocale($this->lang->getLocale());
         $this->assertEquals($content->getTitle(), $data[$i]["title"]);
         $this->assertEquals($content->getDescription(), $data[$i]["description"]);
         $this->assertEquals($content->getChapo(), $data[$i]["chapo"]);
         $this->assertEquals($content->getPostscriptum(), $data[$i]["conclusion"]);
         $this->assertEquals($content->getMetaTitle(), $data[$i]["seo_title"]);
         $this->assertEquals($content->getMetaDescription(), $data[$i]["seo_description"]);
         $this->assertEquals($content->getMetaKeywords(), $data[$i]["seo_keywords"]);
         do {
             if (null !== $data[$i]["folder_id"]) {
                 $folder = FolderQuery::create()->findPk($data[$i]["folder_id"]);
                 $this->assertNotNull($folder);
                 $contentFolder = ContentFolderQuery::create()->filterByContent($content)->filterByFolder($folder)->findOne();
                 $this->assertNotNull($contentFolder);
                 $folder->setLocale($this->lang->getLocale());
                 $this->assertEquals($folder->getTitle(), $data[$i]["folder_title"]);
                 $this->assertEquals($contentFolder->getDefaultFolder(), (bool) (int) $data[$i]["is_default_folder"]);
             }
         } while (isset($data[++$i]["id"]) && $data[$i - 1]["id"] === $data[$i]["id"] && ++$max);
     }
 }
Example #2
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Content is new, it will return
  * an empty collection; or if this Content has previously
  * been saved, it will retrieve related ContentFolders from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Content.
  *
  * @param      Criteria $criteria optional Criteria object to narrow the query
  * @param      ConnectionInterface $con optional connection object
  * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return Collection|ChildContentFolder[] List of ChildContentFolder objects
  */
 public function getContentFoldersJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
 {
     $query = ChildContentFolderQuery::create(null, $criteria);
     $query->joinWith('Folder', $joinBehavior);
     return $this->getContentFolders($query, $con);
 }
Example #3
0
 /**
  * @depends testAddFolderToContent
  */
 public function testRemoveFolder(ContentFolder $association)
 {
     $event = new ContentRemoveFolderEvent($association->getContent(), $association->getFolder()->getId());
     $event->setDispatcher($this->dispatcher);
     $contentAction = new Content($this->getContainer());
     $contentAction->removeFolder($event);
     $testAssociation = ContentFolderQuery::create()->filterByContent($association->getContent())->filterByFolder($association->getFolder())->findOne();
     $this->assertNull($testAssociation);
 }
Example #4
0
 public function removeFolder(ContentRemoveFolderEvent $event)
 {
     $contentFolder = ContentFolderQuery::create()->filterByContent($event->getContent())->filterByFolderId($event->getFolderId())->findOne();
     if (null !== $contentFolder) {
         $contentFolder->delete();
     }
 }
Example #5
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see ContentFolder::setDeleted()
  * @see ContentFolder::isDeleted()
  */
 public function delete(ConnectionInterface $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildContentFolderQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * Performs an INSERT on the database, given a ContentFolder or Criteria object.
  *
  * @param mixed               $criteria Criteria or ContentFolder object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from ContentFolder object
     }
     // Set the correct dbName
     $query = ContentFolderQuery::create()->mergeWith($criteria);
     try {
         // use transaction because $criteria could contain info
         // for more than one table (I guess, conceivably)
         $con->beginTransaction();
         $pk = $query->doInsert($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     return $pk;
 }
Example #7
0
 /**
  * @param LoopResultRow $loopResultRow
  * @param ContentModel $content
  * @param int $defaultFolderId
  */
 private function findNextPrev(LoopResultRow $loopResultRow, ContentModel $content, $defaultFolderId)
 {
     if ($this->getWithPrevNextInfo()) {
         $currentPosition = ContentFolderQuery::create()->filterByFolderId($defaultFolderId)->filterByContentId($content->getId())->findOne()->getPosition();
         // Find previous and next content
         $previousQuery = ContentFolderQuery::create()->filterByFolderId($defaultFolderId)->filterByPosition($currentPosition, Criteria::LESS_THAN);
         $nextQuery = ContentFolderQuery::create()->filterByFolderId($defaultFolderId)->filterByPosition($currentPosition, Criteria::GREATER_THAN);
         if (!$this->getBackendContext()) {
             $previousQuery->useContentQuery()->filterByVisible(true)->endUse();
             $previousQuery->useContentQuery()->filterByVisible(true)->endUse();
         }
         $previous = $previousQuery->orderByPosition(Criteria::DESC)->findOne();
         $next = $nextQuery->orderByPosition(Criteria::ASC)->findOne();
         $loopResultRow->set("HAS_PREVIOUS", $previous != null ? 1 : 0)->set("HAS_NEXT", $next != null ? 1 : 0)->set("PREVIOUS", $previous != null ? $previous->getContentId() : -1)->set("NEXT", $next != null ? $next->getContentId() : -1);
     }
 }