original_string: public function attachEntityFields(EntityInterface $entity)
      {
          $_fields = [];
          foreach ($this->_attributesForEntity($entity) as $attr) {
              $field = $this->_prepareMockField($entity, $attr);
              if ($entity->has($field->get('name'))) {
                  $this->_fetchPost($field);
              }
  
              $field->fieldAttached();
              $_fields[] = $field;
          }
  
          $entity->set('_fields', new FieldCollection($_fields));
  
          return $entity;
      }
code: public function attachEntityFields(EntityInterface $entity)
      {
          $_fields = [];
          foreach ($this->_attributesForEntity($entity) as $attr) {
              $field = $this->_prepareMockField($entity, $attr);
              if ($entity->has($field->get('name'))) {
                  $this->_fetchPost($field);
              }
  
              $field->fieldAttached();
              $_fields[] = $field;
          }
  
          $entity->set('_fields', new FieldCollection($_fields));
  
          return $entity;
      }
code_tokens: public function attachEntityFields ( EntityInterface $ entity ) { $ _fields = [ ] ; foreach ( $ this -> _attributesForEntity ( $ entity ) as $ attr ) { $ field = $ this -> _prepareMockField ( $ entity , $ attr ) ; if ( $ entity -> has ( $ field -> get ( 'name' ) ) ) { $ this -> _fetchPost ( $ field ) ; } $ field -> fieldAttached ( ) ; $ _fields [ ] = $ field ; } $ entity -> set ( '_fields' , new FieldCollection ( $ _fields ) ) ; return $ entity ; }
docstring: The method which actually fetches custom fields.
  
  Fetches all Entity's fields under the `_fields` property.
  
  @param \Cake\Datasource\EntityInterface $entity The entity where to fetch fields
  @return \Cake\Datasource\EntityInterface
docstring_tokens: The method which actually fetches custom fields .