I have the Sonata Media Bundle installed but I don't use the gallery portion of the bundle.
How do I disable the Gallery?
I am using Symfony 2.3 and I have the standard Media Bundle install as per the documentation.
Solution thus far:
If you look at this issue https://github.com/sonata-project/SonataAdminBundle/issues/460 from the admin bundle you can disable a admin by adding the show_in_dashboard: false
tag to the yaml file.
To do this I simply add my own compiler that adds this flag for me then:
Create your compiler: http://symfony.com/doc/current/components/dependency_injection/tags.html
Add your compiler to your bundle: http://symfony.com/doc/2.3/cookbook/service_container/compiler_passes.html
And you are done. If there is a better solution I'd love to hear about it.
Example of compiler:
namespace YourBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class OverrideMediaGalleryCompilerPass implements CompilerPassInterface
{
/**
* You can modify the container here before it is dumped to PHP code.
*
* @param ContainerBuilder $container
*
* @api
*/
public function process( ContainerBuilder $container )
{
$definition = $container->getDefinition( 'sonata.media.admin.gallery' );
if ( $definition ) {
/**
* The purpose here is to disable the sonata admin gallery from showing up
* in the dashboard. This goes through and adds show_in_dashboard parameter
* that disables this.
*/
if ( $definition->hasTag( 'sonata.admin' ) ) {
$tags = $definition->getTag( 'sonata.admin' );
$tags[ 0 ][ 'show_in_dashboard' ] = false;
$definition->clearTag( 'sonata.admin' );
$definition->addTag( 'sonata.admin', $tags[ 0 ] );
}
}
}
}