Ejemplo n.º 1
0
 public function delete(FolderDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     if (null !== ($folder = FolderQuery::create()->findPk($event->getFolderId()))) {
         $con = Propel::getWriteConnection(FolderTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             $fileList = ['images' => [], 'documentList' => []];
             // Get folder's files to delete after folder deletion
             $fileList['images']['list'] = FolderImageQuery::create()->findByFolderId($event->getFolderId());
             $fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
             $fileList['documentList']['list'] = FolderDocumentQuery::create()->findByFolderId($event->getFolderId());
             $fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
             // Delete folder
             $folder->setDispatcher($dispatcher)->delete($con);
             $event->setFolder($folder);
             // Dispatch delete folder's files event
             foreach ($fileList as $fileTypeList) {
                 foreach ($fileTypeList['list'] as $fileToDelete) {
                     $fileDeleteEvent = new FileDeleteEvent($fileToDelete);
                     $dispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
                 }
             }
             $con->commit();
         } catch (\Exception $e) {
             $con->rollback();
             throw $e;
         }
     }
 }
Ejemplo n.º 2
0
 public function preImport()
 {
     // Delete table before proceeding
     ContentQuery::create()->deleteAll();
     FolderQuery::create()->deleteAll();
     FolderImageQuery::create()->deleteAll();
     FolderDocumentQuery::create()->deleteAll();
     // Create T1 <-> T2 IDs correspondance tables
     $this->fld_corresp->reset();
 }
Ejemplo n.º 3
0
 public function testCopyUploadedFileFolderDocument()
 {
     $this->dotTestDocumentUpload(FolderDocumentQuery::create()->findOne(), 'folder');
 }
Ejemplo n.º 4
0
 public function testQueryDocument()
 {
     $data = $this->handler->setDocumentExport(true)->buildData($this->lang)->getData();
     $max = count($data);
     if ($max > 50) {
         $max = 50;
     }
     for ($i = 0; $i < $max; ++$i) {
         $documents = ContentDocumentQuery::create()->filterByContentId($data[$i]["id"])->select(ContentDocumentTableMap::FILE)->find()->toArray();
         $documentsString = implode(",", $documents);
         if (empty($data[$i]["content_documents"])) {
             $j = 1;
             while ($data[$i - $j]["id"] === $data[$i]["id"]) {
                 if (!empty($data[$i - $j++]["content_documents"])) {
                     $data[$i]["content_documents"] = $data[$i - $j + 1]["content_documents"];
                     break;
                 }
             }
         }
         $this->assertEquals($documentsString, $data[$i]["content_documents"]);
         $folderDocuments = FolderDocumentQuery::create()->useFolderQuery()->useContentFolderQuery()->filterByContentId($data[$i]["id"])->filterByFolderId($data[$i]["folder_id"])->endUse()->endUse()->select(FolderDocumentTableMap::FILE)->find()->toArray();
         $folderDocuments = implode(",", $folderDocuments);
         $this->assertEquals($folderDocuments, $data[$i]["folder_documents"]);
     }
 }
Ejemplo n.º 5
0
 /**
  * @return array
  *
  * return an array with the paths to the documents to include in the archive
  */
 public function getDocumentsPaths()
 {
     $documentPaths = [];
     $folderDocuments = FolderDocumentQuery::create()->find();
     /** @var \Thelia\Model\FolderDocument $folderDocument */
     foreach ($folderDocuments as $folderDocument) {
         $this->addFileToArray($folderDocument, $documentPaths);
     }
     $contentDocuments = ContentDocumentQuery::create()->find();
     /** @var \Thelia\Model\ContentDocument $contentDocument */
     foreach ($contentDocuments as $contentDocument) {
         $this->addFileToArray($contentDocument, $documentPaths);
     }
     return $documentPaths;
 }
Ejemplo n.º 6
0
 Model\FolderI18nQuery::create()->deleteAll();
 Model\ContentQuery::create()->deleteAll();
 Model\ContentI18nQuery::create()->deleteAll();
 Model\AccessoryQuery::create()->deleteAll();
 Model\ProductSaleElementsQuery::create()->deleteAll();
 Model\ProductPriceQuery::create()->deleteAll();
 Model\BrandQuery::create()->deleteAll();
 Model\BrandI18nQuery::create()->deleteAll();
 Model\ProductImageQuery::create()->deleteAll();
 Model\CategoryImageQuery::create()->deleteAll();
 Model\FolderImageQuery::create()->deleteAll();
 Model\ContentImageQuery::create()->deleteAll();
 Model\BrandImageQuery::create()->deleteAll();
 Model\ProductDocumentQuery::create()->deleteAll();
 Model\CategoryDocumentQuery::create()->deleteAll();
 Model\FolderDocumentQuery::create()->deleteAll();
 Model\ContentDocumentQuery::create()->deleteAll();
 Model\BrandDocumentQuery::create()->deleteAll();
 Model\CouponQuery::create()->deleteAll();
 Model\OrderQuery::create()->deleteAll();
 Model\SaleQuery::create()->deleteAll();
 Model\SaleProductQuery::create()->deleteAll();
 Model\MetaDataQuery::create()->deleteAll();
 $stmt = $con->prepare("SET foreign_key_checks = 1");
 $stmt->execute();
 echo "Creating customers\n";
 //API
 $api = new Thelia\Model\Api();
 $api->setProfileId(null)->setApiKey('79E95BD784CADA0C9A578282E')->setLabel("test")->save();
 //customer
 $customer = new Thelia\Model\Customer();
Ejemplo n.º 7
0
 public function testSearchByFolderId()
 {
     $document = FolderDocumentQuery::create()->findOne();
     $this->baseTestSearchById($document->getId(), array('source' => 'folder'));
 }
Ejemplo n.º 8
0
 $stock = \Thelia\Model\ProductSaleElementsQuery::create()->find();
 $stock->delete();
 $productPrice = \Thelia\Model\ProductPriceQuery::create()->find();
 $productPrice->delete();
 $brand = Thelia\Model\BrandQuery::create()->find();
 $brand->delete();
 $brand = Thelia\Model\BrandI18nQuery::create()->find();
 $brand->delete();
 \Thelia\Model\ProductImageQuery::create()->find()->delete();
 \Thelia\Model\CategoryImageQuery::create()->find()->delete();
 \Thelia\Model\FolderImageQuery::create()->find()->delete();
 \Thelia\Model\ContentImageQuery::create()->find()->delete();
 \Thelia\Model\BrandImageQuery::create()->find()->delete();
 \Thelia\Model\ProductDocumentQuery::create()->find()->delete();
 \Thelia\Model\CategoryDocumentQuery::create()->find()->delete();
 \Thelia\Model\FolderDocumentQuery::create()->find()->delete();
 \Thelia\Model\ContentDocumentQuery::create()->find()->delete();
 \Thelia\Model\BrandDocumentQuery::create()->find()->delete();
 \Thelia\Model\CouponQuery::create()->find()->delete();
 \Thelia\Model\OrderQuery::create()->find()->delete();
 \Thelia\Model\SaleQuery::create()->find()->delete();
 \Thelia\Model\SaleProductQuery::create()->find()->delete();
 \Thelia\Model\MetaDataQuery::create()->find()->delete();
 $stmt = $con->prepare("SET foreign_key_checks = 1");
 $stmt->execute();
 echo "Creating customers\n";
 //API
 $api = new Thelia\Model\Api();
 $api->setProfileId(null)->setApiKey('79E95BD784CADA0C9A578282E')->setLabel("test")->save();
 //customer
 $customer = new Thelia\Model\Customer();
Ejemplo n.º 9
0
 /**
  * Performs an INSERT on the database, given a FolderDocument or Criteria object.
  *
  * @param mixed               $criteria Criteria or FolderDocument 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(FolderDocumentTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from FolderDocument object
     }
     if ($criteria->containsKey(FolderDocumentTableMap::ID) && $criteria->keyContainsValue(FolderDocumentTableMap::ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderDocumentTableMap::ID . ')');
     }
     // Set the correct dbName
     $query = FolderDocumentQuery::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;
 }
Ejemplo n.º 10
0
 /**
  * Get the associated ChildFolderDocument object
  *
  * @param      ConnectionInterface $con Optional Connection object.
  * @return                 ChildFolderDocument The associated ChildFolderDocument object.
  * @throws PropelException
  */
 public function getFolderDocument(ConnectionInterface $con = null)
 {
     if ($this->aFolderDocument === null && $this->id !== null) {
         $this->aFolderDocument = ChildFolderDocumentQuery::create()->findPk($this->id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aFolderDocument->addFolderDocumentI18ns($this);
            */
     }
     return $this->aFolderDocument;
 }
Ejemplo n.º 11
0
 /**
  * Returns the number of related FolderDocument objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      ConnectionInterface $con
  * @return int             Count of related FolderDocument objects.
  * @throws PropelException
  */
 public function countFolderDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     $partial = $this->collFolderDocumentsPartial && !$this->isNew();
     if (null === $this->collFolderDocuments || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collFolderDocuments) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getFolderDocuments());
         }
         $query = ChildFolderDocumentQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByFolder($this)->count($con);
     }
     return count($this->collFolderDocuments);
 }
Ejemplo n.º 12
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see FolderDocument::setDeleted()
  * @see FolderDocument::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(FolderDocumentTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildFolderDocumentQuery::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;
     }
 }