symfony - Adding properties to/extending Sonata Media entity -
i want add properties sonata media entity, can't work. i'm using sonata media bundle 2.3, , have installed according manual. extended sonata easy extends bundle.
when add property application\sonata\mediabundle\entity\media
, doesn't picked when run doctrine:generate:diff
('no changes detected in mapping information.').
overriding media class in config.yml
won't make difference well.
this code in application\sonata\mediabundle\entity\media.php
:
<?php namespace application\sonata\mediabundle\entity; use doctrine\orm\mapping orm; use sonata\mediabundle\entity\basemedia basemedia; /** * @orm\entity */ class media extends basemedia { /** * @var integer $id */ protected $id; /** * @orm\column(type="string", nullable=true) */ protected $test; /** * @return mixed */ public function gettest() { return $this->test; } /** * @param mixed $test */ public function settest($test) { $this->test = $test; } /** * id * * @return integer $id */ public function getid() { return $this->id; } }
and in config.yml
:
sonata_media: class: media: application\sonata\mediabundle\entity\media gallery: application\sonata\mediabundle\entity\gallery gallery_has_media: application\sonata\mediabundle\entity\galleryhasmedia
again, same result if leave section commented out.
update: when create custom migration adds property, when extend mediaadmin, test
field won't show when go image edit page:
// application\sonata\mediabundle\admin\mediaadmin.php <?php namespace sonata\mediabundle\admin; use sonata\adminbundle\admin\admin; use sonata\adminbundle\form\formmapper; use sonata\adminbundle\datagrid\datagridmapper; use sonata\adminbundle\datagrid\listmapper; use sonata\adminbundle\show\showmapper; class mediaadmin extends admin { protected function configureformfields(formmapper $formmapper) { $formmapper ->add('name', null, ['required' => false]) ->add('enabled', null, ['required' => false]) ->add('authorname', null, ['required' => false]) ->add('cdnisflushable', null, ['required' => false]) ->add('description', null, ['required' => false]) ->add('copyright', null, ['required' => false]) ->add('test', null, ['required' => false]) ->add('binarycontent', 'file', ['required' => false]); } }
so seems sonata ignoring extended media bundle (which isn't case, because when remove application\sonata\mediabundle\entity\media.php
, error).
well, seems had remove application/sonata/mediabundle/resources/config/doctrine
folder , annotate media entities following:
<?php namespace application\sonata\mediabundle\entity; use doctrine\orm\mapping orm; use sonata\mediabundle\entity\basemedia basemedia; /** * @orm\table(name="media__media") * @orm\entity */ class media extends basemedia
a simple php app/console doctrine:schema:update --force
in end did trick. hope helps encounter same problem.
Comments
Post a Comment