Sonata Media Bundle をインストールしていますが、バンドルのギャラリー部分は使用していません。
ギャラリーを無効にするにはどうすればよいですか?
私は Symfony 2.3 を使用しており、ドキュメントに従って標準のメディア バンドルをインストールしています。
これまでの解決策:
管理バンドルからこの問題https://github.com/sonata-project/SonataAdminBundle/issues/460show_in_dashboard: false
を見ると、yaml ファイルにタグを追加することで管理者を無効にすることができます。
これを行うには、このフラグを追加する独自のコンパイラを追加するだけです。
コンパイラを作成します: http://symfony.com/doc/current/components/dependency_injection/tags.html
コンパイラをバンドルに追加します: http://symfony.com/doc/2.3/cookbook/service_container/compiler_passes.html
これで完了です。より良い解決策があれば、それについて聞きたいです。
コンパイラの例:
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 ] );
}
}
}
}