Skip to content

Commit

Permalink
re-added doctrine events
Browse files Browse the repository at this point in the history
  • Loading branch information
petrparolek authored and f3l1x committed Feb 7, 2024
1 parent 2db0cab commit 7e0d7cf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/Model/Service/LibraryLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace App\Model\Service;

use Doctrine\Common\EventSubscriber;

//use Doctrine\DBAL\Event\ConnectionEventArgs;
//use Doctrine\DBAL\Events;
use Doctrine\ORM\Event\PostLoadEventArgs;
use Doctrine\ORM\Events;
use LengthException;

/**
* Naive implementation of library limiter that checks the size of book library
Expand All @@ -27,21 +27,21 @@ final class LibraryLimiter implements EventSubscriber
public function getSubscribedEvents(): array
{
return [
//Events::postConnect
Events::postLoad,
];
}

/*public function postConnect(ConnectionEventArgs $args): void
public function postLoad(PostLoadEventArgs $args): void
{
$schemaManager = $args->getConnection()->createSchemaManager();
$schemaManager = $args->getObjectManager()->getConnection()->createSchemaManager();

if ($schemaManager->tablesExist(['book']) === true) {
$all = $args->getConnection()->fetchAllAssociative('SELECT id FROM book');
$all = $args->getObjectManager()->getConnection()->fetchAllAssociative('SELECT id FROM book');

if (count($all) > self::LIBRARY_MAX_SIZE) {
throw new LengthException('Oops. Too many books were placed in such a small library and it collapsed.');
}
}
}*/
}

}

0 comments on commit 7e0d7cf

Please sign in to comment.