Skip to content

Commit

Permalink
Merge pull request #41 from DivanteLtd/pimcoreX
Browse files Browse the repository at this point in the history
fix sync assets command
  • Loading branch information
bramalho authored Jul 16, 2021
2 parents 6a5dfb9 + dda5603 commit 38995d9
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Command/SynchronizeAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

namespace PimcoreDevkitBundle\Command;

use Pimcore\Console\AbstractCommand;
use Pimcore\Model\Asset;
use Pimcore\Model\DataObject\Folder;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -19,7 +18,7 @@
* Class SynchronizeAssetsCommand
* @package PimcoreDevkitBundle\Command
*/
class SynchronizeAssetsCommand extends AbstractCommand
class SynchronizeAssetsCommand extends Command
{
/**
* @return void
Expand All @@ -40,10 +39,10 @@ protected function configure(): void
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @return int
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$folder = $input->getArgument("folder");

Expand All @@ -52,15 +51,15 @@ protected function execute(InputInterface $input, OutputInterface $output): void
} else {
$folder = $folder[0];
}
$files = $this->listFolderFiles(PIMCORE_ASSET_DIRECTORY . $folder);
$files = $this->listFolderFiles(PIMCORE_WEB_ROOT . '/var/assets' . $folder);

foreach ($files as $file) {
// Is it a directory?
if (is_dir($file)) {
continue;
}

$parentPath = substr(dirname($file), strlen(PIMCORE_ASSET_DIRECTORY)) . "/";
$parentPath = substr(dirname($file), strlen(PIMCORE_WEB_ROOT . '/var/assets')) . "/";
$filename = basename($file);
$fileModificationDate = filemtime($file);

Expand Down Expand Up @@ -94,6 +93,8 @@ protected function execute(InputInterface $input, OutputInterface $output): void
}
}
}

return Command::SUCCESS;
}

/**
Expand Down

0 comments on commit 38995d9

Please sign in to comment.