1

私は、Symfony CMF ルーティング バンドル 1.3 を使用する Symfony 2.6 アプリケーションを持っています。ここでは、通常の symfony ルートとカスタム ストア用の動的ルートを組み合わせて使用​​します (とりわけ、以下の例では動的ルーターの 1 つに焦点を当てています)。

問題は、ルーターが正常に機能しているにもかかわらず、ルーターが動的ルートに一致しないという無限のログを取得していることです。

最も一般的なエントリは次のとおりです。

Router Symfony\Bundle\FrameworkBundle\Routing\Router was not able to match, message ""

たまに見かけます

Router Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter was not able to match, message ""

これらのログを無効にするか、動的ルーターの構成/セットアップを変更して、ルートが実際に失敗した場合にのみこれらのエラーが表示されるようにする方法はありますか?

ここに私の設定/セットアップがあります:

# app/config/config.yml

cmf_routing:
    chain:
        routers_by_id:
            router.default:             32
            cmf_routing.dynamic_router: 30
    dynamic:
        enabled:                      true
        route_provider_service_id:    store_router

そして、実際の動的ルーターはに基づいています

// StoreBundle/Router/StoreRouter.php

<?php

/**
 * @DI\Service("store_router")
 */
class StoreRouter implements RouteProviderInterface
{
    protected $em;

    /**
     * @DI\InjectParams({
     *      "em" = @DI\Inject("doctrine.orm.entity_manager")
     * })
     */
    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    /**
     * @param Request $request
     * @return RouteCollection
     */
    public function getRouteCollectionForRequest(Request $request)
    {
        $collection = new RouteCollection();

        $store = $this->em->getRepository('StoreBundle:Store')->findOneBySlug(substr($request->getPathInfo(), 1), $request->get('key', null));

        // no store found, return an empty collection
        if (empty($store)) {
            return $collection;
        }

        $route = new Route(
            '/' . $store->getSlug(),
            [
                '_controller' => 'StoreBundle:Store:view',
                'slug' => $stote->getSlug()
            ]
        );

        $collection->add($store->getSlug(), $route);

        return $collection;
    }

    public function getRouteByName($name, $params = [])
    {
    }

    public function getRoutesByNames($names)
    {
    }
}

動的ルートを使用するより良い方法がある場合は、それを聞きたいです:)

4

1 に答える 1

1

ログ エントリは、レベル「debug」で作成されます。ロガーの最小レベルを高く設定できます。他のことのためにデバッグ ログが必要な場合は、symfony_cmf.router サービスで logger 引数を削除する CompilerPass を作成できます。

falseロギングを完全に無効にするオプションを使用して、ログ レベルを構成可能にすることが理にかなっていることに同意します。これが必要な場合は、Routing コンポーネントのコードと RoutingBundle のプル リクエストを確認してマージし、構成を公開します。

于 2015-10-19T20:37:50.787 に答える