2012-02-25 6 views
0

私は自分のクラスのオートローダーを作成しており、結果から配列を作成しています。私はこの配列を構築することができますが、私は何をすることはできませんクラスの実際のクラス名がへの鍵としてロードされて設定されている、私はそれがクラス名ではなくクラスパスを渡すことでReflectionデータを取得できますか?

$classes['myTestClass'] = ./classes/myTestClass.class.php

ようになりたい私の配列の

1パス。

これは私の配列

foreach ($classIterator as $file) { 

    if ($this->_searchFilter($file)) 
     $this->classes[] = $file->getPathname(); 
} 

$file->getPathname()を構築し、私のforeachループは、私はそのファイルからクラス名を取得する方法requiredになりますクラスファイルの絶対パスを持っていますか?あなたが命名規則を使用している場合

答えて

0

ので/classes/myTestClass.class.phpは、単純なstr_replaceは十分なものでなければならない、その後、myTestClass宣言します

foreach ($classIterator as $file) { 

    if ($this->_searchFilter($file)) 
     $classPath = $file->getPathname(); 
     $className = str_replace('.class.php', '', basename($classPath)); 
     $this->classes[$className] = $classPath; 
} 
関連する問題