Skip to content

Commit

Permalink
feat(article): Get whole article
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlovicnemanja committed Nov 4, 2024
1 parent b6b2e63 commit 73b50b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/SWP/Bundle/ContentBundle/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,22 @@ public function getAction($id): SingleResourceResponseInterface {
public function getByCodeAction(Request $request): SingleResourceResponseInterface {
// Extract parameters from the request
$code = $request->query->get('code', '');

$article = $this->entityManager->createQuery('SELECT a.id FROM SWP\Bundle\ContentBundle\Model\Article a where a.code = :code')
->setParameter('code', $code)
//->setParameter('tenant_code', $tenantCode)
->setMaxResults(1)
->getOneOrNullResult();
$article = $this->entityManager->getRepository('SWP\Bundle\ContentBundle\Model\Article')
->findOneBy(['code' => $code]);

if (null === $article) {
throw new NotFoundHttpException('Article was not found');
}

$article->setStatus('new');
$article->setRouteId(null);
$article->setRoute(null);
$article->setPublishedAt(null);
$article->setIsPublishable(false);
$this->entityManager->flush();

// Find the swp_package associated with the article
$swpPackage = $article->getPackage();
$swpPackage = $this->entityManager->getRepository('SWP\Bundle\CoreBundle\Model\Package')
->findOneBy(['guid' => $code]);

if (null !== $swpPackage) {
// Update the swp_package fields
Expand Down
2 changes: 1 addition & 1 deletion src/SWP/Bundle/ContentBundle/Model/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function getPublishedAt()
return $this->publishedAt;
}

public function setPublishedAt(\DateTime $publishedAt)
public function setPublishedAt(?\DateTime $publishedAt)
{
$this->publishedAt = $publishedAt;
}
Expand Down

0 comments on commit 73b50b4

Please sign in to comment.