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;
    }
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;
    }
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 ; }
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
The method which actually fetches custom fields .