original_string: protected function _mergeBelongsToMany($original, $assoc, $value, $options)
      {
          $associated = isset($options['associated']) ? $options['associated'] : [];
  
          $hasIds = array_key_exists('_ids', $value);
          $onlyIds = array_key_exists('onlyIds', $options) && $options['onlyIds'];
  
          if ($hasIds && is_array($value['_ids'])) {
              return $this->_loadAssociatedByIds($assoc, $value['_ids']);
          }
          if ($hasIds || $onlyIds) {
              return [];
          }
  
          if (!empty($associated) && !in_array('_joinData', $associated) && !isset($associated['_joinData'])) {
              return $this->mergeMany($original, $value, $options);
          }
  
          return $this->_mergeJoinData($original, $assoc, $value, $options);
      }
code: protected function _mergeBelongsToMany($original, $assoc, $value, $options)
      {
          $associated = isset($options['associated']) ? $options['associated'] : [];
  
          $hasIds = array_key_exists('_ids', $value);
          $onlyIds = array_key_exists('onlyIds', $options) && $options['onlyIds'];
  
          if ($hasIds && is_array($value['_ids'])) {
              return $this->_loadAssociatedByIds($assoc, $value['_ids']);
          }
          if ($hasIds || $onlyIds) {
              return [];
          }
  
          if (!empty($associated) && !in_array('_joinData', $associated) && !isset($associated['_joinData'])) {
              return $this->mergeMany($original, $value, $options);
          }
  
          return $this->_mergeJoinData($original, $assoc, $value, $options);
      }
code_tokens: protected function _mergeBelongsToMany ( $ original , $ assoc , $ value , $ options ) { $ associated = isset ( $ options [ 'associated' ] ) ? $ options [ 'associated' ] : [ ] ; $ hasIds = array_key_exists ( '_ids' , $ value ) ; $ onlyIds = array_key_exists ( 'onlyIds' , $ options ) && $ options [ 'onlyIds' ] ; if ( $ hasIds && is_array ( $ value [ '_ids' ] ) ) { return $ this -> _loadAssociatedByIds ( $ assoc , $ value [ '_ids' ] ) ; } if ( $ hasIds || $ onlyIds ) { return [ ] ; } if ( ! empty ( $ associated ) && ! in_array ( '_joinData' , $ associated ) && ! isset ( $ associated [ '_joinData' ] ) ) { return $ this -> mergeMany ( $ original , $ value , $ options ) ; } return $ this -> _mergeJoinData ( $ original , $ assoc , $ value , $ options ) ; }
docstring: Creates a new sub-marshaller and merges the associated data for a BelongstoMany
  association.
  
  @param \Cake\Datasource\EntityInterface $original The original entity
  @param \Cake\ORM\Association $assoc The association to marshall
  @param array $value The data to hydrate
  @param array $options List of options.
  @return \Cake\Datasource\EntityInterface[]
docstring_tokens: Creates a new sub - marshaller and merges the associated data for a BelongstoMany association .