\Dewdrop\Auth\DbUserRowGateway

User database row data gateway class

You can set values on the row using the set() method like this:

$row->set('column_name', $value);

Or, you can set multiple values at once like this:

$row->set(
    array(
        'column_name'   => $value,
        'second_column' => $anotherValue
    )
);

Setting and retrieving values can also be done via direct object or array-style use of the object:

// Access a column's value with object syntax
echo $row->column_name;

// Access a column's value with array syntax
echo $row['column_name'];

// Set a column's value with object syntax
$row->column_name = 'Value';

// Set a column's value with array syntax
$row['column_name'] = 'Value';

Once the columns have been assigned the desired values, you can call save(), which will either update or insert the row depending upon whether it already exists in the database. After saving, the row's data is automatically refreshed to ensure it still accurately represents the corresponding row in the database. For example, if it is a new row, the primary key's value will be populated after calling save().

Additionally, you can retrieve field objects representing columns in this row by calling its field() method:

$row->field('column_name');

The field object allows you to easily integrate with other Dewdrop APIs, leveraging the database metadata to add validators, retrieve lists of options, etc.

Summary

Methods
Properties
Constants
__construct()
init()
setTable()
getTable()
field()
__set()
offsetSet()
set()
__get()
offsetGet()
get()
__isset()
offsetExists()
has()
__unset()
offsetUnset()
save()
isNew()
delete()
getData()
toArray()
shortcode()
hasRole()
eraseCredentials()
getPassword()
getRoles()
getSalt()
getId()
getUsername()
getEmailAddress()
getShortName()
getFullName()
hashPassword()
setRole()
__sleep()
__wakeup()
No public properties found
No constants found
No protected methods found
$data
$columns
$role
N/A
refresh()
assembleUpdateWhereClause()
$table
$virtualFieldsInitialized
N/A

Properties

$data

$data : array

The data represented by this row.

Type

array

$columns

$columns : array

The columns available to this row as defined by the associated table's metadata.

Type

array

$role

$role : \Symfony\Component\Security\Core\Role\Role

Role

Type

\Symfony\Component\Security\Core\Role\Role

$table

$table : \Dewdrop\Db\Table

The table this row is associated with.

Type

\Dewdrop\Db\Table

$virtualFieldsInitialized

$virtualFieldsInitialized : array

A map of many-to-many and EAV fieldsthat tracks whether their initial value has been loaded yet. If not, the first time get() is called on this row for the field, the value will be loaded from the database.

Type

array

Methods

__construct()

__construct(\Dewdrop\Db\Table  $table, array  $data = array()) 

Instantiate the row, checking to ensure the data array contains only those columns present in the table's metadata.

Parameters

\Dewdrop\Db\Table $table
array $data

init()

init() : void

This method can be used by sub-classes to store initial values (for comparison during saving, for example).

setTable()

setTable(\Dewdrop\Db\Table  $table) : $this

Provide a new table instance for the row. Mostly useful if you're implementing a __wakeup() method.

Parameters

\Dewdrop\Db\Table $table

Returns

$this

getTable()

getTable() : \Dewdrop\Db\Table

Get the table associated with this row.

Returns

\Dewdrop\Db\Table

field()

field(string  $name) : \Dewdrop\Db\Field

Retrieve a field object representing the specified column name.

Parameters

string $name

Returns

\Dewdrop\Db\Field

__set()

__set(string  $key, mixed  $value) : void

Allow setting of data properties on this row via direct object property syntax:

$row->property_id = $value;

Parameters

string $key
mixed $value

offsetSet()

offsetSet(string  $key, mixed  $value) : void

Allow setting of data properties on this row via direct array syntax:

$row['property_id'] = $value;

This is part of the ArrayAccess interface built into PHP.

Parameters

string $key
mixed $value

set()

set(string|array  $column, mixed  $value = null) : $this

The the value of one or more columns on this row.

If $name is a string, that single column will be set. If $name is an array, the array will be iterated and each key-value pair will be set on the row.

Parameters

string|array $column
mixed $value

Throws

\Dewdrop\Exception

Returns

$this

__get()

__get(string  $key) : mixed

Allow retrieval of data values via direct object property access:

echo $row->property_id;

Parameters

string $key

Returns

mixed

offsetGet()

offsetGet(string  $key) : mixed

Allow retrieval of data values via direct array access:

echo $row['property_id'];

This method is part of the ArrayAccess interface built into PHP.

Parameters

string $key

Returns

mixed

get()

get(string  $name) : mixed

Get the value of the specified column.

Parameters

string $name

Throws

\Dewdrop\Exception

Returns

mixed

__isset()

__isset(string  $key) : boolean

Test to see if a given column exists on this row using object syntax:

isset($row->column_name);

Parameters

string $key

Returns

boolean

offsetExists()

offsetExists(string  $key) : boolean

Test to see if a given column exists on this row using array syntax:

isset($row['column_name']);

This method is part of the ArrayAccess interface built into PHP.

Parameters

string $key

Returns

boolean

has()

has(string  $name) : boolean

Test to see if the given column exists on this row.

Parameters

string $name

Returns

boolean

__unset()

__unset(string  $key) 

We do not allow unsetting columns on a row.

Parameters

string $key

Throws

\Dewdrop\Exception

offsetUnset()

offsetUnset(string  $key) 

Even though this method is required by the ArrayAccess interface, we do not allow unsetting columns on a row.

Parameters

string $key

Throws

\Dewdrop\Exception

save()

save() : $this

Save this row, inserting if it is a new row and updating otherwise.

Returns

$this

isNew()

isNew() : boolean

Determine whether this row is new or already present in the DB by checking if its primary key columns have a value assigned.

Returns

boolean

delete()

delete() : integer

Deletes existing rows.

Returns

integer —

The number of rows deleted.

getData()

getData() : array

Returns the row data.

Returns

array

toArray()

toArray() : array

Returns an array representation of the row data.

Returns

array

shortcode()

shortcode() : string

Returns

string

hasRole()

hasRole(\Symfony\Component\Security\Core\Role\Role|string  $role) : boolean

Check to see if the user has the specified role.

Parameters

\Symfony\Component\Security\Core\Role\Role|string $role

Returns

boolean

eraseCredentials()

eraseCredentials() : void

Removes sensitive data from the user.

This is important if, at any given point, sensitive information like the plain-text password is stored on this object.

getPassword()

getPassword() : string

Returns the password used to authenticate the user.

This should be the encoded password. On authentication, a plain-text password will be salted, encoded, and then compared to this value.

Returns

string —

The password

getRoles()

getRoles() : array<mixed,\Symfony\Component\Security\Core\Role\Role>

Returns the roles granted to the user.

public function getRoles()
{
    return array('ROLE_USER');
}

Alternatively, the roles might be stored on a roles property, and populated in any number of different ways when the user object is created.

Returns

array<mixed,\Symfony\Component\Security\Core\Role\Role> —

The user roles

getSalt()

getSalt() : string

Returns the salt that was originally used to encode the password.

This can return null if the password was not encoded using a salt.

Returns

string —

The salt

getId()

getId() : integer

Get ID

Returns

integer

getUsername()

getUsername() : string

Returns the username used to authenticate the user.

Returns

string —

The username

getEmailAddress()

getEmailAddress() : string

Get email address

Returns

string

getShortName()

getShortName() : string

Get short name (e.g., Jane D)

Returns

string

getFullName()

getFullName() : string

Get full name (e.g., John Doe)

Returns

string

hashPassword()

hashPassword(string  $plaintextPassword) : \Dewdrop\Auth\Db\UserRowGateway

Hashes the given plain text password and stores the result, which can be retrieved with getPassword()

Parameters

string $plaintextPassword

Returns

\Dewdrop\Auth\Db\UserRowGateway

setRole()

setRole(\Symfony\Component\Security\Core\Role\Role  $role) : \Dewdrop\Auth\Db\UserRowGateway

Set role

Parameters

\Symfony\Component\Security\Core\Role\Role $role

Returns

\Dewdrop\Auth\Db\UserRowGateway

__sleep()

__sleep() : array

Serialize columns and data only

Returns

array

__wakeup()

__wakeup() : void

Set the table data gateway on unserialize()

refresh()

refresh() : $this

Refresh the row, pulling in the latest data from the DB.

Returns

$this

assembleUpdateWhereClause()

assembleUpdateWhereClause() : string

Assemble the WHERE clause for the update method using the primary key column's from the associated table.

Returns

string