本文整理汇总了PHP中Extension::addIncludePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Extension::addIncludePath方法的具体用法?PHP Extension::addIncludePath怎么用?PHP Extension::addIncludePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Extension
的用法示例。
在下文中一共展示了Extension::addIncludePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
use TraitSingleton, TraitContainer, TraitFilepath;
/**
* @param $type
* @throws ExtensionException
*/
public static function get($type)
{
$type = strtolower($type);
if ($file = FilesystemPath::find(self::addIncludePath(), $type . DIRECTORY_SEPARATOR . $type . '.php')) {
require_once $file;
$class_name = __NAMESPACE__ . '\\ExtensionType' . ucfirst($type);
if (!class_exists($class_name)) {
throw new ExtensionException(sprintf('Extension type "%s" not found!', ucfirst($type)));
}
$required_traits = ['Cyan\\Framework\\TraitSingleton'];
$reflection_class = new ReflectionClass($class_name);
foreach ($required_traits as $required_trait) {
if (!in_array($required_trait, $reflection_class->getTraitNames())) {
throw new ExtensionException(sprintf('%s class must use %s', $class_name, $required_trait));
}
}
if (!is_callable([$class_name, 'register'])) {
throw new ExtensionException(sprintf('%s class must implement register method', $class_name));
}
return $class_name::getInstance();
}
throw new ExtensionException(sprintf('Extension "%s" not found!', ucfirst($type)));
}
}
Extension::addIncludePath(__DIR__ . DIRECTORY_SEPARATOR . 'type');