Skip to content

Commit

Permalink
[TASK]Use doctrine instead of extbase persistencemanager
Browse files Browse the repository at this point in the history
  • Loading branch information
yabid21 committed Sep 21, 2023
1 parent f098319 commit 86d5b0e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
45 changes: 37 additions & 8 deletions Classes/Domain/Model/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,47 @@ public function getTitle(): string
return $this->title;
}

public function setTitle(string $title): void
public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}

public function getClientId(): string
{
return $this->id;
}

public function setId(string $id): void
public function setId(string $id): self
{
$this->id = $id;

return $this;
}

public function getClientSecret(): string
{
return $this->secret;
}

public function setSecret(string $secret): void
public function setSecret(string $secret): self
{
$this->secret = $secret;

return $this;
}

public function getDomain(): string
{
return $this->domain;
}

public function setDomain(string $domain): void
public function setDomain(string $domain): self
{
$this->domain = $domain;

return $this;
}

public function getFullDomain(): string
Expand All @@ -115,9 +123,11 @@ public function getAudience(bool $asFullDomain = false): string
return $this->audience;
}

public function setAudience(string $audience): void
public function setAudience(string $audience): self
{
$this->audience = trim($audience, '/') . '/';

return $this;
}

public function getApiBasePath(): string
Expand All @@ -130,19 +140,23 @@ public function isSingleLogOut(): bool
return $this->singleLogOut;
}

public function setSingleLogOut(bool $singleLogOut): void
public function setSingleLogOut(bool $singleLogOut): self
{
$this->singleLogOut = $singleLogOut;

return $this;
}

public function getSignatureAlgorithm(): string
{
return $this->signatureAlgorithm;
}

public function setSignatureAlgorithm(string $signatureAlgorithm): void
public function setSignatureAlgorithm(string $signatureAlgorithm): self
{
$this->signatureAlgorithm = $signatureAlgorithm;

return $this;
}

public function isCustomDomain(): bool
Expand All @@ -155,8 +169,23 @@ public function hasApi(): bool
return $this->api;
}

public function setApi(bool $api): void
public function setApi(bool $api): self
{
$this->api = $api;

return $this;
}

public static function fromArray(array $data): self
{
return (new self())
->setTitle($data['title'])
->setId($data['id'])
->setSecret($data['secret'])
->setDomain($data['domain'])
->setAudience($data['audience'])
->setSingleLogOut((bool)$data['single_log_out'])
->setSignatureAlgorithm($data['signature_algorithm'] ?? '')
->setApi((bool)$data['api']);
}
}
18 changes: 16 additions & 2 deletions Classes/Domain/Repository/ApplicationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,29 @@
use Leuchtfeuer\Auth0\Domain\Model\Application;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;

class ApplicationRepository
{
const TABLE_NAME = 'tx_auth0_domain_model_application';

public function findByUid(int $uid): ?Application
{
return GeneralUtility::makeInstance(PersistenceManager::class)->getObjectByIdentifier($uid, Application::class);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable(self::TABLE_NAME);
$applicationArray = $queryBuilder
->select('*')
->from(self::TABLE_NAME)
->where(
$queryBuilder->expr()->eq('uid', $uid)
)
->setMaxResults(1)
->executeQuery()->fetchAllAssociative() ?? [];

if (empty($applicationArray)) {
return null;
}

return Application::fromArray($applicationArray[0]);
}

public function findAll(): array
Expand Down
1 change: 0 additions & 1 deletion Classes/Utility/TokenUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
use Leuchtfeuer\Auth0\Middleware\CallbackMiddleware;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down

0 comments on commit 86d5b0e

Please sign in to comment.