protected function cleanupAction()
    {
        $days = 2;
        $date = new \DateTime();
        $date->modify("-$days day");

        $filter = array("before" => $date->format("Y-m-d"),
                        "isDraft" => 1);
        
        $applications    = $this->fetchApplications($filter);
        $documentManager = $this->documentManager;

        $count = count($applications);
        $i=0;

        echo  $count . " applications in Draft Mode and older than " . $days . " days will be deleted\n";

        $progress = new ProgressBar($count);

        foreach ($applications as $application) {
            $progress->update($i++, 'Application ' . $i . ' / ' . $count);
            try {
                $documentManager->remove($application);
            } catch (\Exception $e) {
                // log something
                $e->getCode();
            }
        }
        $progress->update($i, 'clean up database');
        $documentManager->flush();
        $progress->finish();
    }
protected function cleanupAction()
    {
        $days = 2;
        $date = new \DateTime();
        $date->modify("-$days day");

        $filter = array("before" => $date->format("Y-m-d"),
                        "isDraft" => 1);
        
        $applications    = $this->fetchApplications($filter);
        $documentManager = $this->documentManager;

        $count = count($applications);
        $i=0;

        echo  $count . " applications in Draft Mode and older than " . $days . " days will be deleted\n";

        $progress = new ProgressBar($count);

        foreach ($applications as $application) {
            $progress->update($i++, 'Application ' . $i . ' / ' . $count);
            try {
                $documentManager->remove($application);
            } catch (\Exception $e) {
                // log something
                $e->getCode();
            }
        }
        $progress->update($i, 'clean up database');
        $documentManager->flush();
        $progress->finish();
    }
protected function cleanupAction ( ) { $ days = 2 ; $ date = new \ DateTime ( ) ; $ date -> modify ( "-$days day" ) ; $ filter = array ( "before" => $ date -> format ( "Y-m-d" ) , "isDraft" => 1 ) ; $ applications = $ this -> fetchApplications ( $ filter ) ; $ documentManager = $ this -> documentManager ; $ count = count ( $ applications ) ; $ i = 0 ; echo $ count . " applications in Draft Mode and older than " . $ days . " days will be deleted\n" ; $ progress = new ProgressBar ( $ count ) ; foreach ( $ applications as $ application ) { $ progress -> update ( $ i ++ , 'Application ' . $ i . ' / ' . $ count ) ; try { $ documentManager -> remove ( $ application ) ; } catch ( \ Exception $ e ) { // log something $ e -> getCode ( ) ; } } $ progress -> update ( $ i , 'clean up database' ) ; $ documentManager -> flush ( ) ; $ progress -> finish ( ) ; }
removes unfinished applications. Applications, which are in Draft Mode for
more than 24 hours.
removes unfinished applications . Applications which are in Draft Mode for more than 24 hours .