【问题标题】:Sonata No site available for the current request奏鸣曲 没有可用于当前请求的网站
【发布时间】:2019-01-13 03:35:34
【问题描述】:

我在 Symfony 4 上设置 Sonata-Page , Admin ...

iphttp://10.2.0.6是docker服务器ip

运行

 bin/console sonata:page:create-snapshots --site=all
 bin/console sonata:page:update-core-routes --site=all

启用页面

但总是有

在 Sonata\PageBundle\Site 公共函数中检索()我得到

arrayPrint.php on line 64:
HostSiteSelector {#211 ▼
  #siteManager: SiteManager {#220 ▶}
  #decoratorStrategy: DecoratorStrategy {#213 ▶}
  #seoPage: SeoPage {#214 ▶}
  #site: null

这个变量是谁填的,为什么是空的?

我看到监听器 (Sonata\PageBundle\Listener\RequestListener onCoreReques ) 被触发并尝试从此方法站点对象获取。

在同一个班级我看到了

protected function getSites(Request $request)

当我转储这个时,我得到了

arrayPrint.php on line 64:
array:1 [▼
  0 => SonataPageSite {#460 ▼
    #id: 1
    #enabled: true
    #createdAt: DateTime @1533546625 {#483 ▶}
    #updatedAt: DateTime @1533541412 {#505 ▶}
    #name: "localhost"
    #host: "10.2.0.6"
    #relativePath: null
    #enabledFrom: DateTime @1533546622 {#484 ▶}
    #enabledTo: DateTime @1849165822 {#464 ▶}
    #isDefault: true
    #formats: []
    #locale: "en_GB"
    #title: null
    #metaKeywords: null
    #metaDescription: null
  }
]

【问题讨论】:

    标签: php symfony sonata-admin sonata


    【解决方案1】:

    好的,我找到了原因 - 我创建了像手册一样的页面

    php app/console  sonata:page:create-site --enabled=true --name=localhost --locale=- --host=localhost --relativePath=/ --enabledFrom=now --enabledTo="+10 years" --default=true
    

    enabledFrom=now ,我不知道为什么,但在 GMT 中给出我的时间而不是我的时区,所以如果我等待一小时网站从可见开始,则网站在当前时间不可见。我认为这不好。在默认页面中应该是可见的,没有范围之外的限制。

    【讨论】:

      猜你喜欢
      • 2020-10-20
      • 2012-07-03
      • 2019-01-13
      • 2019-05-17
      • 1970-01-01
      • 2013-07-03
      • 2021-08-15
      • 2017-04-27
      • 2013-12-04
      相关资源
      最近更新 更多