public function execute()
    {
        $result = $this->resultJson->create();
        try {
            $read = $this->filesystem->getDirectoryRead(DirectoryList::VAR_DIR);
            $snippetPath = $read->getRelativePath('vcl_snippets_custom');

            $customSnippets = $read->read($snippetPath);

            if (!$customSnippets) {
                return $result->setData([
                    'status'    => false,
                    'msg'       => 'No snippets found.'
                ]);
            }
            $snippets = [];
            foreach ($customSnippets as $snippet) {
                $snippets[] = explode('/', $snippet)[1];
            }

            return $result->setData([
                'status'    => true,
                'snippets'  => $snippets
            ]);
        } catch (\Exception $e) {
            return $result->setData([
                'status'    => false,
                'msg'       => $e->getMessage()
            ]);
        }
    }
public function execute()
    {
        $result = $this->resultJson->create();
        try {
            $read = $this->filesystem->getDirectoryRead(DirectoryList::VAR_DIR);
            $snippetPath = $read->getRelativePath('vcl_snippets_custom');

            $customSnippets = $read->read($snippetPath);

            if (!$customSnippets) {
                return $result->setData([
                    'status'    => false,
                    'msg'       => 'No snippets found.'
                ]);
            }
            $snippets = [];
            foreach ($customSnippets as $snippet) {
                $snippets[] = explode('/', $snippet)[1];
            }

            return $result->setData([
                'status'    => true,
                'snippets'  => $snippets
            ]);
        } catch (\Exception $e) {
            return $result->setData([
                'status'    => false,
                'msg'       => $e->getMessage()
            ]);
        }
    }
public function execute ( ) { $ result = $ this -> resultJson -> create ( ) ; try { $ read = $ this -> filesystem -> getDirectoryRead ( DirectoryList :: VAR_DIR ) ; $ snippetPath = $ read -> getRelativePath ( 'vcl_snippets_custom' ) ; $ customSnippets = $ read -> read ( $ snippetPath ) ; if ( ! $ customSnippets ) { return $ result -> setData ( [ 'status' => false , 'msg' => 'No snippets found.' ] ) ; } $ snippets = [ ] ; foreach ( $ customSnippets as $ snippet ) { $ snippets [ ] = explode ( '/' , $ snippet ) [ 1 ] ; } return $ result -> setData ( [ 'status' => true , 'snippets' => $ snippets ] ) ; } catch ( \ Exception $ e ) { return $ result -> setData ( [ 'status' => false , 'msg' => $ e -> getMessage ( ) ] ) ; } }
Get custom snippets

@return $this|\Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface
Get custom snippets