PHP code example of digitalkaoz / gaufrette-browser-bundle

1. Go to this page and download the library: Download digitalkaoz/gaufrette-browser-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digitalkaoz / gaufrette-browser-bundle example snippets

 php
// application/AppKernel.php
public function registerBundles()
{
  return array(
      // ...
      new rs\GaufretteBrowserBundle\rsGaufretteBrowserBundle(),
      // ...
  );
}
 php
$this->get('rs_gaufrette_browser.repository.directory')->findBy(array('prefix'=>'/foo')); #only search folders that starts with /foo
$this->get('rs_gaufrette_browser.repository.file')->findBy(array('suffix'=>'/\.xls/')); #only search .xls files
$this->get('rs_gaufrette_browser.repository.file')->find('/foo/bar.png'); #find one file
$this->get('rs_gaufrette_browser.repository.file')->findOneBy(array('prefix'=>'/foo', 'suffix' => '/\.xls/')); #find one file named /foo/*.xls
 php
/**
 * @ParamConverter("folder", class="rs\GaufretteBrowserBundle\Entity\Directory", options={"id" = "slug"})
 */
public function myCustomDirectoryAction(Request $request, Directory $folder){}

/**
 * @ParamConverter("file", class="rs\GaufretteBrowserBundle\Entity\File", options={"id" = "slug"})
 */
public function myCustomFileAction(Request $request, File $file){}
 php
class MyEventSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return array(
            GaufretteBrowserEvents::DIRECTORY_INDEX => 'myCustomAction'
        );
    }

    public function myCustomAction(DirectoryControllerEvent $event)
    {
        $event->addDirectory($myCustomDirectory);
        $event->removeDirectory($unwantedDirectory);

        $event->addTemplateData('myCustomVar', 'foobar');
    }
}