class Row (View source)

Stores a row.

Constants

PROPERTY_SEPARATOR

Level separator of destination and source properties.

Properties

protected array $source

The actual values of the source row.

protected array $sourceIds

The source identifiers.

protected array $destination

The destination values.

protected array $idMap

The mapping between source and destination identifiers.

protected bool $frozen

Whether the source has been frozen already.

protected array $rawDestination

The raw destination properties.

protected bool $isStub

TRUE when this row is a stub.

protected array $emptyDestinationProperties

The empty destination properties.

Methods

__construct(array $values = [], array $source_ids = [], bool $is_stub = FALSE)

Constructs a \Drupal\migrate\Row object.

array
getSourceIdValues()

Retrieves the values of the source identifiers.

bool
hasSourceProperty(string $property)

Determines whether a source has a property.

mixed|null
getSourceProperty(string $property)

Retrieves a source property.

array
getSource()

Returns the whole source array.

setSourceProperty(string $property, mixed $data)

Sets a source property if the row is not frozen.

$this
freezeSource()

Freezes the source.

Row
cloneWithoutDestination()

Clones the row with an empty set of destination values.

bool
hasDestinationProperty(array|string $property)

Tests if destination property exists.

setDestinationProperty(string $property, mixed $value)

Sets destination properties.

removeDestinationProperty(string $property)

Removes destination property.

setEmptyDestinationProperty(string $property)

Sets a destination to be empty.

array
getEmptyDestinationProperties()

Gets the empty destination properties.

array
getDestination()

Returns the whole destination array.

array
getRawDestination()

Returns the raw destination. Rarely necessary.

mixed
getDestinationProperty(string $property)

Returns the value of a destination property.

mixed|null
get(string $property)

Retrieve a source or destination property.

array
getMultiple(array $properties)

Retrieve multiple source and destination properties at once.

setIdMap(array $id_map)

Sets the Migrate ID mappings.

array
getIdMap()

Retrieves the Migrate ID mappings.

rehash()

Recalculates the hash for the row.

bool
changed()

Checks whether the row has changed compared to the original ID map.

bool
needsUpdate()

Returns if this row needs an update.

mixed
getHash()

Returns the hash for the source values.

bool
isStub()

Reports whether this row is a stub.

Details

__construct(array $values = [], array $source_ids = [], bool $is_stub = FALSE)

Constructs a \Drupal\migrate\Row object.

Parameters

array $values

An array of values to add as properties on the object.

array $source_ids

An array containing the IDs of the source using the keys as the field names.

bool $is_stub

TRUE if the row being created is a stub.

Exceptions

InvalidArgumentException

array getSourceIdValues()

Retrieves the values of the source identifiers.

Return Value

array

An array containing the values of the source identifiers. Returns values in the same order as defined in $this->sourceIds.

bool hasSourceProperty(string $property)

Determines whether a source has a property.

Parameters

string $property

A property on the source.

Return Value

bool

TRUE if the source has property; FALSE otherwise.

mixed|null getSourceProperty(string $property)

Retrieves a source property.

This function directly retrieves a source property. It does not unescape '@' symbols. This is most useful in source plugins when you don't want to worry about escaping '@' symbols. If using this in a process plugin to retrieve a source property based on a configuration value, consider if the ::get() function might be more appropriate, to allow the migration to potentially specify a destination key as well.

Parameters

string $property

A property on the source.

Return Value

mixed|null

The found returned property or NULL if not found.

array getSource()

Returns the whole source array.

Return Value

array

An array of source plugins.

setSourceProperty(string $property, mixed $data)

Sets a source property if the row is not frozen.

This can only be called from the source plugin.

Parameters

string $property

A property on the source.

mixed $data

The property value to set on the source.

Exceptions

Exception

See also

SourcePluginBase::next

$this freezeSource()

Freezes the source.

Return Value

$this

Row cloneWithoutDestination()

Clones the row with an empty set of destination values.

Return Value

Row

bool hasDestinationProperty(array|string $property)

Tests if destination property exists.

Parameters

array|string $property

An array of properties on the destination.

Return Value

bool

TRUE if the destination property exists.

setDestinationProperty(string $property, mixed $value)

Sets destination properties.

Parameters

string $property

The name of the destination property.

mixed $value

The property value to set on the destination.

removeDestinationProperty(string $property)

Removes destination property.

Parameters

string $property

The name of the destination property.

setEmptyDestinationProperty(string $property)

Sets a destination to be empty.

Parameters

string $property

The destination property.

array getEmptyDestinationProperties()

Gets the empty destination properties.

Return Value

array

An array of destination properties.

array getDestination()

Returns the whole destination array.

Return Value

array

An array of destination values.

array getRawDestination()

Returns the raw destination. Rarely necessary.

For example calling setDestination('foo/bar', 'baz') results in

Return Value

array

The raw destination values.

mixed getDestinationProperty(string $property)

Returns the value of a destination property.

This function directly returns a destination property. The property name should not begin with an @ symbol. This is most useful in a destination plugin.

Parameters

string $property

The name of a property on the destination.

Return Value

mixed

The destination value.

mixed|null get(string $property)

Retrieve a source or destination property.

If the property key begins with '@' return a destination property, otherwise return a source property. the '@' symbol itself can be escaped as '@@'. Returns NULL if property is not found. Useful in process plugins to retrieve a row property specified in a configuration key which may be either a source or destination property prefixed with an '@'.

Parameters

string $property

The property to get.

Return Value

mixed|null

The requested property.

array getMultiple(array $properties)

Retrieve multiple source and destination properties at once.

Parameters

array $properties

An array of values to retrieve, with destination values prefixed with @.

Return Value

array

An array of property values, keyed by property name.

setIdMap(array $id_map)

Sets the Migrate ID mappings.

Parameters

array $id_map

An array of mappings between source ID and destination ID.

array getIdMap()

Retrieves the Migrate ID mappings.

Return Value

array

An array of mapping between source and destination identifiers.

rehash()

Recalculates the hash for the row.

bool changed()

Checks whether the row has changed compared to the original ID map.

Return Value

bool

TRUE if the row has changed, FALSE otherwise. If setIdMap() was not called, this always returns FALSE.

bool needsUpdate()

Returns if this row needs an update.

Return Value

bool

TRUE if the row needs updating, FALSE otherwise.

mixed getHash()

Returns the hash for the source values.

.

Return Value

mixed

The hash of the source values.

bool isStub()

Reports whether this row is a stub.

Return Value

bool

The current stub value.