public function process()
    {
        $remainingChildren = $this->remainingChildren;

        // if there's no more, we're done!
        if (!count($remainingChildren)) {
            $this->isComplete = true;
            $this->handleCompletion();
            return;
        }

        $class = $this->dataClass;
        $ID = array_shift($remainingChildren);

        $record = null;

        if (class_exists('Subsite')) {
            $records = Subsite::get_from_all_subsites($class, ['ID' => $ID]);
            if ($records && $records->exists()) {
                $record = $records->First();
            }
        } else {
            $record = $class::get()->byID($ID);
        }

        if (!$record || !$record->exists()) {
            $message = sprintf('%s ID %s not found!', $class, $ID);
            $this->addMessage($message, 'WARNING');
            Injector::inst()->get(LoggerInterface::class)->warning($message);
        } else {
            $created = $record->dbObject('Created')->Nice();
            $record->delete();
            $this->addMessage(sprintf('Deleted %s ID %s (%s)', $class, $ID, $created), 'WARNING');
        }

        // Update counter
        $this->currentStep++;
        $this->remainingChildren = $remainingChildren;
    }
public function process()
    {
        $remainingChildren = $this->remainingChildren;

        // if there's no more, we're done!
        if (!count($remainingChildren)) {
            $this->isComplete = true;
            $this->handleCompletion();
            return;
        }

        $class = $this->dataClass;
        $ID = array_shift($remainingChildren);

        $record = null;

        if (class_exists('Subsite')) {
            $records = Subsite::get_from_all_subsites($class, ['ID' => $ID]);
            if ($records && $records->exists()) {
                $record = $records->First();
            }
        } else {
            $record = $class::get()->byID($ID);
        }

        if (!$record || !$record->exists()) {
            $message = sprintf('%s ID %s not found!', $class, $ID);
            $this->addMessage($message, 'WARNING');
            Injector::inst()->get(LoggerInterface::class)->warning($message);
        } else {
            $created = $record->dbObject('Created')->Nice();
            $record->delete();
            $this->addMessage(sprintf('Deleted %s ID %s (%s)', $class, $ID, $created), 'WARNING');
        }

        // Update counter
        $this->currentStep++;
        $this->remainingChildren = $remainingChildren;
    }
public function process ( ) { $ remainingChildren = $ this -> remainingChildren ; // if there's no more, we're done! if ( ! count ( $ remainingChildren ) ) { $ this -> isComplete = true ; $ this -> handleCompletion ( ) ; return ; } $ class = $ this -> dataClass ; $ ID = array_shift ( $ remainingChildren ) ; $ record = null ; if ( class_exists ( 'Subsite' ) ) { $ records = Subsite :: get_from_all_subsites ( $ class , [ 'ID' => $ ID ] ) ; if ( $ records && $ records -> exists ( ) ) { $ record = $ records -> First ( ) ; } } else { $ record = $ class :: get ( ) -> byID ( $ ID ) ; } if ( ! $ record || ! $ record -> exists ( ) ) { $ message = sprintf ( '%s ID %s not found!' , $ class , $ ID ) ; $ this -> addMessage ( $ message , 'WARNING' ) ; Injector :: inst ( ) -> get ( LoggerInterface :: class ) -> warning ( $ message ) ; } else { $ created = $ record -> dbObject ( 'Created' ) -> Nice ( ) ; $ record -> delete ( ) ; $ this -> addMessage ( sprintf ( 'Deleted %s ID %s (%s)' , $ class , $ ID , $ created ) , 'WARNING' ) ; } // Update counter $ this -> currentStep ++ ; $ this -> remainingChildren = $ remainingChildren ; }
Lets process one ID at the time
Lets process one ID at the time