public function testFindAllMainByExpressionAndObject() { $aMainPaths = ResourceFinder::findResourcesByExpressions(array('lib', 'main.php')); $this->assertSame(1, count($aMainPaths)); $oFileRes = new FileResource(ArrayUtil::assocPeek($aMainPaths)); $this->assertSame(array($oFileRes->getRelativePath() => MAIN_DIR . '/base/lib/main.php'), $aMainPaths); }
private static function findRapilaClass($sClassName) { $sFileName = "{$sClassName}.php"; //Standard Classes $sPath = ResourceFinder::create()->addPath(DIRNAME_LIB, DIRNAME_CLASSES, $sFileName)->find(); if ($sPath) { return $sPath; } //Generated Model classes $sPath = ResourceFinder::create()->addPath(DIRNAME_GENERATED, DIRNAME_MODEL, $sFileName)->searchMainOnly()->find(); if ($sPath) { return $sPath; } $sPath = ResourceFinder::create()->addPath(DIRNAME_GENERATED, DIRNAME_MODEL, false, $sFileName)->byExpressions()->searchMainOnly()->find(); if (($sPath = ArrayUtil::assocPeek($sPath)) !== null) { return $sPath; } //Model classes $sPath = ResourceFinder::create()->addPath(DIRNAME_LIB, DIRNAME_MODEL, $sFileName)->find(); if ($sPath) { return $sPath; } $sPath = ResourceFinder::create()->addPath(DIRNAME_LIB, DIRNAME_MODEL, false, $sFileName)->byExpressions()->find(); if (($sPath = ArrayUtil::assocPeek($sPath)) !== null) { return $sPath; } if (Module::isValidModuleClassNameOfAnyType($sClassName)) { foreach (Module::listModuleTypes() as $sModuleType) { $sModuleBaseClass = Module::getClassNameByTypeAndName($sModuleType); if (!class_exists($sModuleBaseClass)) { continue; } if ($sModuleBaseClass::isValidModuleClassName($sClassName)) { $sPath = ResourceFinder::create(array(DIRNAME_MODULES, $sModuleType, $sModuleBaseClass::getNameByClassName($sClassName), $sFileName))->find(); if ($sPath) { return $sPath; } } } } return null; }