Skip to content

Commit

Permalink
feat(chore): implement usage without user
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisdugue committed Jan 29, 2024
1 parent 817fba4 commit ab16049
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions Core/H5PSymfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Studit\H5PBundle\Core;

use DateTime;
use DateTimeInterface;
use Doctrine\DBAL\Exception;
use Doctrine\ORM\EntityManagerInterface;
Expand Down Expand Up @@ -35,7 +36,6 @@
use Doctrine\DBAL\Exception\ConnectionException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;

class H5PSymfony implements \H5PFrameworkInterface
{
Expand Down Expand Up @@ -1088,8 +1088,8 @@ public function replaceContentTypeCache($contentTypeCache): void
{
$this->truncateTable(LibrariesHubCache::class);
foreach ($contentTypeCache->contentTypes as $ct) {
$created_at = new \DateTime($ct->createdAt);
$updated_at = new \DateTime($ct->updatedAt);
$created_at = new DateTime($ct->createdAt);
$updated_at = new DateTime($ct->updatedAt);
$cache = new LibrariesHubCache();
$cache->setMachineName($ct->id);
$cache->setMajorVersion($ct->version->major);
Expand Down Expand Up @@ -1118,18 +1118,23 @@ public function replaceContentTypeCache($contentTypeCache): void
}

/**
* @param string $tableClassName
* @throws Exception
* Truncate the specified database table.
*
* This method truncates the given database table by executing SQL queries to temporarily
* disable foreign key checks, truncate the table, and then re-enable foreign key checks.
* Truncating a table removes all rows but keeps the table structure intact.
*
* @param string $tableClassName The fully qualified class name of the entity representing the table.
* @return void
*/
* @throws Exception
* */
private function truncateTable(string $tableClassName): void
{
$cmd = $this->manager->getClassMetadata($tableClassName);
$connection = $this->manager->getConnection();
$dbPlatform = $connection->getDatabasePlatform();
$connection->executeQuery('SET FOREIGN_KEY_CHECKS=0');
$q = $dbPlatform->getTruncateTableSql($cmd->getTableName());
$connection->executeStatement($q);
$connection->executeStatement($dbPlatform->getTruncateTableSql($cmd->getTableName()));
$connection->executeQuery('SET FOREIGN_KEY_CHECKS=1');
}

Expand Down Expand Up @@ -1164,7 +1169,7 @@ public function getContentHubMetadataChecked($lang = 'en'): ?string
{
// Todo fetch the timestamp of current language here
// dd(Languages::getName($lang));
$date = new \DateTime('now');
$date = new DateTime('now');
return $date->format(DateTimeInterface::RFC7231);
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jorisdugue/h5p-bundle",
"version": "2.1.0",
"version": "2.0.2",
"type": "symfony-bundle",
"description": "H5P Bundle for Symfony 5, 6 and Symfony 7",
"keywords": [
Expand Down

0 comments on commit ab16049

Please sign in to comment.