digitalkaoz/gaufrette-browser-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digitalkaoz/gaufrette-browser-bundle

Composer 安装命令:

composer require digitalkaoz/gaufrette-browser-bundle

包简介

This bundle provides an integration of the KnpMenu library

README 文档

README

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

统计信息

  • 总下载量: 269
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-04-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固