コード例 #1
0
 /**
  * Clears the super cache by listening to the task.cache.clear event.
  *
  * @param sfEvent An sfEvent instance
  */
 public static function clearCache(sfEvent $event)
 {
     $config = sfFilterConfigHandler::getConfiguration($event['app']->getConfigPaths('config/filters.yml'));
     $event->getSubject()->logSection('cache', 'Clearing super cache');
     // find super cache configuration
     $found = false;
     $cacheDir = 'cache';
     foreach ($config as $value) {
         if ('sfSuperCacheFilter' == $value['class']) {
             $found = true;
             if (isset($value['param']['cache_dir'])) {
                 $cacheDir = $value['param']['cache_dir'];
             }
             break;
         }
     }
     if ($found) {
         // clear the cache
         $cacheDir = sfConfig::get('sf_web_dir') . '/' . $cacheDir;
         if (is_dir($cacheDir)) {
             // remove cache files
             $event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir));
         }
     }
 }
コード例 #2
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(8);
$handler = new sfFilterConfigHandler();
$handler->initialize();
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'sfFilterConfigHandler' . DIRECTORY_SEPARATOR;
// parse errors
$t->diag('parse errors');
$files = array($dir . 'no_class.yml');
try {
    $data = $handler->execute($files);
    $t->fail('filters.yml must have a "class" section for each filter entry');
} catch (sfParseException $e) {
    $t->like($e->getMessage(), '/with missing class key/', 'filters.yml must have a "class" section for each filter entry');
}
// no execution/rendering filter
foreach (array('execution', 'rendering') as $key) {
    $files = array($dir . sprintf('no_%s.yml', $key));
    try {
        $data = $handler->execute($files);
        $t->fail(sprintf('filters.yml must have a filter of type "%s"', $key));
    } catch (sfParseException $e) {
        $t->like($e->getMessage(), sprintf('/must register a filter of type "%s"/', $key), sprintf('filters.yml must have a filter of type "%s"', $key));