src/ScContent/Listener/Back/ContentListDelete.php
public function process(EventInterface $event)
    {
        $events = $this->getEventManager();
        $mapper = $this->getMapper();
        $optionsProvider = $this->getOptionsProvider();
        $translator = $this->getTranslator();
        $pane = $event->getParam('pane');
        if (! $optionsProvider->hasIdentifier($pane)) {
            return;
        }
        $ids = $event->getParam('id');
        if (empty($ids)) {
            return;
        }
        $options = $optionsProvider->getOptions($pane);
        if ($options->getRoot() == 'site') {
            $this->error(self::DeleteFromSite);
            return $this->redirect($event);
        }
        foreach ($ids as $id) {
            try {
                $mapper->beginTransaction();
                $tid = $mapper->getTransactionIdentifier();
                $events->trigger(
                    __FUNCTION__ . '.delete.pre',
                    null,
                    [
                        'content' => $id,
                        'tid' => $tid,
                    ]
                );
                $mapper->delete($id, $tid);
                $mapper->commit();
            } catch (UnavailableSourceException $e) {
                $mapper->rollBack();
                $this->setValue($id)->error(self::SourceNotFound);
            } catch (Exception $e) {
                if (DEBUG_MODE) {
                    throw new DebugException(
                        $translator->translate('Error: ') . $e->getMessage(),
                        $e->getCode(),
                        $e
                    );
                }
                $meta = $mapper->findMetaById($id);
                $name = isset($meta['title']) ? $meta['title'] : $id;
                $this->setValue($name)->error(self::UnexpectedError);
            }
        }

        return $this->redirect($event, 'sc-admin/file/delete');
    }
public function process(EventInterface $event)
    {
        $events = $this->getEventManager();
        $mapper = $this->getMapper();
        $optionsProvider = $this->getOptionsProvider();
        $translator = $this->getTranslator();
        $pane = $event->getParam('pane');
        if (! $optionsProvider->hasIdentifier($pane)) {
            return;
        }
        $ids = $event->getParam('id');
        if (empty($ids)) {
            return;
        }
        $options = $optionsProvider->getOptions($pane);
        if ($options->getRoot() == 'site') {
            $this->error(self::DeleteFromSite);
            return $this->redirect($event);
        }
        foreach ($ids as $id) {
            try {
                $mapper->beginTransaction();
                $tid = $mapper->getTransactionIdentifier();
                $events->trigger(
                    __FUNCTION__ . '.delete.pre',
                    null,
                    [
                        'content' => $id,
                        'tid' => $tid,
                    ]
                );
                $mapper->delete($id, $tid);
                $mapper->commit();
            } catch (UnavailableSourceException $e) {
                $mapper->rollBack();
                $this->setValue($id)->error(self::SourceNotFound);
            } catch (Exception $e) {
                if (DEBUG_MODE) {
                    throw new DebugException(
                        $translator->translate('Error: ') . $e->getMessage(),
                        $e->getCode(),
                        $e
                    );
                }
                $meta = $mapper->findMetaById($id);
                $name = isset($meta['title']) ? $meta['title'] : $id;
                $this->setValue($name)->error(self::UnexpectedError);
            }
        }

        return $this->redirect($event, 'sc-admin/file/delete');
    }
public function process ( EventInterface $ event ) { $ events = $ this -> getEventManager ( ) ; $ mapper = $ this -> getMapper ( ) ; $ optionsProvider = $ this -> getOptionsProvider ( ) ; $ translator = $ this -> getTranslator ( ) ; $ pane = $ event -> getParam ( 'pane' ) ; if ( ! $ optionsProvider -> hasIdentifier ( $ pane ) ) { return ; } $ ids = $ event -> getParam ( 'id' ) ; if ( empty ( $ ids ) ) { return ; } $ options = $ optionsProvider -> getOptions ( $ pane ) ; if ( $ options -> getRoot ( ) == 'site' ) { $ this -> error ( self :: DeleteFromSite ) ; return $ this -> redirect ( $ event ) ; } foreach ( $ ids as $ id ) { try { $ mapper -> beginTransaction ( ) ; $ tid = $ mapper -> getTransactionIdentifier ( ) ; $ events -> trigger ( __FUNCTION__ . '.delete.pre' , null , [ 'content' => $ id , 'tid' => $ tid , ] ) ; $ mapper -> delete ( $ id , $ tid ) ; $ mapper -> commit ( ) ; } catch ( UnavailableSourceException $ e ) { $ mapper -> rollBack ( ) ; $ this -> setValue ( $ id ) -> error ( self :: SourceNotFound ) ; } catch ( Exception $ e ) { if ( DEBUG_MODE ) { throw new DebugException ( $ translator -> translate ( 'Error: ' ) . $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } $ meta = $ mapper -> findMetaById ( $ id ) ; $ name = isset ( $ meta [ 'title' ] ) ? $ meta [ 'title' ] : $ id ; $ this -> setValue ( $ name ) -> error ( self :: UnexpectedError ) ; } } return $ this -> redirect ( $ event , 'sc-admin/file/delete' ) ; }
To permanently delete elements from the trash

@param  \Zend\EventManager\EventInterface $event
@return null|\Zend\Http\Response
To permanently delete elements from the trash