-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Codebase to Use Symfony Filesystem Instead of Native PHP Functions #1109
base: dev
Are you sure you want to change the base?
Conversation
d9b2502
to
0c9d13d
Compare
210af31
to
52308ff
Compare
|
||
if ($filesystem->exists($filePath)) { | ||
if ($this->container->getUpdateConfiguration()->isChannelOnline()) { | ||
try { | ||
$filesystem->remove($filePath); | ||
$this->logger->debug($this->translator->trans('%s removed', [$filePath])); | ||
} catch (Exception $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but I think you can use IOExceptionInterface
from symfony filesystem.
try { | ||
$filesystem->remove($latestPath); | ||
$this->logger->debug($this->translator->trans('%s removed', [$latestPath])); | ||
} catch (Exception $e) { | ||
$this->logger->debug($this->translator->trans('Please remove %s by FTP', [$latestPath])); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do the same as other try catch what do you think about make a method for it ?
$this->logger->debug($this->translator->trans('Please remove %s by FTP', [$filePath])); | ||
} | ||
} else { | ||
$this->logger->debug($this->translator->trans('Please remove %s by FTP', [$filePath])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we log remove by ftp if we are not on channelOnline ? I'm not sure but I think something is rong her on the refacto.
$this->next = TaskName::TASK_ERROR; | ||
$this->logger->error($this->translator->trans('Error while creating directory %s.', [$dest])); | ||
$this->logger->error($this->translator->trans('Error while creating directory %s: %s.', [$dest, $e->getMessage()])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but I think something is wrong with the translation %s: %s
$this->next = TaskName::TASK_ERROR; | ||
$this->logger->error($this->translator->trans('Error while copying file %s', [$file])); | ||
$this->logger->error($this->translator->trans('Error while copying file %s: %s', [$file, $e->getMessage()])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for translation her
8c6447e
to
5af8958
Compare
5af8958
to
0f6f416
Compare
Quality Gate failedFailed conditions |
if (!$this->filesystem->exists($path)) { | ||
try { | ||
$this->filesystem->mkdir($path); | ||
} catch (IOException $e) { | ||
throw new IOException($this->translator->trans('Unable to create directory %s: %s', [$path, $e->getMessage()])); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check anymore if the directory already exists. If it does, Filesystem
will ignore the creation.
This pull request refactors the codebase to replace the usage of native PHP filesystem functions (e.g., file_exists, unlink, mkdir, etc.) with the Symfony Filesystem component. This change improves code readability, consistency, and reliability by leveraging Symfony's robust and well-tested API for filesystem operations.
Key changes include:
This refactor aligns with best practices and enhances compatibility with modern Symfony projects.