Skip to content
Open
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
2 changes: 1 addition & 1 deletion Entity/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
*/
interface UserInterface
{
public function getId(): int;
public function getId(): ?int;
}
15 changes: 13 additions & 2 deletions Entity/WidgetUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace Pd\WidgetBundle\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Pd\WidgetBundle\Repository\WidgetUserRepository;

/**
* Widget Private User Data.
Expand All @@ -22,30 +24,39 @@
*
* @author Ramazan APAYDIN <apaydin541@gmail.com>
*/
#[ORM\Entity(repositoryClass: WidgetUserRepository::class)]
#[ORM\Table(name: 'widget_user')]
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')]
class WidgetUser
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private $id;

/**
* @ORM\Column(type="array")
*/
#[ORM\Column(type: Types::ARRAY)]
private $config;

/**
* @ORM\OneToOne(targetEntity="UserInterface")
* @ORM\JoinColumn(referencedColumnName="id", unique=true, onDelete="CASCADE")
*/
#[ORM\OneToOne(targetEntity: UserInterface::class)]
#[ORM\JoinColumn(referencedColumnName: 'id', unique: true, onDelete: 'CASCADE')]
private $owner;

/**
* Get id.
*/
public function getId(): int
public function getId(): ?int
{
return $this->id;
}
Expand All @@ -57,7 +68,7 @@ public function setConfig(array $config): self
return $this;
}

public function getConfig(): array
public function getConfig(): ?array
{
return $this->config;
}
Expand Down
3 changes: 2 additions & 1 deletion Widget/WidgetBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Doctrine\ORM\EntityManagerInterface;
use Pd\WidgetBundle\Builder\ItemInterface;
use Pd\WidgetBundle\Entity\WidgetUser;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;

/**
Expand Down Expand Up @@ -115,7 +116,7 @@ private function loadUserConfig(): void
{
if (!$this->widgetConfig) {
$config = $this->entityManager
->getRepository('PdWidgetBundle:WidgetUser')
->getRepository(WidgetUser::class)
->findOneBy([
'owner' => $this->tokenStorage->getToken()->getUser(),
]);
Expand Down