getContenttype() public method

public getContenttype ( )
Example #1
0
 /**
  * Dispatch the update event.
  *
  * @param Content $content
  * @param string  $type
  * @param string  $legacyType
  */
 private function dispatch(Content $content, $type, $legacyType)
 {
     $event = new StorageEvent($content, ['contenttype' => $content->getContenttype(), 'create' => false]);
     try {
         $this->dispatcher->dispatch("timed.{$type}", $event);
     } catch (\Exception $e) {
         $this->systemLogger->critical(sprintf('Dispatch handling failed for %s.', $content->getContenttype()), ['event' => 'exception', 'exception' => $e]);
     }
     try {
         /** @deprecated Deprecated since 3.1, to be removed in 4.0. */
         $this->dispatcher->dispatch("timed.{$legacyType}", $event);
     } catch (\Exception $e) {
         $this->systemLogger->critical(sprintf('Dispatch handling failed for %s.', $content->getContenttype()), ['event' => 'exception', 'exception' => $e]);
     }
 }
Example #2
0
 /**
  * Transition a record's owner if permitted.
  *
  * @param Content $entity
  * @param integer $ownerId
  */
 protected function transistionRecordOwner(Content $entity, $ownerId)
 {
     $recordId = $entity->getId();
     $contentTypeName = (string) $entity->getContenttype();
     $canChangeOwner = $this->users->isAllowed("contenttype:{$contentTypeName}:change-ownership:{$recordId}");
     if (!$canChangeOwner) {
         $this->loggerFlash->error(Trans::__('general.access-denied.content-not-modified', ['%title%' => $entity->getTitle()]));
         return;
     }
     $entity->setOwnerid($ownerId);
     $entity->_modified = true;
 }
Example #3
0
 /**
  * Build a valid AJAX response for in-place saves that account for pre/post
  * save events.
  *
  * @param Content $content
  * @param boolean $flush
  *
  * @return JsonResponse
  */
 private function createJsonUpdate(Content $content, $flush)
 {
     /*
      * Flush any buffers from saveConent() dispatcher hooks
      * and make sure our JSON output is clean.
      *
      * Currently occurs due to exceptions being generated in the dispatchers
      * in \Bolt\Storage::saveContent()
      *     StorageEvents::PRE_SAVE
      *     StorageEvents::POST_SAVE
      */
     if ($flush) {
         Response::closeOutputBuffers(0, false);
     }
     $val = $content->toArray();
     if (isset($val['datechanged'])) {
         $val['datechanged'] = (new Carbon($val['datechanged']))->toIso8601String();
     }
     // Adjust decimal point as some locales use a comma and… JavaScript
     $lc = localeconv();
     $fields = $this->app['config']->get('contenttypes/' . $content->getContenttype() . '/fields');
     foreach ($fields as $key => $values) {
         if ($values['type'] === 'float' && $lc['decimal_point'] === ',') {
             $val[$key] = str_replace('.', ',', $val[$key]);
         }
     }
     // Unset flashbag for ajax
     $this->app['logger.flash']->clear();
     return new JsonResponse($val);
 }
Example #4
0
 /**
  * Identifies which relations are incoming to the given entity
  *
  * @param Entity\Content $entity
  *
  * @return mixed
  */
 public function incoming(Entity\Content $entity)
 {
     return $this->filter(function ($el) use($entity) {
         /** @var Entity\Relations $el */
         return $el->getToContenttype() == (string) $entity->getContenttype() && $el->getToId() === $entity->getId();
     });
 }