예제 #1
0
 public static function autoload($className)
 {
     if (StringHelper::strEndsWith($className, 'Controller')) {
         require APPLICATION_PATH . '/controllers/' . $className . '.php';
     } elseif (StringHelper::strStartsWith($className, 'Model_')) {
         list(, $name) = explode('_', $className);
         require APPLICATION_PATH . '/models/' . $name . '.php';
     } else {
         require APPLICATION_PATH . '/libs/' . $className . '.php';
     }
 }
 /**
  * scans a directory for files with a certain extensions
  *
  * @param string $dir the directory to scan
  * @param string $ext the extension of the files wanted
  * @return array list of files matchin extention, without path
  * @static
  */
 function scanDirectory($dir, $ext)
 {
     $dh = opendir($dir);
     if ($dh === false) {
         //open error PHP warning should do
         return array();
     }
     while (false !== ($filename = readdir($dh))) {
         if (StringHelper::strEndsWith($filename, $ext)) {
             // Single file Plugin '.plugin.php'
             $files[] = $filename;
         } else {
             // Plugin in its own directory
             if (is_dir($dir . '/' . $filename) && file_exists($dir . '/' . $filename . '/' . $filename . $ext)) {
                 $files[] = $filename . '/' . $filename . $ext;
             }
         }
     }
     return $files;
 }
 /**
  *
  * @dataProvider testEndsWithProvider
  */
 public function testEndsWith($suffix, $string, $outcome)
 {
     $this->assertEquals($outcome, StringHelper::strEndsWith($suffix, $string));
 }