-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Conversation
{ | ||
public static function process(Modx $modx, int $id) | ||
public static function process(Modx &$modx, int $id) |
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.
Ты зря добавил передачу объекта MODX по ссылке. Объекты передают ссылку на себя автоматически еще с PHP 5.3. Так что знак ссылки устаревший и не нужный.
А вот класс MODX нужно подписывать вот так modX
@@ -1,5 +1,7 @@ | |||
<?php | |||
|
|||
require MODX_CORE_PATH . 'components/minishop2/processors/mgr/gallery/removecatalogs.class.php'; |
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.
Переделай подключение класса с абсолютного, на относительный путь через dirname(FILE) (можно даже проще, без dirname, так как файлы находятся в одном каталоге)
require переделай на require_once.
@@ -0,0 +1,12 @@ | |||
<?php | |||
|
|||
class removeCatalogs |
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.
Согласно стандарту PSR-12 имя класса должно начинаться с большой буквы
@@ -45,6 +47,10 @@ public function process() | |||
return $this->success('', array('thumb' => $thumb)); | |||
} | |||
|
|||
if(!$product->getMany('Files')){ |
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.
Выражение $product->getMany('Files') возвращает массив. Проверять корректнее, через empty.
Вариант if(!$product->getMany('Files'))
тоже сработает, но это некорректное выражение. Лучше его не использовать. Рекомендую переделать
Что оно делает?
Добавил класс с двумя статическими методами для удаления пустых каталогов из-под картинок галереи товаров.
Зачем это нужно?
Чтобы мусор не оставался в файлах сайта.