Skip to content
Bundle to manage media in your project
ActionScript JavaScript PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Controller
DataFixtures/ORM
DependencyInjection
Doctrine/ValueTransformer
Entity
Enums
Form
MediaManagerUpload
Resources
Tests
Types
README
YllyMediaManagerBundle.php

README

MediaManagerBundle Installation Instructions

Add Repo in your project
git submodule add git@github.com:jordscream/MediaManagerBundle.git src/Ylly/MediaManagerBundle

Add Imagine lib in your project to manipulate images data
git submodule add https://github.com/avalanche123/Imagine.git vendor/imagine

Add in registering bundle:
new Ylly\MediaManagerBundle\YllyMediaManagerBundle()

Add in your autoload:
  'Ylly'                         => __DIR__.'/../src',
  'Imagine'                         =>  '/../vendor/imagine/lib',

Do the commands below to see if everything is ok....
symfony doctrine:schema:update --force (It must be add new table media)

symfony assets:install web

If you want to add data example do:
symfony doctrine:data:load

Check if the folder uploads exists in web folder

Configure the new twig configuration to have new renderer field
# Twig Configuration
twig:
    debug:            %kernel.debug%
    strict_variables: %kernel.debug%
    form:
        resources: [YllyMediaManagerBundle:Admin:fieldrenderer.html.twig]    




After that, if you want to have medias associated to your object do the modifications.
In your entity class:
class MyObject implements MediaInterface
{
    /**
     * @orm:ManyToMany(targetEntity="Ylly\MediaManagerBundle\Entity\Media")
     */
    protected $medias;	
    
    public function __construct()
    {
        $this->medias = new ArrayCollection();    	
    }

    public function getMedias()
    {
        return $this->medias;
    }    
    
    public function setMedias(ArrayCollection $medias)
    {
        $this->medias = $medias;
    }

    public function getMedia()
    {
        return isset($this->medias[0]) ? $this->medias[0] : new Media();
    }

}

symfony doctrine:schema:update --force 

In your Entity Form:
class MyObjectForm{
      .....
      $transformer = new CollectionToChoiceTransformer(array(
            'em' => $this->getOption('entity_manager'),
            'className' => 'Ylly\MediaManagerBundle\Entity\Media'
        ));

      $this->add(new MediaField('medias', array('value_transformer' => $transformer, 'crop_width' => 200, 'crop_height' => 100)));
}
Something went wrong with that request. Please try again.