original_string: protected function _prepareMockField(EntityInterface $entity, EntityInterface $attribute)
      {
          $type = $this->_toolbox->mapType($attribute->get('type'));
          if (!$attribute->has(':value')) {
              $bundle = $this->_resolveBundle($entity);
              $conditions = [
                  'EavAttribute.table_alias' => $this->_table->table(),
                  'EavAttribute.name' => $attribute->get('name'),
                  'EavValues.entity_id' => $entity->get((string)$this->_table->primaryKey()),
              ];
  
              if ($bundle) {
                  $conditions['EavAttribute.bundle'] = $bundle;
              }
  
              $storedValue = TableRegistry::get('Eav.EavValues')
                  ->find()
                  ->contain(['EavAttribute'])
                  ->select(['id', "value_{$type}", 'extra'])
                  ->where($conditions)
                  ->limit(1)
                  ->first();
          } else {
              $storedValue = $attribute->get(':value');
          }
  
          $mockField = new Field([
              'name' => $attribute->get('name'),
              'label' => $attribute->get('instance')->get('label'),
              'value' => null,
              'extra' => null,
              'metadata' => new Entity([
                  'value_id' => null,
                  'instance_id' => $attribute->get('instance')->get('id'),
                  'attribute_id' => $attribute->get('id'),
                  'entity_id' => $this->_toolbox->getEntityId($entity),
                  'table_alias' => $attribute->get('table_alias'),
                  'type' => $type,
                  'bundle' => $attribute->get('bundle'),
                  'handler' => $attribute->get('instance')->get('handler'),
                  'required' => $attribute->get('instance')->required,
                  'description' => $attribute->get('instance')->description,
                  'settings' => $attribute->get('instance')->settings,
                  'view_modes' => $attribute->get('instance')->view_modes,
                  'entity' => $entity,
                  'errors' => [],
              ]),
          ]);
  
          if ($storedValue) {
              $mockField->set('value', $this->_toolbox->marshal($storedValue->get("value_{$type}"), $type));
              $mockField->set('extra', $storedValue->get('extra'));
              $mockField->metadata->set('value_id', $storedValue->id);
          }
  
          $mockField->isNew($entity->isNew());
  
          return $mockField;
      }
code: protected function _prepareMockField(EntityInterface $entity, EntityInterface $attribute)
      {
          $type = $this->_toolbox->mapType($attribute->get('type'));
          if (!$attribute->has(':value')) {
              $bundle = $this->_resolveBundle($entity);
              $conditions = [
                  'EavAttribute.table_alias' => $this->_table->table(),
                  'EavAttribute.name' => $attribute->get('name'),
                  'EavValues.entity_id' => $entity->get((string)$this->_table->primaryKey()),
              ];
  
              if ($bundle) {
                  $conditions['EavAttribute.bundle'] = $bundle;
              }
  
              $storedValue = TableRegistry::get('Eav.EavValues')
                  ->find()
                  ->contain(['EavAttribute'])
                  ->select(['id', "value_{$type}", 'extra'])
                  ->where($conditions)
                  ->limit(1)
                  ->first();
          } else {
              $storedValue = $attribute->get(':value');
          }
  
          $mockField = new Field([
              'name' => $attribute->get('name'),
              'label' => $attribute->get('instance')->get('label'),
              'value' => null,
              'extra' => null,
              'metadata' => new Entity([
                  'value_id' => null,
                  'instance_id' => $attribute->get('instance')->get('id'),
                  'attribute_id' => $attribute->get('id'),
                  'entity_id' => $this->_toolbox->getEntityId($entity),
                  'table_alias' => $attribute->get('table_alias'),
                  'type' => $type,
                  'bundle' => $attribute->get('bundle'),
                  'handler' => $attribute->get('instance')->get('handler'),
                  'required' => $attribute->get('instance')->required,
                  'description' => $attribute->get('instance')->description,
                  'settings' => $attribute->get('instance')->settings,
                  'view_modes' => $attribute->get('instance')->view_modes,
                  'entity' => $entity,
                  'errors' => [],
              ]),
          ]);
  
          if ($storedValue) {
              $mockField->set('value', $this->_toolbox->marshal($storedValue->get("value_{$type}"), $type));
              $mockField->set('extra', $storedValue->get('extra'));
              $mockField->metadata->set('value_id', $storedValue->id);
          }
  
          $mockField->isNew($entity->isNew());
  
          return $mockField;
      }
code_tokens: protected function _prepareMockField ( EntityInterface $ entity , EntityInterface $ attribute ) { $ type = $ this -> _toolbox -> mapType ( $ attribute -> get ( 'type' ) ) ; if ( ! $ attribute -> has ( ':value' ) ) { $ bundle = $ this -> _resolveBundle ( $ entity ) ; $ conditions = [ 'EavAttribute.table_alias' => $ this -> _table -> table ( ) , 'EavAttribute.name' => $ attribute -> get ( 'name' ) , 'EavValues.entity_id' => $ entity -> get ( ( string ) $ this -> _table -> primaryKey ( ) ) , ] ; if ( $ bundle ) { $ conditions [ 'EavAttribute.bundle' ] = $ bundle ; } $ storedValue = TableRegistry :: get ( 'Eav.EavValues' ) -> find ( ) -> contain ( [ 'EavAttribute' ] ) -> select ( [ 'id' , "value_{$type}" , 'extra' ] ) -> where ( $ conditions ) -> limit ( 1 ) -> first ( ) ; } else { $ storedValue = $ attribute -> get ( ':value' ) ; } $ mockField = new Field ( [ 'name' => $ attribute -> get ( 'name' ) , 'label' => $ attribute -> get ( 'instance' ) -> get ( 'label' ) , 'value' => null , 'extra' => null , 'metadata' => new Entity ( [ 'value_id' => null , 'instance_id' => $ attribute -> get ( 'instance' ) -> get ( 'id' ) , 'attribute_id' => $ attribute -> get ( 'id' ) , 'entity_id' => $ this -> _toolbox -> getEntityId ( $ entity ) , 'table_alias' => $ attribute -> get ( 'table_alias' ) , 'type' => $ type , 'bundle' => $ attribute -> get ( 'bundle' ) , 'handler' => $ attribute -> get ( 'instance' ) -> get ( 'handler' ) , 'required' => $ attribute -> get ( 'instance' ) -> required , 'description' => $ attribute -> get ( 'instance' ) -> description , 'settings' => $ attribute -> get ( 'instance' ) -> settings , 'view_modes' => $ attribute -> get ( 'instance' ) -> view_modes , 'entity' => $ entity , 'errors' => [ ] , ] ) , ] ) ; if ( $ storedValue ) { $ mockField -> set ( 'value' , $ this -> _toolbox -> marshal ( $ storedValue -> get ( "value_{$type}" ) , $ type ) ) ; $ mockField -> set ( 'extra' , $ storedValue -> get ( 'extra' ) ) ; $ mockField -> metadata -> set ( 'value_id' , $ storedValue -> id ) ; } $ mockField -> isNew ( $ entity -> isNew ( ) ) ; return $ mockField ; }
docstring: Creates a new Virtual "Field" to be attached to the given entity.
  
  This mock Field represents a new property (table column) of the entity.
  
  @param \Cake\Datasource\EntityInterface $entity The entity where the
  generated virtual field will be attached
  @param \Cake\Datasource\EntityInterface $attribute The attribute where to get
  the information when creating the mock field.
  @return \Field\Model\Entity\Field
docstring_tokens: Creates a new Virtual Field to be attached to the given entity .