File modules/cms/action/file/FilePubAction.class.php
Last commit: Fri Mar 11 12:26:33 2022 +0100 dankert Fix: Catch error if something happens while publishing.
1 <?php 2 namespace cms\action\file; 3 use cms\action\FileAction; 4 use cms\action\Method; 5 use cms\generator\FileContext; 6 use cms\generator\FileGenerator; 7 use cms\generator\Producer; 8 use cms\generator\Publisher; 9 use cms\generator\PublishOrder; 10 use cms\model\Permission; 11 use language\Messages; 12 use util\exception\PublisherException; 13 14 class FilePubAction extends FileAction implements Method { 15 public function getRequiredPermission() { 16 return Permission::ACL_PUBLISH; 17 } 18 19 public function view() { 20 } 21 public function post() { 22 $fileGenerator = new FileGenerator( new FileContext( $this->file->objectid, Producer::SCHEME_PUBLIC)); 23 24 $publisher = new Publisher( $this->file->projectid ); 25 $publisher->addOrderForPublishing( new PublishOrder( $fileGenerator->getCache()->load()->getFilename(),$fileGenerator->getPublicFilename(),$this->file->lastchangeDate) ); 26 27 try { 28 $publisher->publish(); 29 $this->file->setPublishedTimestamp(); 30 $this->addNoticeFor($this->file,'PUBLISHED',[],'Published items:'."\n".implode("\n",$publisher->getDestinationFilenames()) ); 31 } catch( PublisherException $e ) { 32 $this->addErrorFor( $this->file,Messages::PUBLISHED_ERROR,[],$e->getMessage() ); 33 } 34 35 } 36 }
Downloadmodules/cms/action/file/FilePubAction.class.php
History Fri, 11 Mar 2022 12:26:33 +0100 dankert Fix: Catch error if something happens while publishing. Sat, 6 Mar 2021 03:42:38 +0100 Jan Dankert New: Better permission checks. Sat, 27 Feb 2021 00:29:39 +0100 Jan Dankert New: Set publishing date on publishing. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.