Skip to content

Commit

Permalink
Resource Service Migration (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
skellamp authored Jan 2, 2024
1 parent 093b349 commit a8fd705
Show file tree
Hide file tree
Showing 28 changed files with 477 additions and 825 deletions.
9 changes: 5 additions & 4 deletions module/VuFind/src/VuFind/Controller/Plugin/Favorites.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,17 @@ public function saveBulk($params, $user)
[$source, $id] = explode('|', $current, 2);

// Get or create a resource object as needed:
$resourceTable = $this->getController()->getTable('Resource');
$resource = $resourceTable->findResource($id, $source);
$resourceService = $this->getController()->getDbService(\VuFind\Db\Service\ResourceService::class);
$resource = $resourceService->findResource($id, $source);

// Add the information to the user's account:
$tags = isset($params['mytags'])
? $this->tags->parse($params['mytags']) : [];
$user->saveResource($resource, $list->getId(), $tags, '', false);
$userService = $this->getController()->getDbService(\VuFind\Db\Service\UserService::class);
$userService->saveResource($resource, $user->id, $list, $tags, '', false);

// Collect record IDs for caching
if ($this->cache->isCachable($resource->source)) {
if ($this->cache->isCachable($resource->getSource())) {
$cacheRecordIds[] = $current;
}
}
Expand Down
93 changes: 93 additions & 0 deletions module/VuFind/src/VuFind/Db/Entity/Ratings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

namespace VuFind\Db\Entity;

use DateTime;
use Doctrine\ORM\Mapping as ORM;

/**
Expand Down Expand Up @@ -107,6 +108,16 @@ class Ratings implements EntityInterface
*/
protected $created = '2000-01-01 00:00:00';

/**
* Id getter
*
* @return ?int
*/
public function getId(): ?int
{
return $this->id;
}

/**
* Get user.
*
Expand All @@ -116,4 +127,86 @@ public function getUser()
{
return $this->user;
}

/**
* User setter
*
* @param User $user User
*
* @return Ratings
*/
public function setUser(User $user): Ratings
{
$this->user = $user;
return $this;
}

/**
* Rating setter
*
* @param int $rating Rating
*
* @return Ratings
*/
public function setRating(int $rating): Ratings
{
$this->rating = $rating;
return $this;
}

/**
* Rating getter
*
* @return int
*/
public function getRating(): int
{
return $this->rating;
}

/**
* Resource setter
*
* @param Resource $resource Resource
*
* @return Ratings
*/
public function setResource(Resource $resource): Ratings
{
$this->resource = $resource;
return $this;
}

/**
* Resource getter
*
* @return Resource
*/
public function getResource(): Resource
{
return $this->resource;
}

/**
* Created setter.
*
* @param Datetime $dateTime Created date
*
* @return UserList
*/
public function setCreated(DateTime $dateTime): Ratings
{
$this->created = $dateTime;
return $this;
}

/**
* Created getter
*
* @return Datetime
*/
public function getCreated(): Datetime
{
return $this->created;
}
}
20 changes: 20 additions & 0 deletions module/VuFind/src/VuFind/Db/Entity/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ public function setTitle(string $title): Resource
return $this;
}

/**
* Title getter
*
* @return string
*/
public function getTitle(): string
{
return $this->title;
}

/**
* Author setter
*
Expand Down Expand Up @@ -231,4 +241,14 @@ public function setExtraMetadata(?string $extraMetadata): Resource
$this->extraMetadata = $extraMetadata;
return $this;
}

/**
* Extra Metadata getter
*
* @return ?string
*/
public function getExtraMetadata(): ?string
{
return $this->extraMetadata;
}
}
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
'accesstoken' => AccessToken::class,
'externalsession' => ExternalSession::class,
'ratings' => Ratings::class,
'resource' => Resource::class,
'search' => Search::class,
'session' => Session::class,
'user' => User::class,
Expand All @@ -66,7 +65,6 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
AuthHash::class => RowGatewayFactory::class,
ExternalSession::class => RowGatewayFactory::class,
Ratings::class => RowGatewayFactory::class,
Resource::class => RowGatewayFactory::class,
Search::class => RowGatewayFactory::class,
Session::class => RowGatewayFactory::class,
User::class => UserFactory::class,
Expand Down
Loading

0 comments on commit a8fd705

Please sign in to comment.