/** * 名前をキーとしてインスタンスを探す * * @param string $name 名前 * @return BcAgent|null * @dataProvider findDataProvider */ public function testFind($name) { $result = $this->agent->find($name); if (!is_null($result)) { $this->assertEquals($name, $result->name, '設定を正しく読み込めません'); } else { $this->assertNull($result, '存在しないユーザーエージェント名で設定が読み込まれています'); } }
/** * After Render * * @param string $viewFile */ public function afterRender($viewFile) { parent::afterRender($viewFile); if (BcUtil::isAdminSystem()) { return; } if (empty($this->request->params['Site'])) { return; } if (isset($this->request->params['Site']['name']) && is_null($this->request->params['Site']['name'])) { return; } if (isset($this->request->params['Site']['device']) && $this->request->params['Site']['device'] != '') { return; } // 別URLの場合、alternateを出力(スマートフォンのみ対応) $pureUrl = $this->BcContents->getPureUrl($this->request->url, $this->request->params['Site']['id']); $agent = BcAgent::find('smartphone'); $subSite = BcSite::findCurrentSub(false, $agent); if (!$subSite) { return; } $url = $subSite->makeUrl(new CakeRequest($pureUrl)); $this->_View->set('meta', $this->BcHtml->meta('canonical', $this->BcHtml->url($url, true), ['rel' => 'canonical', 'media' => 'only screen and (max-width: 640px)', 'type' => null, 'title' => null, 'inline' => false])); }