newNewsFeed() public method

Adds a new news-feed entry. If not message (means null) is passed we generate a diff.
public newNewsFeed ( Objects $repo, string $objectKey, array $item, string $verb, string | null $message = null )
$repo Objects
$objectKey string
$item array
$verb string
$message string | null
Example #1
0
 /**
  * @param string|File $path
  * @param string $verb
  * @param string $message
  */
 protected function newFeed($path, $verb, $message = '')
 {
     $file = $path;
     if (!$path instanceof File) {
         $file = $this->webFilesystem->getFile($path);
     }
     if ($file instanceof File) {
         $this->utils->newNewsFeed($this->objects, 'jarves/file', $file->toArray(), $verb, $message);
     }
 }
Example #2
0
 /**
  * Patches a object entry. This means, only defined fields will be saved. Fields which are not defined will
  * not be overwritten.
  *
  * @param  array $pk
  *
  * @param  Request|array $requestOrData
  * @return bool
  *
  * @throws AccessDeniedException
  * @throws ObjectNotFoundException
  * @throws \Exception
  */
 public function patch($pk, $requestOrData)
 {
     $storageController = $this->objects->getStorageController($this->getObject());
     $pk = $storageController->normalizePrimaryKey($pk);
     $this->primaryKey = $pk;
     $values = $this->collectData($requestOrData);
     $args = ['pk' => $pk, 'values' => &$values, 'controller' => $this, 'mode' => 'update'];
     $eventPre = new GenericEvent($this->getObject(), $args);
     $this->eventDispatcher->dispatch('core/object/modify-pre', $eventPre);
     $this->eventDispatcher->dispatch('core/object/patch-pre', $eventPre);
     $item = $this->getItem($pk);
     if ($this->getPermissionCheck()) {
         if (!$item) {
             return null;
         }
         if (!$this->acl->check(ACLRequest::create($this->getObject(), $pk)->onlyUpdateMode())) {
             return null;
         }
         foreach ($values as $fieldName => $value) {
             $aclRequest = ACLRequest::create($this->getObject(), $pk)->setField([$fieldName => $value])->onlyUpdateMode();
             if (!$this->acl->check($aclRequest)) {
                 throw new AccessDeniedException(sprintf('Not allowed to change `%s`', $fieldName));
             }
         }
     }
     if (($condition = $this->getCondition()) && $condition->hasRules()) {
         if (!$this->conditionOperator->satisfy($condition, $item, $this->getObject())) {
             return null;
         }
     }
     $incomingFields = $requestOrData instanceof Request ? array_keys($requestOrData->request->all()) : array_keys($requestOrData);
     if (!$incomingFields) {
         return false;
     }
     $changedData = $this->mapData($values, $incomingFields, $item);
     if ($this->getWithNewsFeed()) {
         $this->utils->newNewsFeed($this->objects, $this->getObject(), array_merge($values, $pk), 'updated');
     }
     $result = $storageController->patch($pk, $changedData);
     $args['result'] = $result;
     $event = new GenericEvent($this->getObject(), $args);
     $this->eventDispatcher->dispatch('core/object/modify', $event);
     $this->eventDispatcher->dispatch('core/object/patch', $event);
     return $result;
 }