Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Gaufrette Browser Bundle Laravel Package

digitalkaoz/gaufrette-browser-bundle

View on GitHub
Deep Wiki
Context7

Gaufrette Browser

Build Status Total Downloads Latest Stable Version Code Coverage Scrutinizer Quality Score SensioLabsInsight

This Bundle allows you to browse a Gaufrette Filesystem like a Doctrine Connection. It tries to wrap Doctrine ObjectRepositories and Entities around Gaufrette Files.

Installation

Install it with Composer

{
    "require" : {
        "digitalkaoz/gaufrette-browser-bundle" : "dev-master@dev"
    }
}

Active the Bundle in your Kernel

// application/AppKernel.php
public function registerBundles()
{
  return array(
      // ...
      new rs\GaufretteBrowserBundle\rsGaufretteBrowserBundle(),
      // ...
  );
}

Import the Routing

rs_gaufrette_browser:
    resource: "@rsGaufretteBrowserBundle/Resources/config/routing.xml"
    prefix:   /gaufrette/browser

Configuration

Create a Gaufrette Filesystem (see https://github.com/KnpLabs/KnpGaufretteBundle for more Installation and Configuration)

knp_gaufrette:
    adapters:
        default:
            local:
                directory: /your/path/
    filesystems:
        default:
            adapter:    default
            alias:      default_filesystem

    stream_wrapper: ~

Connect the Browser to the Filesystem

rs_gaufrette_browser:
    filesystem: default_filesystem #the gaufrette filesystem alias to use

The Full Config Reference

rs_gaufrette_browser:
    file_pattern:    "/\.(jpg|gif|jpeg|png)$/"    # a valid regular expression to filter for file-extensions
    filesystem:      default_filesystem           # the gaufrette filesystem alias to use
    file_class:      Your\File\Class              # should extend rs\GaufretteBrowserBundle\Entity\File
    directory_class: Your\Directory\Class         # should extend rs\GaufretteBrowserBundle\Entity\Directory

Usage

Goto http://your.domain/gaufrette/browser and browse the filesystem

Querying for Directories or Files

Using the Repository Implementations:

$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

Using the ParamConverters

Using ParamConverters for Directory and File is quiet simple:

/**
 * @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){}

Hooking into Events

Everything inside the Controller-Actions is build up with Events.

The following Events exists

final class GaufretteBrowserEvents
{
    const DIRECTORY_SHOW = 'gaufrette.directory.show';
    const DIRECTORY_INDEX = 'gaufrette.directory.index';

    const FILE_SHOW = 'gaufrette.file.show';
    const FILE_INDEX = 'gaufrette.file.index';
}

Hook your own Functionality into default Controllers

implement the Subscriber

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');
    }
}

and TAG the Service

<service id="my.custom.event_subscriber" class="\MyEventSubscriber">
    <tag name="kernel.event_subscriber" />
</service>

Tests

everything is well unit tested:

phpunit

view builds on Travis: https://travis-ci.org/digitalkaoz/GaufretteBrowserBundle

TODO

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware