- Timestamp:
- 01/12/08 04:10:41 (5 years ago)
- Files:
-
- plugins/sfLucenePlugin/trunk/CHANGELOG (modified) (1 diff)
- plugins/sfLucenePlugin/trunk/README (modified) (1 diff)
- plugins/sfLucenePlugin/trunk/lib/behavior/sfLucenePropelBehavior.class.php (modified) (4 diffs)
- plugins/sfLucenePlugin/trunk/test/unit/behavior/sfLucenePropelBehaviorTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfLucenePlugin/trunk/CHANGELOG
r6922 r7021 20 20 * BC: sfLuceneCriteria constructor now requires sfLucene instance 21 21 * Refactored highlighting system 22 * Added ability to lock the Propel behavior. 22 23 23 24 Version 0.1.1 Beta plugins/sfLucenePlugin/trunk/README
r6922 r7021 154 154 after the class declaration. So, for a blog, you would open project/lib/model/BlogPost.php and append the above, replacing "!MyModel" with "!BlogPost". 155 155 156 If you wish to disable the Propel behavior so that no indexing can occur, you can simply do: 157 {{{ 158 sfLucenePropelBehavior::setLock(true); // disables Propel behavior, no indexing 159 sfLucenePropelBehavior::setLock(false); // enables Propel behavior, does index 160 }}} 161 162 By default, the behavior is not locked so indexing does occur. 163 156 164 == Advanced Model Settings == 157 165 You can configure the model even more. If the peer does not follow symfony's naming conventions, you can specify a new one with in the project level search.yml: plugins/sfLucenePlugin/trunk/lib/behavior/sfLucenePropelBehavior.class.php
r6733 r7021 28 28 29 29 /** 30 * If true, then nothing can be added to the queues. 31 */ 32 static protected $locked = false; 33 34 /** 30 35 * Adds the node to the queue if is modified or is new. 31 36 * … … 36 41 public function preSave($node) 37 42 { 43 if (self::$locked) 44 { 45 return; 46 } 47 38 48 if ($node->isModified() || $node->isNew()) 39 49 { … … 77 87 public function preDelete($node) 78 88 { 89 if (self::$locked) 90 { 91 return; 92 } 93 79 94 if (!$node->isNew()) 80 95 { … … 192 207 return sfLucenePropelInitializer::getInstance(); 193 208 } 209 210 /** 211 * Locks the Propel behavior, so nothing can be queued. 212 * @param bool $to If true, the behavior is locked. If false, the behavior is unlocked. 213 */ 214 static public function setLock($to) 215 { 216 self::$locked = (bool) $to; 217 } 194 218 } plugins/sfLucenePlugin/trunk/test/unit/behavior/sfLucenePropelBehaviorTest.php
r6960 r7021 17 17 require dirname(__FILE__) . '/../../bootstrap/unit.php'; 18 18 19 $t = new limeade_test( 26, limeade_output::get());19 $t = new limeade_test(30, limeade_output::get()); 20 20 $limeade = new limeade_sf($t); 21 21 $app = $limeade->bootstrap(); … … 55 55 { 56 56 return $this->getSearchInstances($node); 57 } 58 59 public function clear() 60 { 61 $this->saveQueue = array(); 62 $this->deleteQueue = array(); 57 63 } 58 64 } … … 154 160 $t->is($behavior->_getDeleteQueue(), array(1 => $m2), '->postDelete() removes deleting model from the queue'); 155 161 162 $t->diag('testing ::setLock()'); 163 164 $behavior->clear(); 165 166 sfLucenePropelBehavior::setLock(true); 167 168 $m1->setCoolness(4); 169 170 $behavior->preSave($m1); 171 $t->is(count($behavior->_getSaveQueue()), 0, '::setLock() disables the save queue'); 172 173 $behavior->preDelete($m1); 174 $t->is(count($behavior->_getDeleteQueue()), 0, '::setLock() disables the delete queue'); 175 176 $behavior->clear(); 177 178 sfLucenePropelBehavior::setLock(false); 179 180 $behavior->preSave($m1); 181 $t->is(count($behavior->_getSaveQueue()), 1, '::setLock() enables the save queue'); 182 183 $behavior->preDelete($m1); 184 $t->is(count($behavior->_getDeleteQueue()), 1, '::setLock() enables the delete queue'); 185 186 $behavior->clear(); 187 188 foreach (array($m1, $m2, $m3, $m3) as $m) 189 { 190 $indexer = new sfLucenePropelIndexer(sfLucene::getInstance('testLucene', 'en'), $m); 191 $indexer->delete(); 192 } 193 156 194 $t->diag('testing ->insertIndex()'); 157 195