appventus/aviary-bundle

此包已被废弃,不再维护。没有建议的替代包。

Symfony AvAviaryBundle

安装数: 7,363

依赖者: 0

建议者: 0

安全: 0

星标: 4

关注者: 8

分支: 2

开放问题: 1

语言:HTML

类型:symfony-bundle

dev-master 2016-01-22 13:02 UTC

This package is not auto-updated.

Last update: 2023-08-05 10:29:58 UTC


README

##描述

此包提供基于BlueImp jQuery文件上传包的多个文件上传功能。同时提供Aviary编辑图像功能。

##安装

###步骤 1

使用Composer

在您的composer.json文件中添加此行:"appventus/aviary-bundle" : "dev-master"

在您的AppKernel.php中声明此包:public function registerBundles() { $bundles = array( [...] new AppVentus\AviaryBundle\AviaryBundle(), [...] }

###步骤 2 : 实体

在您的YourEntity.php中,添加与Gallery的一对一关系

/**
 * @ORM\OneToOne(targetEntity="Appventus\AviaryBundle\Entity\Gallery", cascade={"persist"})
 */
private $gallery;

/**
 * Set gallery
 *
 * @param \Appventus\AviaryBundle\Entity\Gallery $gallery
 * @return Product
 */
public function setGallery(\Appventus\AviaryBundle\Entity\Gallery $gallery = null)
{
    $this->gallery = $gallery;

    return $this;
}

/**
 * Get gallery
 *
 * @return \Appventus\AviaryBundle\Entity\Gallery 
 */
public function getGallery()
{
    return $this->gallery;
}

###步骤 3 : 表单类型

在您的YourEntityType.php中,添加GalleryType use Appventus\AviaryBundle\Form\GalleryType; class YourEntityType extends AbstractType { /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder [...] ->add('gallery', new GalleryType()) [...] ; } }

###步骤 4

将"aviary.uploadpath"参数添加到您的config.yml

parameters:
    aviary.uploadpath: /

并将"AviaryBundle:Form:fields.html.twig"添加到您的twig.yml

twig:
    form:
        resources:
            - 'AviaryBundle:Form:fields.html.twig'

###步骤 5 : 添加样式和脚本

如果您已安装我们的AsseticInjectorBundle包,请添加injector标签

  • javascripts (injector="aviary_scripts")
  • stylesheets (injector="aviary_styles")

###步骤 6 : 表单 ! {{ form_start(form, {'method': 'POST', 'attr' : {'id' : 'fileupload'}}) }} {{ form_widget(form.gallery) }} {{ form_rest(form) }} {{ form_end(form) }}

###步骤 7 : 主要脚本

var featherEditor = new Aviary.Feather({
    apiKey: 'yourapikey',
    apiVersion: 3,
    theme: 'dark',
    appendTo: '',
    language: 'fr',
    onSave: function(imageID, newURL) {
        postImage(imageID, newURL);
        featherEditor.close();
        return false;
    },
    onError: function(errorObj) {
        alert(errorObj.message);
    }
});