Code Monkey home page Code Monkey logo

vlabsmediabundle's Introduction

VlabsMediaBundle Build Status

Form, database and filesystem abstraction for files

Features :

  • Form upload process abstraction
  • Database persistence abstration
  • Dynamic resize with cache
  • Media templates
  • Stand alone handler as service for filesystem operations

Documentation

To do

  • Ajax upload form type
  • Real namer tool
  • Full abstraction of file deletion

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE

vlabsmediabundle's People

Contributors

choomz avatar gregsparrow avatar jcrombez avatar jekill avatar lenybernard avatar maximivanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vlabsmediabundle's Issues

Event exception

Hi,

This problem has already been discussed but not solved...

Catchable Fatal Error: Argument 1 passed to Vlabs\MediaBundle\EventListener\BaseFileListener::preSetData() must be an instance of Symfony\Component\Form\Event\DataEvent, instance of Symfony\Component\Form\FormEvent given in /home/fred/NetBeansProjects/brehat-4/vendor/vlabs/media-bundle/Vlabs/MediaBundle/EventListener/BaseFileListener.php line 59

My config : symfony 2.3 vlabs media bundle 1.1.1

createdAt property in abstract class

I saw that you set a property createdAt in the class BaseFile.
This property is not related to the media themselves.

I think you should let the developers decide whether they need or not such a property.
If they need it, let them implement it in their entity.

Documentation order problem

You can't update your doctrine schema before the configuration step, or you get the following error :

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
The child node "mapping" at path "vlabs_media" must be configured.

The documentation should be reordered.

Argument 1 passed to Vlabs\MediaBundle\EventListener\BaseFileListener::preSetData()

Hi,

I think this a bug related to this issue :
#24

But i still have the same problem !
I'm under symfony 2.3.13, and tried with media bundle 1.1 and 1.1.1

Her is the error :

ContextErrorException: Catchable Fatal Error: Argument 1 passed to Vlabs\MediaBundle\EventListener\BaseFileListener::preSetData() must be an instance of
 Symfony\Component\Form\Event\DataEvent, 
instance of Symfony\Component\Form\FormEvent given in /path/to/site/vendor/vlabs/media-bundle/Vlabs/MediaBundle/EventListener/BaseFileListener.php line 59

I've tried to
set public function preSetData(FormEvent $event)
instead of
public function preSetData(DataEvent $event)

and get this error

ContextErrorException: Catchable Fatal Error: Argument 1 passed to Vlabs\MediaBundle\EventListener\BaseFileListener::preSetData() must be an instance of
 Vlabs\MediaBundle\EventListener\FormEvent, 
instance of Symfony\Component\Form\FormEvent given in /path/to/site/vendor/vlabs/media-bundle/Vlabs/MediaBundle/EventListener/BaseFileListener.php line 59

Any help is welcom.
Thank you

File object instead of String

Hi,

I have just installed this bundle. I have created an Image entity and linked it to another entity.
Then I have created my form and successfully uploaded an image.
But when I want to edit my entity, I have the following error :
The form's view data is expected to be an instance of class Symfony\Component HttpFoundation\File\File, but is a(n) string. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms a(n) string to an instance of Symfony\Component\HttpFoundation\File\File.

It seems that your data transformer return a string, but Symfony does not accept it and prefer a File object.
Do you know how to resolve this error?

Cant install with composer

knplabs gaufrette has been changed - and dev-master has new requirements.

So could you please update your composer and let it use
"knplabs/knp-gaufrette-bundle": "0.1.*"
instead

question about MediaBundle

Hello, first I want to congratulate you for this excellent bundle. I would like to ask you a simple question about MediaBundle, basically how to validate that only can be uploaded files of an specific mime/type and with a maximum size. Since none of the attributes in the used entities has the file type, where I can put this kind of validation or constraints.

Add ability to disable file preview

Hi, I would like to add ability to disable preview when I edit an entity. It could be an option of "vlabs_file" field type.
In my current project I had to custom the "Browse" button and the image preview add after button in the default view make it complicated.

Any suggestion ?

update to symfony3

because of the requirement for knplabs/knp-gaufrette-bundle v0.1.7 it's impossible to update to symfony 3 with this bundle.

If we can update the requirement to knplabs/knp-gaufrette-bundle ^0.3.0 it should work

Issue with an ArrayCollection

Hello

Thinks for your bundle ;)

I test it yesterday and i would like to know if it's possible to use it with an ArrayCollection with prototype ?

Can I use another Document class?

Hi.

I have defined my own document classes, f.e. ImageFile, PdfFile - they extend AbstractFile class. How can I use my own classes in User document (it has inside such definition:
@odm\ReferenceOne(targetDocument="MyOwnBundle\Document\File\AbstractFile") protected $avatar;

Regards, Marek

upload is not remembered, image is on form error

Hey,

When I upload an image in a standard symfony form with this bundle, and I have a validation error on any field, after reload it shows the image, but you need to re-upload the image.

Behavior should be that if the image was correctly uploaded it should persist, even if other fields throw validation errors and upon solving those validation errors the form should save normally, WITH image.

Not possible to add images directly

Its not possible to add images without a form.
Fx via fixtures

[ErrorException]
Notice: Undefined variable: classConfig in vendor/vlabs/media-bundle/Vlabs/MediaBundle/Handler/HandlerManager.php line 84

Do you have any fixes for this?

Im using this code in my fixture

use Symfony\Component\Finder\Finder;

$finder = new Finder;
$finder->files()->in($path);
foreach($finder as $file) {
   $img = new Entity\Image();
   $img->setContentType('image/jpeg');
   $img->setCreatedAt(new \DateTime());
   $img->setName($file->getFilename());
   $img->setPath($file->getPath());
   $img->setSize($file->getSize());

   $manager->persist($img);
   $manager->flush();
}

required=true when editing and add_del option with new entity

Hi,

I've just installed your bundle. Looks great so far! I saw 2 possible enhancements. Wanting to make my form user-friendly, I don't want the user to see the delete option when creating a new entity.

Similarly it's annoying for the user that if the image is required, but already uploaded and showing, that the user needs to upload a new image (overwriting the existing).

I think I tackled both issues for you by changing Vlabs\MediaBundle\Form\Type\FileType

Although in some use-cases this could lead to problems when people actually want the above stated behavior..

Kind regards,
Rein

class FileType extends AbstractType
{
// ...
public function buildForm(FormBuilderInterface $builder, array $options)
{
// check if form is related to entity and if that entity has an ID
if (is_object($builder->getData()) && method_exists($builder->getData(), 'getId'))
{
if ($builder->getData()->getId() === null)
{
// remove delete button on a new entity
if ($options['add_del'])
$options['add_del'] = false;
}
else
{
// remove required on existing entity
if ($options['required'] === true)
$options['required'] = false;
}
}
// ...

Storing images outside the web root

I think there are some issues for people that would like to store images outside the web root:

     **/
     * ...
     * @Vlabs\Media(identifier="image_entity", upload_dir="../files/images")
     */
    protected $image;

This works fine and store images outside the web root in MyProject/files/images instead of MyProject/web/files/images.

So for an image uploaded, the path in the database is for example would be for a given image:
../files/images/5357d7e9d223f.gif

Problem when using filters

The problem is now in rendering:
{{ user.image | vlabs_media('default') }} outputs: /../files/images/5357d7e9d223f.gif

Therefore using a filter like liipImagineBundle
{{ user.image | vlabs_media('default') | imagine_filter('myImagineFilter') }} would result in:
/../files/../files/images/5357d7e9d223f.gif

Wouldn't it be better to have a data_root directory in config file, very similar to liipImagineBundle:

    filesystem:
      data_root:      %kernel.root_dir%/../files

and only store images/5357d7e9d223f.gif in the database to avoid ../

Setting it up with One to Many relationships

Hello. I'm trying to create an entity Part that has many Imagenpart, but I can not set up it at all, I'm recieving this error:

( ! ) Fatal error: Call to a member function getIdentifier() on a non-object in C:\wamp\www\module_car\vendor\vlabs\media-bundle\Vlabs\MediaBundle\Annotation\MediaReader.php on line 43

Not compatible with assets_version mechanism

When using the assets_version mechanism, i got the following error :

FatalErrorException: Error: Cannot use object of type Acme\HelloBundle\Entity\Avatar as array in /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Templating/Asset/Package.php line 65

http://symfony.com/doc/master/reference/configuration/framework.html#ref-framework-assets-version

Symfony try to access the string as an array to reach the first character :

// line 65
if ($path && '/' == $path[0])

But VlabsMediaBundle only provide an Object and its ability to be converted to a string.
I guess we need to convert the object to a string sooner ourself, or add the ability to our object be accessed as an array.

Issue with Gauffrette dependency

Here is the result of the installation process:

$ composer require "vlabs/media-bundle": ">=1.1"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for vlabs/media-bundle > 1.1 -> satisfiable by vlabs/media-bundle[v1.1.1].
- vlabs/media-bundle v1.1.1 requires knplabs/knp-gaufrette-bundle dev-master -> no matching package found.

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

documentation in yaml.

where can i find documentation for yaml for extending the baseclass, im going to use app/console doctrine:mapping:convert yml destination-dir/.

Requires "minimum-stability": "dev"?

Right now, I need to have a "minimum-stability: dev" in my composer json to get this simple bundle installed.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - vlabs/media-bundle v1.1.1 requires knplabs/knp-gaufrette-bundle dev-master -> satisfiable by knplabs/knp-gaufrette-bundle[dev-master].
    - vlabs/media-bundle v1.1 requires knplabs/knp-gaufrette-bundle dev-master -> satisfiable by knplabs/knp-gaufrette-bundle[dev-master].
    - vlabs/media-bundle v1.1.1 requires knplabs/knp-gaufrette-bundle dev-master -> satisfiable by knplabs/knp-gaufrette-bundle[dev-master].
    - Removal request for knplabs/knp-gaufrette-bundle == 9999999-dev
    - Installation request for vlabs/media-bundle ^1.1 -> satisfiable by vlabs/media-bundle[v1.1, v1.1.1].

This is a big problem, as a moment ago I ended up on 2.0.0 of Twig. :)

Tx

Calling a filter from a controller

I need to crop an avatar in my controller in order to give a resized avatar in a json response of a REST API.

I tried calling the twig filter but it's not public.

Is there a way to achieve that ? Is there a reason for the twig extension service not to be public ?

Undefined variable: classConfig - HandlerManager.php line 84

I'm trying to programmatically create a new user with its avatar.

I'm basically doing this :

$avatar = new Avatar();
$avatar
    ->setName('0f28b5d49b302.png')
    ->setContentType('image/png')
    ->setSize(60914)
    ->setPath("/path/web/uploads/avatars/0f28b5d49b302.png")
;

$user = $userManager->createUser()
    ->setUsername('foo')
    ->setEmail('[email protected]')
    ->setAvatar($avatar)
;

$userManager->updateUser($user);

But then i got the following Exception :

[ErrorException]                                                                                                                                             
  Notice: Undefined variable: classConfig in /path/vendor/vlabs/media-bundle/Vlabs/MediaBundle/Handler/HandlerManager.php line 84  

I have no problem defining an avatar through the profile form on a classically registred user.

How to add custom properties to an Image ?

Hello,
Ive tried to add the following to my Image Class:

    /**
     * Defines if the current picture should be shown as thumb in list
     * @var boolean $isThumb
     */
    private $isThumb;

When I try to generate getter/setters they are not generated.
I created them manually but when I run:

php app/console doctrine:schema:update --force

The Database Scheme do not change ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.