V-labs / VlabsMediaBundle

Form, database and filesystem abstraction for files
44 stars 18 forks source link

Undefined variable: classConfig - HandlerManager.php line 84 #6

Closed jcrombez closed 11 years ago

jcrombez commented 11 years ago

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('foo@bar.com')
    ->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.

lenybernard commented 11 years ago

Hi,

Did you figured out ? I have got exactly the same issue...

choomz commented 11 years ago

Hi,

I was on holidays last week, i'll try to look at it this week.

jcrombez commented 11 years ago

Thank you for this fix.

Just a little thing : when adding file programmaticly, i have to specify createdAt manually. Not a big deal but, it would be nice to keep that on the bundle side.

choomz commented 11 years ago

Yes I know for the create at. It's a 'wanted' behaviour as long as I don't want to force a dependancy with a lib like gedmo doctrine extensions.

jcrombez commented 11 years ago

A simple default value in the constructor would do the job, do you see any problem with this solution ?

choomz commented 11 years ago

You are right. waiting for your PR :)

jcrombez commented 11 years ago

My fork has a composer set for SF 2.2, is it okay ?

choomz commented 11 years ago

Did not tested yet, you can try to run tests and see.

choomz commented 11 years ago

Well actually, the BaseFile is an abstract class, and so if we setup constructor, children must call the parent constructor to achieve the initialization.

So .. I think it's better for you to just setup the constructor in your children class.

jcrombez commented 11 years ago

What's the problem with calling the parent constructor when a children constructor is needed ?