protected function deleteAll()
    {
        $elements = $this->Request->getRequiredParameter('elements');

        $interval = 1000;

        $elementSlugs = StringUtils::smartExplode($elements);
        $elements = array();
        foreach($elementSlugs as $eSlug)
            $elements[] = $this->ElementService->getBySlug($eSlug);

        foreach($elements as $element)
        {
            $offset = 0;

            if($this->Request->getParameter('offset') != null)
                $offset = $this->Request->getParameter('offset');

            echo 'Deleting nodes for element: '.$element."\n";

            while(true)
            {
                $count = 0;

                // commit any pending transactions and begin new one
                $this->TransactionManager->commit()->begin();

                $nq = new NodeQuery();
                $nq->setParameter('NodeRefs.only', true);
                $nq->setParameter('Elements.in', $element->getSlug());
                $nq->setLimit($interval);
                $nq->setOffset($offset);

                $nq = $this->NodeService->findAll($nq, true);
                $nodeRefs = $nq->getResults();
                $tCount = $nq->getTotalRecords();

                if(empty($nodeRefs))
                    break;

                foreach($nodeRefs as $nodeRef)
                {
                    try {
                        $this->NodeService->delete($nodeRef);
                        echo ($count+1).". ".$nodeRef->getSlug()." deleted\n";
                        if(($count+1) % 10 == 0) {
                            $this->TransactionManager->commit()->begin();
                            echo "commit\n";
                        }
                    } catch(Exception $e) {
                        echo "Exception caught: ".$e->getMessage()."\n";
                        // if an error occurs, bail - we don't want to get stuck in a
                        // loop if we can't delete stuff for some reason
                        echo "Exiting, please correct problem and re-run\n";
                        return;
                    }

                    ++$count;
                }

                echo 'Deleted '.$count.' of '.$tCount.' '.$element->getSlug()." nodes.\n";
            }
        }
    }
protected function deleteAll()
    {
        $elements = $this->Request->getRequiredParameter('elements');

        $interval = 1000;

        $elementSlugs = StringUtils::smartExplode($elements);
        $elements = array();
        foreach($elementSlugs as $eSlug)
            $elements[] = $this->ElementService->getBySlug($eSlug);

        foreach($elements as $element)
        {
            $offset = 0;

            if($this->Request->getParameter('offset') != null)
                $offset = $this->Request->getParameter('offset');

            echo 'Deleting nodes for element: '.$element."\n";

            while(true)
            {
                $count = 0;

                // commit any pending transactions and begin new one
                $this->TransactionManager->commit()->begin();

                $nq = new NodeQuery();
                $nq->setParameter('NodeRefs.only', true);
                $nq->setParameter('Elements.in', $element->getSlug());
                $nq->setLimit($interval);
                $nq->setOffset($offset);

                $nq = $this->NodeService->findAll($nq, true);
                $nodeRefs = $nq->getResults();
                $tCount = $nq->getTotalRecords();

                if(empty($nodeRefs))
                    break;

                foreach($nodeRefs as $nodeRef)
                {
                    try {
                        $this->NodeService->delete($nodeRef);
                        echo ($count+1).". ".$nodeRef->getSlug()." deleted\n";
                        if(($count+1) % 10 == 0) {
                            $this->TransactionManager->commit()->begin();
                            echo "commit\n";
                        }
                    } catch(Exception $e) {
                        echo "Exception caught: ".$e->getMessage()."\n";
                        // if an error occurs, bail - we don't want to get stuck in a
                        // loop if we can't delete stuff for some reason
                        echo "Exiting, please correct problem and re-run\n";
                        return;
                    }

                    ++$count;
                }

                echo 'Deleted '.$count.' of '.$tCount.' '.$element->getSlug()." nodes.\n";
            }
        }
    }
protected function deleteAll ( ) { $ elements = $ this -> Request -> getRequiredParameter ( 'elements' ) ; $ interval = 1000 ; $ elementSlugs = StringUtils :: smartExplode ( $ elements ) ; $ elements = array ( ) ; foreach ( $ elementSlugs as $ eSlug ) $ elements [ ] = $ this -> ElementService -> getBySlug ( $ eSlug ) ; foreach ( $ elements as $ element ) { $ offset = 0 ; if ( $ this -> Request -> getParameter ( 'offset' ) != null ) $ offset = $ this -> Request -> getParameter ( 'offset' ) ; echo 'Deleting nodes for element: ' . $ element . "\n" ; while ( true ) { $ count = 0 ; // commit any pending transactions and begin new one $ this -> TransactionManager -> commit ( ) -> begin ( ) ; $ nq = new NodeQuery ( ) ; $ nq -> setParameter ( 'NodeRefs.only' , true ) ; $ nq -> setParameter ( 'Elements.in' , $ element -> getSlug ( ) ) ; $ nq -> setLimit ( $ interval ) ; $ nq -> setOffset ( $ offset ) ; $ nq = $ this -> NodeService -> findAll ( $ nq , true ) ; $ nodeRefs = $ nq -> getResults ( ) ; $ tCount = $ nq -> getTotalRecords ( ) ; if ( empty ( $ nodeRefs ) ) break ; foreach ( $ nodeRefs as $ nodeRef ) { try { $ this -> NodeService -> delete ( $ nodeRef ) ; echo ( $ count + 1 ) . ". " . $ nodeRef -> getSlug ( ) . " deleted\n" ; if ( ( $ count + 1 ) % 10 == 0 ) { $ this -> TransactionManager -> commit ( ) -> begin ( ) ; echo "commit\n" ; } } catch ( Exception $ e ) { echo "Exception caught: " . $ e -> getMessage ( ) . "\n" ; // if an error occurs, bail - we don't want to get stuck in a // loop if we can't delete stuff for some reason echo "Exiting, please correct problem and re-run\n" ; return ; } ++ $ count ; } echo 'Deleted ' . $ count . ' of ' . $ tCount . ' ' . $ element -> getSlug ( ) . " nodes.\n" ; } } }
Deletes all nodes for specified elements.

@param elements A comma delimited list of the elements to delete nodes in
@param offset An integer value for the offset to begin deleting nodes from

@return void
Deletes all nodes for specified elements .