Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial commit #37

Draft
wants to merge 1 commit into
base: doctrine
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions module/VuFind/src/VuFind/Db/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,4 +761,28 @@ public function getEmailVerified(): ?DateTime
{
return $this->emailVerified;
}

/**
* Populate entity data from an associative array.
*
* @param array $data Key-value pairs representing entity properties.
*/
public function exchangeArray(array $data): void
{
foreach ($data as $key => $value) {
if (property_exists($this, $key)) {
$this->$key = $value;
}
}
}

/**
* Get an array representation of the entity.
*
* @return array
*/
public function toArray(): array
{
return get_object_vars($this);
}
}
14 changes: 14 additions & 0 deletions module/VuFind/src/VuFind/Db/Entity/UserEntityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,18 @@ public function setEmailVerified(?DateTime $dateTime): static;
* @return ?DateTime
*/
public function getEmailVerified(): ?DateTime;

/**
* Populate entity data from an associative array.
*
* @param array $data Key-value pairs representing entity properties.
*/
public function exchangeArray(array $data): void;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually make this a separate interface, like VuFind\Db\Entity\ExchangeArrayInterface and then you could implement it via VuFind\Db\Entity\ExchangeArrayTrait. Then UserEntityInterface could extend ExchangeArrayInterface. This way, we could "mix in" this function to other entities as needed, but we keep the session serialization functionality distinct from all of the other more user-specific functionality.


/**
* Get an array representation of the entity.
*
* @return array
*/
public function toArray(): array;
}
2 changes: 0 additions & 2 deletions module/VuFind/src/VuFind/Db/Row/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
'ratings' => Ratings::class,
'search' => Search::class,
'session' => Session::class,
'user' => User::class,
'userresource' => UserResource::class,
];

Expand All @@ -62,7 +61,6 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
Ratings::class => RowGatewayFactory::class,
Search::class => RowGatewayFactory::class,
Session::class => RowGatewayFactory::class,
User::class => UserFactory::class,
UserResource::class => RowGatewayFactory::class,
];

Expand Down
Loading
Loading