Skip to content
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

added removal of empty directories #685

Merged
merged 8 commits into from
Jun 8, 2022
Merged

added removal of empty directories #685

merged 8 commits into from
Jun 8, 2022

Conversation

ShevArtV
Copy link
Collaborator

Что оно делает?

Добавил класс с двумя статическими методами для удаления пустых каталогов из-под картинок галереи товаров.

Зачем это нужно?

Чтобы мусор не оставался в файлах сайта.

{
public static function process(Modx $modx, int $id)
public static function process(Modx &$modx, int $id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты зря добавил передачу объекта MODX по ссылке. Объекты передают ссылку на себя автоматически еще с PHP 5.3. Так что знак ссылки устаревший и не нужный.
А вот класс MODX нужно подписывать вот так modX

@@ -1,5 +1,7 @@
<?php

require MODX_CORE_PATH . 'components/minishop2/processors/mgr/gallery/removecatalogs.class.php';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переделай подключение класса с абсолютного, на относительный путь через dirname(FILE) (можно даже проще, без dirname, так как файлы находятся в одном каталоге)
require переделай на require_once.

@@ -0,0 +1,12 @@
<?php

class removeCatalogs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласно стандарту PSR-12 имя класса должно начинаться с большой буквы

@@ -45,6 +47,10 @@ public function process()
return $this->success('', array('thumb' => $thumb));
}

if(!$product->getMany('Files')){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выражение $product->getMany('Files') возвращает массив. Проверять корректнее, через empty.
Вариант if(!$product->getMany('Files')) тоже сработает, но это некорректное выражение. Лучше его не использовать. Рекомендую переделать

@biz87 biz87 self-requested a review June 8, 2022 17:49
@biz87 biz87 merged commit 08c89e4 into modx-pro:master Jun 8, 2022
@biz87 biz87 mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants