protected function _cleaner($parentId, $preservedItems = [])
    {
        $nodes = $this->Aco->find()->where(['parent_id' => $parentId]);
        $methodFlip = array_flip($preservedItems);
        foreach ($nodes as $node) {
            if (!isset($methodFlip[$node->alias])) {
                $crumbs = $this->Aco->find('path', ['for' => $node->id, 'order' => 'lft']);
                $path = null;
                foreach ($crumbs as $crumb) {
                    $path .= '/' . $crumb->alias;
                }
                $entity = $this->Aco->get($node->id);
                if ($this->Aco->delete($entity)) {
                    $this->out(__d('cake_acl', 'Deleted ACO node: <warning>{0}</warning> and all children', $path));
                }
            }
        }
    }
protected function _cleaner($parentId, $preservedItems = [])
    {
        $nodes = $this->Aco->find()->where(['parent_id' => $parentId]);
        $methodFlip = array_flip($preservedItems);
        foreach ($nodes as $node) {
            if (!isset($methodFlip[$node->alias])) {
                $crumbs = $this->Aco->find('path', ['for' => $node->id, 'order' => 'lft']);
                $path = null;
                foreach ($crumbs as $crumb) {
                    $path .= '/' . $crumb->alias;
                }
                $entity = $this->Aco->get($node->id);
                if ($this->Aco->delete($entity)) {
                    $this->out(__d('cake_acl', 'Deleted ACO node: <warning>{0}</warning> and all children', $path));
                }
            }
        }
    }
protected function _cleaner ( $ parentId , $ preservedItems = [ ] ) { $ nodes = $ this -> Aco -> find ( ) -> where ( [ 'parent_id' => $ parentId ] ) ; $ methodFlip = array_flip ( $ preservedItems ) ; foreach ( $ nodes as $ node ) { if ( ! isset ( $ methodFlip [ $ node -> alias ] ) ) { $ crumbs = $ this -> Aco -> find ( 'path' , [ 'for' => $ node -> id , 'order' => 'lft' ] ) ; $ path = null ; foreach ( $ crumbs as $ crumb ) { $ path .= '/' . $ crumb -> alias ; } $ entity = $ this -> Aco -> get ( $ node -> id ) ; if ( $ this -> Aco -> delete ( $ entity ) ) { $ this -> out ( __d ( 'cake_acl' , 'Deleted ACO node: <warning>{0}</warning> and all children' , $ path ) ) ; } } } }
Delete unused ACOs.

@param int $parentId Id of the parent node.
@param array $preservedItems list of items that will not be erased.
@return void
Delete unused ACOs .