2017 © Pedro Peláez
 

symfony-bundle aviary-bundle

Symfony AvAviaryBundle

image

appventus/aviary-bundle

Symfony AvAviaryBundle

  • Friday, January 22, 2016
  • by paulandrieux
  • Repository
  • 7 Watchers
  • 4 Stars
  • 6,796 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

AviaryBundle

Description

This bundle provides multiple file uploads, based on the BlueImp jQuery file uploader package. It provides also Aviary editing image functionnalities., (*1)

Installation

Step 1

With Composer:, (*2)

Add this line in your composer.json file: "appventus/aviary-bundle" : "dev-master", (*3)

Declare the bundle in your AppKernel.php: public function registerBundles() { $bundles = array( [...] new AppVentus\AviaryBundle\AviaryBundle(), [...], (*4)

Step 2 : Entity

In your YourEntity.php, add a OneToOne Relation with a Gallery, (*5)

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

Step 3 : Form Type

In your YourEntityType.php, add the 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()) [...] ; } }, (*6)

Step 4

Add "aviary.uploadpath" parameter to your config.yml :, (*7)

parameters:
    aviary.uploadpath: /

And add "AviaryBundle:Form:fields.html.twig" to your twig.yml :, (*8)

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

Step 5 : Add styles and scripts

If You have installed our AsseticInjectorBundle bundle, add the injector tags :, (*9)

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

Step 6 : The Form !

{{ form_start(form, {'method': 'POST', 'attr' : {'id' : 'fileupload'}}) }}
{{ form_widget(form.gallery) }}
{{ form_rest(form) }}
<input type="submit" name="submit" value="Submit" />
{{ form_end(form) }}

Step 7 : Main script

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

The Versions

22/01 2016