Sponsored Link

Ethna_ClassFactory::_include

Filed under: Ethna_ClassFactory — admin @ 10:03:54

■呼び元
Ethna_ClassFactory::getObject


/**
* 指定されたクラスから想定されるファイルをincludeする
*
* @access protected
*/
function _include($class_name)
{
$file = sprintf("%s.%s", $class_name, $this->controller->getExt(’php’));
if (file_exists_ex($file)) {
include_once $file;
return true;
}
 
if (preg_match(’/^(\w+?)_(.*)/’, $class_name, $match)) {
// try ethna app style
// App_Foo_Bar_Baz -> Foo/Bar/App_Foo_Bar_Baz.php
$tmp = explode(”_”, $match[2]);
$tmp[count($tmp)-1] = $class_name;
$file = sprintf(’%s.%s’,
implode(DIRECTORY_SEPARATOR, $tmp),
$this->controller->getExt(’php’));
if (file_exists_ex($file)) {
include_once $file;
return true;
}
 
// try ethna app & pear mixed style
// App_Foo_Bar_Baz -> Foo/Bar/Baz.php
$file = sprintf(’%s.%s’,
str_replace(’_', DIRECTORY_SEPARATOR, $match[2]),
$this->controller->getExt(’php’));
if (file_exists_ex($file)) {
include_once $file;
return true;
}
 
// try ethna master style
// Ethna_Foo_Bar -> class/Ethna/Foo/Ethna_Foo_Bar.php
array_unshift($tmp, ‘Ethna’, ‘class’);
$file = sprintf(’%s.%s’,
implode(DIRECTORY_SEPARATOR, $tmp),
$this->controller->getExt(’php’));
if (file_exists_ex($file)) {
include_once $file;
return true;
}
 
// try pear style
// Foo_Bar_Baz -> Foo/Bar/Baz.php
$file = sprintf(’%s.%s’,
str_replace(’_', DIRECTORY_SEPARATOR, $class_name),
$this->controller->getExt(’php’));
if (file_exists_ex($file)) {
include_once $file;
return true;
}
}
return false;
}

コメント (1) »

  1. Спасибо, полезно!

    コメント by Большая Советская Энциклопедия — 2009/10/2 金曜日 @ 17:09:44

コメント RSS トラックバック URL

コメントをどうぞ