public function cleanupNodesWithIds($ids)
    {
        $ids = array_merge($this->getRelatedNodeIds($ids), $ids);

        if (!empty($ids)) {
            $repositories = $this->getNodeRepositories($ids);

            //delete all the nodes
            $this->getService('repos:base.node')->destroy($ids);

            //set the creator,updator,authors to null
            $in = '('.implode(',', $ids).')';
            $query[] = "last_comment_id = IF(last_comment_id IN $in, NULL, last_comment_id)";
            $query[] = "created_by = IF(created_by IN $in, NULL, created_by)";
            $query[] = "modified_by = IF(modified_by IN $in, NULL, modified_by)";
            $query[] = "last_comment_by = IF(last_comment_by IN $in, NULL, last_comment_by)";
            $query = implode(', ', $query);
            $where = $this->getService('repos:base.node')
                        ->getQuery()
                        ->where("last_comment_by IN $in OR created_by IN $in OR modified_by IN $in OR last_comment_by IN $in");

            $this->getService('repos:base.node')->update($query, $where);

            //cleanup all the relationship of every deleted node
            $query = $this->getService('repos:base.edge')
                ->getQuery()
                ->where('nodeA.id', 'IN', $ids)
                ->where('nodeB.id', 'IN', $ids, 'OR');

            $this->getService('repos:base.edge')->destroy($query);

            //now lets the repositories know so they can
            //handle the cleanup
            foreach ($repositories as $repository) {
                $context = $repository->getCommandContext();
                $context->node_ids = $ids;
                $repository->getCommandChain()->run('after.deletenodes', $context);
            }
        }
    }
public function cleanupNodesWithIds($ids)
    {
        $ids = array_merge($this->getRelatedNodeIds($ids), $ids);

        if (!empty($ids)) {
            $repositories = $this->getNodeRepositories($ids);

            //delete all the nodes
            $this->getService('repos:base.node')->destroy($ids);

            //set the creator,updator,authors to null
            $in = '('.implode(',', $ids).')';
            $query[] = "last_comment_id = IF(last_comment_id IN $in, NULL, last_comment_id)";
            $query[] = "created_by = IF(created_by IN $in, NULL, created_by)";
            $query[] = "modified_by = IF(modified_by IN $in, NULL, modified_by)";
            $query[] = "last_comment_by = IF(last_comment_by IN $in, NULL, last_comment_by)";
            $query = implode(', ', $query);
            $where = $this->getService('repos:base.node')
                        ->getQuery()
                        ->where("last_comment_by IN $in OR created_by IN $in OR modified_by IN $in OR last_comment_by IN $in");

            $this->getService('repos:base.node')->update($query, $where);

            //cleanup all the relationship of every deleted node
            $query = $this->getService('repos:base.edge')
                ->getQuery()
                ->where('nodeA.id', 'IN', $ids)
                ->where('nodeB.id', 'IN', $ids, 'OR');

            $this->getService('repos:base.edge')->destroy($query);

            //now lets the repositories know so they can
            //handle the cleanup
            foreach ($repositories as $repository) {
                $context = $repository->getCommandContext();
                $context->node_ids = $ids;
                $repository->getCommandChain()->run('after.deletenodes', $context);
            }
        }
    }
public function cleanupNodesWithIds ( $ ids ) { $ ids = array_merge ( $ this -> getRelatedNodeIds ( $ ids ) , $ ids ) ; if ( ! empty ( $ ids ) ) { $ repositories = $ this -> getNodeRepositories ( $ ids ) ; //delete all the nodes $ this -> getService ( 'repos:base.node' ) -> destroy ( $ ids ) ; //set the creator,updator,authors to null $ in = '(' . implode ( ',' , $ ids ) . ')' ; $ query [ ] = "last_comment_id = IF(last_comment_id IN $in, NULL, last_comment_id)" ; $ query [ ] = "created_by = IF(created_by IN $in, NULL, created_by)" ; $ query [ ] = "modified_by = IF(modified_by IN $in, NULL, modified_by)" ; $ query [ ] = "last_comment_by = IF(last_comment_by IN $in, NULL, last_comment_by)" ; $ query = implode ( ', ' , $ query ) ; $ where = $ this -> getService ( 'repos:base.node' ) -> getQuery ( ) -> where ( "last_comment_by IN $in OR created_by IN $in OR modified_by IN $in OR last_comment_by IN $in" ) ; $ this -> getService ( 'repos:base.node' ) -> update ( $ query , $ where ) ; //cleanup all the relationship of every deleted node $ query = $ this -> getService ( 'repos:base.edge' ) -> getQuery ( ) -> where ( 'nodeA.id' , 'IN' , $ ids ) -> where ( 'nodeB.id' , 'IN' , $ ids , 'OR' ) ; $ this -> getService ( 'repos:base.edge' ) -> destroy ( $ query ) ; //now lets the repositories know so they can //handle the cleanup foreach ( $ repositories as $ repository ) { $ context = $ repository -> getCommandContext ( ) ; $ context -> node_ids = $ ids ; $ repository -> getCommandChain ( ) -> run ( 'after.deletenodes' , $ context ) ; } } }
Clean up node, edge table for the deleted nodes with passed ids.

@param array $ids Deleted node ids
Clean up node edge table for the deleted nodes with passed ids .