コード例 #1
0
 /**
  * @Route("/doc/new", name="doc_new")
  * @todo  $indir validieren
  */
 public function newAction(Request $request)
 {
     $indir = $request->query->get('indir');
     $storage = $this->get('app.storage_helper');
     $document = new Document();
     if (null !== $indir) {
         $document->setPath($indir);
     }
     $repo = $this->getDoctrine()->getRepository('AppBundle:Document');
     global $allFilingPlaces;
     $allFilingPlaces = [];
     foreach ($repo->getAllFilingPlaces() as $value) {
         $allFilingPlaces[$value['filingPlace']] = $value['filingPlace'];
     }
     $form = $this->createForm(DocumentType::class, $document);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $document->setCreated(new \Datetime());
         $em = $this->getDoctrine()->getManager();
         try {
             $dir = $this->_handleDirectoryCreation($document->getPath());
             $document->setDirectory($dir);
             $em->persist($document);
             $em->flush();
             return $this->redirectToRoute('doc', ['id' => $document->getId()]);
         } catch (\Exception $e) {
             print $e->getMessage();
             die;
         }
     }
     return $this->render('document/new.html.twig', ['document' => $document, 'form' => $form->createView()]);
 }
コード例 #2
0
ファイル: LoadDocs.php プロジェクト: ubermichael/pkppln-php
 /**
  * {@inheritDoc}
  */
 protected function doLoad(ObjectManager $manager)
 {
     $doc = new Document();
     $doc->setContent("<p>Content is good and cheesy.</p>");
     $doc->setPath('test1');
     $doc->setSummary("summarized");
     $doc->setTitle("title1");
     $manager->persist($doc);
     $this->setReference('doc', $doc);
     $manager->flush();
 }
コード例 #3
0
 public function load(ObjectManager $manager)
 {
     foreach ($this->getAllDocuments() as $singleDocument) {
         $document = new Document();
         $document->setSiteId($this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('AppBundle:Site')->findOneBy(array('url' => $singleDocument['site_id_id'])));
         $document->setPath('#');
         $document->setUploadDate(new \DateTime());
         $document->setDocumentType($singleDocument['document_type']);
         $manager->persist($document);
     }
     $manager->flush();
 }
コード例 #4
0
 public function load(ObjectManager $manager)
 {
     /*
             $connection = $manager->getConnection();
             $dbPlatform = $connection->getDatabasePlatform();
     #        $connection->query('SET FOREIGN_KEY_CHECKS=0');
             $q = $dbPlatform->getTruncateTableSql('documents');
             $connection->executeUpdate($q);
             $q = $dbPlatform->getTruncateTableSql('files');
             $connection->executeUpdate($q);
      #       $connection->query('SET FOREIGN_KEY_CHECKS=1');
     */
     for ($i = 0; $i <= 10; $i++) {
         $document = new Document();
         $document->setTitle('Der Titel Nr. ' . $i);
         $document->setDocDate(new \Datetime());
         $document->setPath('/home/jacek/dir');
         $document->setCreated(new \Datetime());
         $document->setTags('tag1 tag2 tag3');
         $r = mt_rand(1, 2);
         for ($j = 0; $j <= $r; $j++) {
             $file = new File();
             $file->setTitle('Titel der Datei Nr. ' . $j);
             $file->setFilename('Dateiname.ext');
             $file->setPath('/home/jacek/dir');
             $file->setFiletype('ext');
             $file->setContent('blablabla');
             $file->setCreated(new \Datetime());
             $file->setDocument($document);
             $manager->persist($file);
             print "File angelegt: {$file->getTitle()} \n";
         }
         $manager->persist($document);
         print "Doc angelegt: {$document->getTitle()} \n";
     }
     $manager->flush();
 }