getDatepublish() public method

public getDatepublish ( ) : DateTime
return DateTime
Exemplo n.º 1
0
 /**
  * Do the edit form for a record.
  *
  * @param Content $content     A content record
  * @param array   $contenttype The contenttype data
  * @param boolean $duplicate   If TRUE create a duplicate record
  *
  * @return array
  */
 public function handleEditRequest(Content $content, array $contenttype, $duplicate)
 {
     $contenttypeSlug = $contenttype['slug'];
     $new = $content->getId() === null ?: false;
     $oldStatus = $content->getStatus();
     $allStatuses = ['published', 'held', 'draft', 'timed'];
     $allowedStatuses = [];
     foreach ($allStatuses as $status) {
         if ($this->app['users']->isContentStatusTransitionAllowed($oldStatus, $status, $contenttypeSlug, $content->getId())) {
             $allowedStatuses[] = $status;
         }
     }
     // For duplicating a record, clear base field values.
     if ($duplicate) {
         $content->setId('');
         $content->setSlug('');
         $content->setDatecreated('');
         $content->setDatepublish('');
         $content->setDatedepublish(null);
         $content->setDatechanged('');
         $content->setUsername('');
         $content->setOwnerid('');
         $this->app['logger.flash']->info(Trans::__('contenttypes.generic.duplicated-finalize', ['%contenttype%' => $contenttypeSlug]));
     }
     // Set the users and the current owner of this content.
     if ($new || $duplicate) {
         // For brand-new and duplicated items, the creator becomes the owner.
         $contentowner = $this->app['users']->getCurrentUser();
     } else {
         // For existing items, we'll just keep the current owner.
         $contentowner = $this->app['users']->getUser($content->getOwnerid());
     }
     // Test write access for uploadable fields.
     $contenttype['fields'] = $this->setCanUpload($contenttype['fields']);
     if ($templatefields = $content->getTemplatefields()) {
         $this->setCanUpload($templatefields->getContenttype());
     }
     // Build context for Twig.
     $contextCan = ['upload' => $this->app['users']->isAllowed('files:uploads'), 'publish' => $this->app['users']->isAllowed('contenttype:' . $contenttypeSlug . ':publish:' . $content->getId()), 'depublish' => $this->app['users']->isAllowed('contenttype:' . $contenttypeSlug . ':depublish:' . $content->getId()), 'change_ownership' => $this->app['users']->isAllowed('contenttype:' . $contenttypeSlug . ':change-ownership:' . $content->getId())];
     $contextHas = ['incoming_relations' => is_array($content->relation), 'relations' => isset($contenttype['relations']), 'tabs' => $contenttype['groups'] !== false, 'taxonomy' => isset($contenttype['taxonomy']), 'templatefields' => $templatefields ? true : false];
     $contextValues = ['datepublish' => $this->getPublishingDate($content->getDatepublish(), true), 'datedepublish' => $this->getPublishingDate($content->getDatedepublish())];
     $context = ['contenttype' => $contenttype, 'content' => $content, 'allowed_status' => $allowedStatuses, 'contentowner' => $contentowner, 'fields' => $this->app['config']->fields->fields(), 'fieldtemplates' => $this->getTempateFieldTemplates($contenttype, $content), 'fieldtypes' => $this->getUsedFieldtypes($contenttype, $content, $contextHas), 'groups' => $this->createGroupTabs($contenttype, $contextHas), 'can' => $contextCan, 'has' => $contextHas, 'values' => $contextValues, 'relations_list' => $this->getRelationsList($contenttype)];
     return $context;
 }