Only count published daily emails
This commit is contained in:
parent
c48f8acd4a
commit
b479e15b66
2 changed files with 10 additions and 5 deletions
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||||
namespace Drupal\opd_daily_emails\Repository;
|
namespace Drupal\opd_daily_emails\Repository;
|
||||||
|
|
||||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||||
|
use Drupal\node\NodeInterface;
|
||||||
|
|
||||||
final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
||||||
->getStorage('node')
|
->getStorage('node')
|
||||||
->getQuery();
|
->getQuery();
|
||||||
|
|
||||||
// TODO: add condition for published status. Only return published nodes.
|
$query->condition('status', NodeInterface::PUBLISHED);
|
||||||
$query->condition('type', 'daily_email');
|
$query->condition('type', 'daily_email');
|
||||||
|
|
||||||
$query->accessCheck(TRUE);
|
$query->accessCheck(TRUE);
|
||||||
|
|
|
@ -19,12 +19,16 @@ final class DailyEmailNodeRepositoryTest extends EntityKernelTestBase {
|
||||||
'opd_daily_emails',
|
'opd_daily_emails',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
public function test_get_all_published_daily_emails(): void {
|
||||||
* @testdox Get all daily emails
|
|
||||||
*/
|
|
||||||
public function test_get_all(): void {
|
|
||||||
$this->createNode([
|
$this->createNode([
|
||||||
'status' => NodeInterface::PUBLISHED,
|
'status' => NodeInterface::PUBLISHED,
|
||||||
|
'title' => 'A published daily email',
|
||||||
|
'type' => 'daily_email',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->createNode([
|
||||||
|
'status' => NodeInterface::NOT_PUBLISHED,
|
||||||
|
'title' => 'An unpublished daily email',
|
||||||
'type' => 'daily_email',
|
'type' => 'daily_email',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue