. */ /** * Doctrine_Search * * @package Doctrine * @subpackage Search * @author Konsta Vesterinen * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version $Revision$ * @link www.phpdoctrine.com * @since 1.0 */ class Doctrine_Search_File extends Doctrine_Search { public function __construct(array $options = array()) { parent::__construct($options); if ( ! isset($this->_options['resource'])) { $table = new Doctrine_Table('File', Doctrine_Manager::connection()); $table->setColumn('url', 'string', 255, array('primary' => true)); $this->_options['resource'] = $table; } if (empty($this->_options['fields'])) { $this->_options['fields'] = array('url', 'content'); } $this->buildDefinition(); } public function indexDirectory($dir) { $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($it as $file) { if (strpos($file, DIRECTORY_SEPARATOR . '.svn') !== false) { continue; } $this->updateIndex(array('url' => $file->getPathName(), 'content' => file_get_contents($file))); } } }