This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 1.22 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. //このコードの改変・再配布等は全く自由に行って構いません
  3.     function _loadFixtures() {
  4.         parent::_loadFixtures();
  5.  
  6.         if (empty($this->_fixtures)) {
  7.             $this->_fixtures = array();
  8.         }
  9.  
  10.         foreach($this->fixtures as $fixture) {
  11.             if(isset($this->_fixtures[$fixture])) {
  12.                 continue;
  13.             }
  14.             if(preg_match('/^app\.(\w+)$/', $fixture, $m)) {
  15.                 $this->_generateFixture($fixture, $m[1]);
  16.             }
  17.         }
  18.  
  19.         if (empty($this->_fixtures)) {
  20.             unset($this->_fixtures);
  21.         }
  22.     }
  23.  
  24.     function _generateFixture($fixture, $name) {
  25.         $Name = Inflector::camelize($name);
  26.         $table = Inflector::tableize($Name);
  27.  
  28.         $fixtureClass = $Name . 'Fixture';
  29.         $schemaVar = '$import';
  30.         $schema = array('table' => $table);
  31.  
  32.         if(!class_exists($fixtureClass)) {
  33.             $code = '
  34. class '. $fixtureClass .' extends CakeTestFixture {
  35.         var $name = "'. $Name .'";
  36.         var '. $schemaVar .' = '. var_export($schema, true) .';
  37. }
  38. ';
  39.             eval($code);
  40.         }
  41.         $this->_fixtures[$fixture] =& new $fixtureClass($this->db);
  42.         $this->_fixtureClassMap[$Name] = $fixture;
  43.     }
clone this paste RAW Paste Data