original_string: public function beforeSave(Event $event, $entity, $options = [])
      {
          if ($this->_table->hasField($this->config('createdByField')) ||
              $this->_table->hasField($this->config('modifiedByField'))
          ) {
              $userId = $this->_getUserId();
              if ($userId > 0) {
                  $entity->set($this->config('modifiedByField'), $userId);
                  if ($entity->isNew()) {
                      $entity->set($this->config('createdByField'), $userId);
                  }
              }
          }
  
          return true;
      }
code: public function beforeSave(Event $event, $entity, $options = [])
      {
          if ($this->_table->hasField($this->config('createdByField')) ||
              $this->_table->hasField($this->config('modifiedByField'))
          ) {
              $userId = $this->_getUserId();
              if ($userId > 0) {
                  $entity->set($this->config('modifiedByField'), $userId);
                  if ($entity->isNew()) {
                      $entity->set($this->config('createdByField'), $userId);
                  }
              }
          }
  
          return true;
      }
code_tokens: public function beforeSave ( Event $ event , $ entity , $ options = [ ] ) { if ( $ this -> _table -> hasField ( $ this -> config ( 'createdByField' ) ) || $ this -> _table -> hasField ( $ this -> config ( 'modifiedByField' ) ) ) { $ userId = $ this -> _getUserId ( ) ; if ( $ userId > 0 ) { $ entity -> set ( $ this -> config ( 'modifiedByField' ) , $ userId ) ; if ( $ entity -> isNew ( ) ) { $ entity -> set ( $ this -> config ( 'createdByField' ) , $ userId ) ; } } } return true ; }
docstring: Run before a model is saved.
  
  @param \Cake\Event\Event $event The event that was triggered
  @param \Cake\ORM\Entity $entity The entity being saved
  @param array $options Array of options for the save operation
  @return bool True if save should proceed, false otherwise
docstring_tokens: Run before a model is saved .