Skip to content

Commit

Permalink
fix(chore): prevent deprecated of php
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisdugue authored Nov 2, 2024
1 parent b41fc78 commit 99b2c63
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Command/H5pBundleIncludeAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
namespace Studit\H5PBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\KernelInterface;

class H5pBundleIncludeAssetsCommand extends Command
Expand All @@ -26,7 +23,7 @@ public function __construct(KernelInterface $appKernel)
parent::__construct();
}

protected function configure()
protected function configure(): void
{
$this
->setDescription(
Expand All @@ -39,16 +36,18 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->includeAssets($input->getOption('copy') ?? false);
return 0;
return Command::SUCCESS;
}

private function includeAssets(bool $copy): void
{
$projectDir = $this->appKernel->getProjectDir();

//get dir of vendor H5P
$fromDir = $projectDir . "/vendor/h5p/";

$fromDir = $this->appKernel->getProjectDir() . "/vendor/h5p/";
//call service
$toDir = $this->appKernel->getProjectDir() . '/public/bundles/studith5p/h5p/';
$toDir = $projectDir . '/public/bundles/studith5p/h5p/';

$coreSubDir = "h5p-core/";
$coreDirs = ["fonts", "images", "js", "styles"];
Expand All @@ -59,7 +58,7 @@ private function includeAssets(bool $copy): void
$this->createFiles($fromDir, $toDir, $editorSubDir, $editorDirs, $copy);
}

private function createFiles($fromDir, $toDir, $subDir, $subDirs, $copy)
private function createFiles(string $fromDir, string $toDir, string $subDir, array $subDirs, bool $copy): void
{
foreach ($subDirs as $dir) {
$src = $fromDir . $subDir . $dir;
Expand All @@ -71,7 +70,7 @@ private function createFiles($fromDir, $toDir, $subDir, $subDirs, $copy)
}
}

private function recurseCopy($src, $dst)
private function recurseCopy(string $src, string $dst): void
{
$dir = opendir($src);
// Restrict the permission to 0750 not upper
Expand Down

0 comments on commit 99b2c63

Please sign in to comment.