独自のチェックを使用する必要があります。
- 自分のを使え
sfWebResponse
- オーバーライド
addJavascript
- チェックを追加
したがって、次のコードを使用して、フォルダーに新しいmyWebResponse.class.php
ファイルを/lib/response/
作成 (作成) します。
class myWebResponse extends sfWebResponse
{
public function addJavascript($file, $position = '', $options = array())
{
$this->validatePosition($position);
// check if the file to add is jquery
// nb: you might update the regex
if (preg_match('/jquery/i', $file))
{
// retrieve all loaded js
$files = array_keys($this->getJavascripts());
// check if one them containt jquery
// nb: you might update the regex
$isJquery = preg_grep("/jquery/i", $files);
// jquery found so do not add the file
if ( ! empty($isJquery))
{
return;
}
}
$this->javascripts[$position][$file] = $options;
}
次に、デフォルトで新しい応答を使用します。apps/frontend/config/factories.yml
に、次を追加します。
all:
response:
class: myWebResponse
あなたは終わった。