original_string: protected function _scaffoldFields(array $associations = [])
      {
          $action = $this->_action();
          $scaffoldFields = (array)$action->getConfig('scaffold.fields');
          if (!empty($scaffoldFields)) {
              $scaffoldFields = Hash::normalize($scaffoldFields);
          }
  
          if (empty($scaffoldFields) || $action->getConfig('scaffold.autoFields')) {
              $cols = $this->_table()->getSchema()->columns();
              $cols = Hash::normalize($cols);
  
              $scope = $action->getConfig('scope');
              if ($scope === 'entity' && !empty($associations['manyToMany'])) {
                  foreach ($associations['manyToMany'] as $alias => $options) {
                      $cols[sprintf('%s._ids', $options['entities'])] = [
                          'multiple' => true
                      ];
                  }
              }
  
              $scaffoldFields = array_merge($cols, $scaffoldFields);
          }
  
          // Check for blacklisted fields
          $blacklist = $action->getConfig('scaffold.fields_blacklist');
          if (!empty($blacklist)) {
              $scaffoldFields = array_diff_key($scaffoldFields, array_combine($blacklist, $blacklist));
          }
  
          // Make sure all array values are an array
          foreach ($scaffoldFields as $field => $options) {
              if (!is_array($options)) {
                  $scaffoldFields[$field] = (array)$options;
              }
  
              $scaffoldFields[$field] += ['formatter' => null];
          }
  
          $fieldSettings = $action->getConfig('scaffold.field_settings');
          if (empty($fieldSettings)) {
              $fieldSettings = [];
          }
          $fieldSettings = array_intersect_key($fieldSettings, $scaffoldFields);
          $scaffoldFields = Hash::merge($scaffoldFields, $fieldSettings);
  
          return $scaffoldFields;
      }
code: protected function _scaffoldFields(array $associations = [])
      {
          $action = $this->_action();
          $scaffoldFields = (array)$action->getConfig('scaffold.fields');
          if (!empty($scaffoldFields)) {
              $scaffoldFields = Hash::normalize($scaffoldFields);
          }
  
          if (empty($scaffoldFields) || $action->getConfig('scaffold.autoFields')) {
              $cols = $this->_table()->getSchema()->columns();
              $cols = Hash::normalize($cols);
  
              $scope = $action->getConfig('scope');
              if ($scope === 'entity' && !empty($associations['manyToMany'])) {
                  foreach ($associations['manyToMany'] as $alias => $options) {
                      $cols[sprintf('%s._ids', $options['entities'])] = [
                          'multiple' => true
                      ];
                  }
              }
  
              $scaffoldFields = array_merge($cols, $scaffoldFields);
          }
  
          // Check for blacklisted fields
          $blacklist = $action->getConfig('scaffold.fields_blacklist');
          if (!empty($blacklist)) {
              $scaffoldFields = array_diff_key($scaffoldFields, array_combine($blacklist, $blacklist));
          }
  
          // Make sure all array values are an array
          foreach ($scaffoldFields as $field => $options) {
              if (!is_array($options)) {
                  $scaffoldFields[$field] = (array)$options;
              }
  
              $scaffoldFields[$field] += ['formatter' => null];
          }
  
          $fieldSettings = $action->getConfig('scaffold.field_settings');
          if (empty($fieldSettings)) {
              $fieldSettings = [];
          }
          $fieldSettings = array_intersect_key($fieldSettings, $scaffoldFields);
          $scaffoldFields = Hash::merge($scaffoldFields, $fieldSettings);
  
          return $scaffoldFields;
      }
code_tokens: protected function _scaffoldFields ( array $ associations = [ ] ) { $ action = $ this -> _action ( ) ; $ scaffoldFields = ( array ) $ action -> getConfig ( 'scaffold.fields' ) ; if ( ! empty ( $ scaffoldFields ) ) { $ scaffoldFields = Hash :: normalize ( $ scaffoldFields ) ; } if ( empty ( $ scaffoldFields ) || $ action -> getConfig ( 'scaffold.autoFields' ) ) { $ cols = $ this -> _table ( ) -> getSchema ( ) -> columns ( ) ; $ cols = Hash :: normalize ( $ cols ) ; $ scope = $ action -> getConfig ( 'scope' ) ; if ( $ scope === 'entity' && ! empty ( $ associations [ 'manyToMany' ] ) ) { foreach ( $ associations [ 'manyToMany' ] as $ alias => $ options ) { $ cols [ sprintf ( '%s._ids' , $ options [ 'entities' ] ) ] = [ 'multiple' => true ] ; } } $ scaffoldFields = array_merge ( $ cols , $ scaffoldFields ) ; } // Check for blacklisted fields $ blacklist = $ action -> getConfig ( 'scaffold.fields_blacklist' ) ; if ( ! empty ( $ blacklist ) ) { $ scaffoldFields = array_diff_key ( $ scaffoldFields , array_combine ( $ blacklist , $ blacklist ) ) ; } // Make sure all array values are an array foreach ( $ scaffoldFields as $ field => $ options ) { if ( ! is_array ( $ options ) ) { $ scaffoldFields [ $ field ] = ( array ) $ options ; } $ scaffoldFields [ $ field ] += [ 'formatter' => null ] ; } $ fieldSettings = $ action -> getConfig ( 'scaffold.field_settings' ) ; if ( empty ( $ fieldSettings ) ) { $ fieldSettings = [ ] ; } $ fieldSettings = array_intersect_key ( $ fieldSettings , $ scaffoldFields ) ; $ scaffoldFields = Hash :: merge ( $ scaffoldFields , $ fieldSettings ) ; return $ scaffoldFields ; }
docstring: Returns fields to be displayed on scaffolded template
  
  @param array $associations Associations list.
  @return array
docstring_tokens: Returns fields to be displayed on scaffolded template