Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • CliController
  • CorrectBadFoldersTask
  • DailyTask
  • DeleteEmptyAssociatedFoldersTask
  • FillTechTitleTask
  • FindCyrillic
  • HourlyTask
  • MonthlyTask
  • PostVKNotificationQueueTask
  • QuarterHourlyTask
  • RealtyXMLImportTask
  • ScheduledTask
  • WeeklyTask
  • YearlyTask
 1 <?php
 2 // Задача удаления пустых папок товаров и пустых корневых хеш-папок (в page-files)
 3 class DeleteEmptyAssociatedFoldersTask extends ScheduledTask {
 4     function process() {
 5         $deletedProductFolders = 0;
 6         $deletedHashFolders = 0;
 7         $rootFolder = AssociatedFolderDecorator::getDefaultRootFolderName();
 8         if ($folder = DataObject::get_one('Folder', "Name = '{$rootFolder}' AND ParentID = 0")) {
 9             if ($children = $folder->AllChildren()) {
10                 foreach($children as $hashFolder) {
11                     if ($hashChildren = $hashFolder->AllChildren()) {                       
12                         foreach($hashChildren as $childFolder) {
13                             if (!$childFolder->AllChildren()->Count() && ($childFolder->ClassName == 'Folder')) {
14                                 echo "{$childFolder->getFullPath()} \n";
15                                 if ($product = DataObject::get_one('Product', "AssociatedFolderID = {$childFolder->ID}")) {
16                                     $product->AssociatedFolderID = 0;
17                                     $product->writeToStage('Stage');
18                                     if ($product->isPublished()) {
19                                         $product->publish('Stage', 'Live');
20                                     }
21                                 }
22                                 $childFolder->delete();
23                                 $deletedProductFolders++;
24                             }
25                         }
26                     }
27                     
28                     if (!$hashFolder->AllChildren()->Count() && ($hashFolder->ClassName == 'Folder')) {
29                         echo "-----{$hashFolder->getFullPath()} \n";
30                         $hashFolder->delete();
31                         $deletedHashFolders++;
32                     }
33                 }
34             }
35         }
36         echo "Удалено {$deletedHashFolders} hash-папок и {$deletedProductFolders} папок товаров";
37         return;
38     }
39 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0