本文整理汇总了PHP中Zend\Loader::explodeIncludePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::explodeIncludePath方法的具体用法?PHP Loader::explodeIncludePath怎么用?PHP Loader::explodeIncludePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Loader
的用法示例。
在下文中一共展示了Loader::explodeIncludePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getFiles
/**
* _getFiles()
*
* @return array Array of files to load
*/
protected function _getFiles()
{
$paths = \Zend\Loader::explodeIncludePath();
// used for checking similarly named files
$relativeItems = array();
$files = array();
$isZendTraversed = false;
foreach ($paths as $path) {
// default patterns to use
$filterDenyDirectoryPattern = '.*(/|\\\\).svn';
$filterAcceptFilePattern = '.*(?:Manifest|Provider)\\.php$';
if (!file_exists($path) || $path[0] == '.') {
continue;
}
$realIncludePath = realpath($path);
// ensure that we only traverse a single version of Zend Framework on all include paths
if (file_exists($realIncludePath . '/Zend/Tool/Framework/Loader/IncludePathLoader.php')) {
if ($isZendTraversed === false) {
$isZendTraversed = true;
} else {
// use the deny directory pattern that includes the path to 'Zend', it will not be accepted
$filterDenyDirectoryPattern = '.*((/|\\\\).svn|' . preg_quote($realIncludePath . DIRECTORY_SEPARATOR) . 'Zend)';
}
}
// create recursive directory iterator
$rdi = new \RecursiveDirectoryIterator($path);
// pass in the RecursiveDirectoryIterator & the patterns
$filter = new RecursiveFilterIterator($rdi, $filterDenyDirectoryPattern, $filterAcceptFilePattern);
// build the rii with the filter
$iterator = new \RecursiveIteratorIterator($filter);
// iterate over the accepted items
foreach ($iterator as $item) {
$file = (string) $item;
if ($this->_fileIsBlacklisted($file)) {
continue;
}
// ensure that the same named file from separate include_paths is not loaded
$relativeItem = preg_replace('#^' . preg_quote($realIncludePath . DIRECTORY_SEPARATOR, '#') . '#', '', $item->getRealPath());
// no links allowed here for now
if ($item->isLink()) {
continue;
}
// no items that are relavitely the same are allowed
if (in_array($relativeItem, $relativeItems)) {
continue;
}
$relativeItems[] = $relativeItem;
$files[] = $item->getRealPath();
}
}
return $files;
}
示例2: _getZfPath
/**
* _getZfPath()
*
* @return string|false
*/
protected function _getZfPath()
{
foreach (\Zend\Loader::explodeIncludePath() as $includePath) {
if (!file_exists($includePath) || $includePath[0] == '.') {
continue;
}
if (realpath($checkedPath = rtrim($includePath, '\\/') . '/Zend/Loader.php') !== false && file_exists($checkedPath)) {
return dirname($checkedPath);
}
}
return false;
}
示例3: testExplodeIncludePathProperlyIdentifiesStreamSchemes
/**
* @group ZF-7271
*/
public function testExplodeIncludePathProperlyIdentifiesStreamSchemes()
{
if (PATH_SEPARATOR != ':') {
$this->markTestSkipped();
}
$path = 'phar://zlt.phar:/var/www:.:filter://[a-z]:glob://*';
$paths = Loader::explodeIncludePath($path);
$this->assertSame(array('phar://zlt.phar', '/var/www', '.', 'filter://[a-z]', 'glob://*'), $paths);
}
示例4: findRealpathInIncludePath
/**
* Find realpath of file based on include_path
*
* @param string $fileName
* @return string
*/
public static function findRealpathInIncludePath($fileName)
{
$includePaths = \Zend\Loader::explodeIncludePath();
while (count($includePaths) > 0) {
$filePath = array_shift($includePaths) . DIRECTORY_SEPARATOR . $fileName;
if (($foundRealpath = realpath($filePath)) !== false) {
break;
}
}
return $foundRealpath;
}