original_string: public function one(array $data, array $options = [])
      {
          list($data, $options) = $this->_prepareDataAndOptions($data, $options);
  
          $primaryKey = (array)$this->_table->getPrimaryKey();
          $entityClass = $this->_table->getEntityClass();
          /** @var \Cake\Datasource\EntityInterface $entity */
          $entity = new $entityClass();
          $entity->setSource($this->_table->getRegistryAlias());
  
          if (isset($options['accessibleFields'])) {
              foreach ((array)$options['accessibleFields'] as $key => $value) {
                  $entity->setAccess($key, $value);
              }
          }
          $errors = $this->_validate($data, $options, true);
  
          $options['isMerge'] = false;
          $propertyMap = $this->_buildPropertyMap($data, $options);
          $properties = [];
          foreach ($data as $key => $value) {
              if (!empty($errors[$key])) {
                  if ($entity instanceof InvalidPropertyInterface) {
                      $entity->setInvalidField($key, $value);
                  }
                  continue;
              }
  
              if ($value === '' && in_array($key, $primaryKey, true)) {
                  // Skip marshalling '' for pk fields.
                  continue;
              }
              if (isset($propertyMap[$key])) {
                  $properties[$key] = $propertyMap[$key]($value, $entity);
              } else {
                  $properties[$key] = $value;
              }
          }
  
          if (isset($options['fields'])) {
              foreach ((array)$options['fields'] as $field) {
                  if (array_key_exists($field, $properties)) {
                      $entity->set($field, $properties[$field]);
                  }
              }
          } else {
              $entity->set($properties);
          }
  
          // Don't flag clean association entities as
          // dirty so we don't persist empty records.
          foreach ($properties as $field => $value) {
              if ($value instanceof EntityInterface) {
                  $entity->setDirty($field, $value->isDirty());
              }
          }
  
          $entity->setErrors($errors);
  
          return $entity;
      }
code: public function one(array $data, array $options = [])
      {
          list($data, $options) = $this->_prepareDataAndOptions($data, $options);
  
          $primaryKey = (array)$this->_table->getPrimaryKey();
          $entityClass = $this->_table->getEntityClass();
          /** @var \Cake\Datasource\EntityInterface $entity */
          $entity = new $entityClass();
          $entity->setSource($this->_table->getRegistryAlias());
  
          if (isset($options['accessibleFields'])) {
              foreach ((array)$options['accessibleFields'] as $key => $value) {
                  $entity->setAccess($key, $value);
              }
          }
          $errors = $this->_validate($data, $options, true);
  
          $options['isMerge'] = false;
          $propertyMap = $this->_buildPropertyMap($data, $options);
          $properties = [];
          foreach ($data as $key => $value) {
              if (!empty($errors[$key])) {
                  if ($entity instanceof InvalidPropertyInterface) {
                      $entity->setInvalidField($key, $value);
                  }
                  continue;
              }
  
              if ($value === '' && in_array($key, $primaryKey, true)) {
                  // Skip marshalling '' for pk fields.
                  continue;
              }
              if (isset($propertyMap[$key])) {
                  $properties[$key] = $propertyMap[$key]($value, $entity);
              } else {
                  $properties[$key] = $value;
              }
          }
  
          if (isset($options['fields'])) {
              foreach ((array)$options['fields'] as $field) {
                  if (array_key_exists($field, $properties)) {
                      $entity->set($field, $properties[$field]);
                  }
              }
          } else {
              $entity->set($properties);
          }
  
          // Don't flag clean association entities as
          // dirty so we don't persist empty records.
          foreach ($properties as $field => $value) {
              if ($value instanceof EntityInterface) {
                  $entity->setDirty($field, $value->isDirty());
              }
          }
  
          $entity->setErrors($errors);
  
          return $entity;
      }
code_tokens: public function one ( array $ data , array $ options = [ ] ) { list ( $ data , $ options ) = $ this -> _prepareDataAndOptions ( $ data , $ options ) ; $ primaryKey = ( array ) $ this -> _table -> getPrimaryKey ( ) ; $ entityClass = $ this -> _table -> getEntityClass ( ) ; /** @var \Cake\Datasource\EntityInterface $entity */ $ entity = new $ entityClass ( ) ; $ entity -> setSource ( $ this -> _table -> getRegistryAlias ( ) ) ; if ( isset ( $ options [ 'accessibleFields' ] ) ) { foreach ( ( array ) $ options [ 'accessibleFields' ] as $ key => $ value ) { $ entity -> setAccess ( $ key , $ value ) ; } } $ errors = $ this -> _validate ( $ data , $ options , true ) ; $ options [ 'isMerge' ] = false ; $ propertyMap = $ this -> _buildPropertyMap ( $ data , $ options ) ; $ properties = [ ] ; foreach ( $ data as $ key => $ value ) { if ( ! empty ( $ errors [ $ key ] ) ) { if ( $ entity instanceof InvalidPropertyInterface ) { $ entity -> setInvalidField ( $ key , $ value ) ; } continue ; } if ( $ value === '' && in_array ( $ key , $ primaryKey , true ) ) { // Skip marshalling '' for pk fields. continue ; } if ( isset ( $ propertyMap [ $ key ] ) ) { $ properties [ $ key ] = $ propertyMap [ $ key ] ( $ value , $ entity ) ; } else { $ properties [ $ key ] = $ value ; } } if ( isset ( $ options [ 'fields' ] ) ) { foreach ( ( array ) $ options [ 'fields' ] as $ field ) { if ( array_key_exists ( $ field , $ properties ) ) { $ entity -> set ( $ field , $ properties [ $ field ] ) ; } } } else { $ entity -> set ( $ properties ) ; } // Don't flag clean association entities as // dirty so we don't persist empty records. foreach ( $ properties as $ field => $ value ) { if ( $ value instanceof EntityInterface ) { $ entity -> setDirty ( $ field , $ value -> isDirty ( ) ) ; } } $ entity -> setErrors ( $ errors ) ; return $ entity ; }
docstring: Hydrate one entity and its associated data.
  
  ### Options:
  
  - validate: Set to false to disable validation. Can also be a string of the validator ruleset to be applied.
  Defaults to true/default.
  - associated: Associations listed here will be marshalled as well. Defaults to null.
  - fieldList: (deprecated) Since 3.4.0. Use fields instead.
  - fields: A whitelist of fields to be assigned to the entity. If not present,
  the accessible fields list in the entity will be used. Defaults to null.
  - accessibleFields: A list of fields to allow or deny in entity accessible fields. Defaults to null
  - forceNew: When enabled, belongsToMany associations will have 'new' entities created
  when primary key values are set, and a record does not already exist. Normally primary key
  on missing entities would be ignored. Defaults to false.
  
  The above options can be used in each nested `associated` array. In addition to the above
  options you can also use the `onlyIds` option for HasMany and BelongsToMany associations.
  When true this option restricts the request data to only be read from `_ids`.
  
  ```
  $result = $marshaller->one($data, [
  'associated' => ['Tags' => ['onlyIds' => true]]
  ]);
  ```
  
  @param array $data The data to hydrate.
  @param array $options List of options
  @return \Cake\Datasource\EntityInterface
  @see \Cake\ORM\Table::newEntity()
  @see \Cake\ORM\Entity::$_accessible
docstring_tokens: Hydrate one entity and its associated data .