本文整理汇总了PHP中spl_autoload_call函数的典型用法代码示例。如果您正苦于以下问题:PHP spl_autoload_call函数的具体用法?PHP spl_autoload_call怎么用?PHP spl_autoload_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spl_autoload_call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autoload2
public function autoload2($class)
{
echo "autoload2\n";
spl_autoload_unregister(array($this, 'autoload2'));
spl_autoload_register(array($this, 'autoload2'));
spl_autoload_call($class);
}
示例2: autoload
/**
* Reloads the autoloader.
*
* @param string $class
*
* @return boolean
*/
public function autoload($class)
{
// only reload once
if ($this->reloaded) {
return false;
}
$autoloads = spl_autoload_functions();
// as of PHP 5.2.11, spl_autoload_functions() returns the object as the first element of the array instead of the class name
if (version_compare(PHP_VERSION, '5.2.11', '>=')) {
foreach ($autoloads as $position => $autoload) {
if ($this === $autoload[0]) {
break;
}
}
} else {
$position = array_search(array(__CLASS__, 'autoload'), $autoloads, true);
}
if (isset($autoloads[$position + 1])) {
$this->unregister();
$this->register();
// since we're rearranged things, call the chain again
spl_autoload_call($class);
return class_exists($class, false) || interface_exists($class, false);
}
$autoload = sfAutoload::getInstance();
$autoload->reloadClasses(true);
$this->reloaded = true;
return $autoload->autoload($class);
}
示例3: autoLoadAnnotation
public static function autoLoadAnnotation()
{
if (!self::$annotationIsLoad) {
foreach (self::$annotationList as $annotation) {
spl_autoload_call(self::$annotationPackage . $annotation);
}
self::$annotationIsLoad = true;
}
}
示例4: testFunc
function testFunc()
{
$loader = new BasePathClassLoader(array('tests/lib'));
$loader->register();
ok($loader);
spl_autoload_call('Foo\\Bar');
ok(class_exists('Foo\\Bar'));
$loader->unregister();
}
示例5: test
function test()
{
spl_autoload_call('FormKit\\ResponseUtils');
block_start('level-1');
?>
Block 1<?php
$content = block_end();
is('Block 1', $content);
$content = FormKit\Block::getContent('level-1');
is('Block 1', $content);
}
示例6: autoLoadAnnotation
public static function autoLoadAnnotation()
{
if (!self::$annotationIsLoad) {
foreach (self::$annotationList as $annotation) {
$className = self::$annotationPackage . $annotation;
if (!class_exists($className)) {
spl_autoload_call($className);
}
}
self::$annotationIsLoad = true;
}
}
示例7: registerAnnotationLoader
protected static function registerAnnotationLoader(array $namespaces)
{
AnnotationRegistry::reset();
AnnotationRegistry::registerLoader(function ($class) use($namespaces) {
foreach ($namespaces as $namespace) {
if (strpos($class, $namespace) === 0) {
spl_autoload_call($class);
return class_exists($class, false);
}
}
});
}
示例8: autoload
protected function autoload($className)
{
echo 'No path is defined, try to autoload class...' . PHP_EOL . PHP_EOL;
if (!class_exists($className)) {
spl_autoload_call($className);
}
if (!class_exists($className)) {
echo 'Unable to autoload the entity class(' . $className . '), try with a path' . PHP_EOL;
return false;
} else {
echo 'Class is load.' . PHP_EOL;
return true;
}
}
示例9: loadClass
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
*/
public function loadClass($class)
{
if (array_key_exists($class, $aliases = $this->classAliasList->getRegisteredAliases())) {
// we have an alias for it, but we don't have it yet loaded
// (because after all, we're in the auto loader.)
$fullClass = $aliases[$class];
if (!class_exists($fullClass, false)) {
spl_autoload_call($fullClass);
}
// finally, we set up a class alias for this list. We do this now because
// we don't know earlier what namespace it'll be in
class_alias($fullClass, $class);
}
}
示例10: create
/**
* @static
* @throws Exception
* |WeLearn_Base_LoaderNaoIniciadoException
* |WeLearn_Base_ParametroInvalidoException
* |WeLearn_DAO_DAOInvalidaException
* |WeLearn_DAO_DAONaoEncontradaException
* |WeLearn_DAO_CFNaoDefinidaException
* @param string $nomeDao Nome da classe DAO
* @param array|null $opcoes Opções que serão passadas como parâmetro
* na inicialização da classe DAO e sua Column Family
* @param boolean $DaoPadrao Indicador se a DAO à ser carregada extende a DAO padrão ou não.
*
* @return mixed
*/
public static function create($nomeDao, array $opcoes = null, $DaoPadrao = true)
{
//Criação de DAO não funciona se o autoload não estiver iniciado
if (!WeLearn_Base_AutoLoader::hasInitiated()) {
throw new WeLearn_Base_LoaderNaoIniciadoException();
}
if (is_string($nomeDao) && $nomeDao !== '') {
$classeDAO = $nomeDao;
} elseif (is_object($nomeDao) && is_subclass_of($nomeDao, 'WeLearn_DTO_IDTO')) {
$nsSseparator = WeLearn_Base_Loader::getInstance()->getNamespaceSeparator();
$classeComNamespace = explode($nsSseparator, get_class($nomeDao));
//Ultimo elemento do array é o nome da classe
$classeSomenteNome = $classeComNamespace[count($classeComNamespace) - 1];
$classeDAO = $classeSomenteNome . 'DAO';
} else {
throw new WeLearn_Base_ParametroInvalidoException();
}
//Se a classe não foi definida
if (!class_exists($classeDAO)) {
spl_autoload_call($classeDAO);
//Tenta carregar
//Se ainda não estiver sido definida
if (!class_exists($classeDAO)) {
throw new WeLearn_DAO_DAONaoEncontradaException($classeDAO);
}
}
//Se foi definida mas não extende a classe DAO padrão
if ($DaoPadrao && !is_subclass_of($classeDAO, 'WeLearn_DAO_AbstractDAO')) {
throw new WeLearn_DAO_DAOInvalidaException($classeDAO);
}
if ($DaoPadrao && !$classeDAO::isSingletonInstanciado()) {
$DAOObject = $classeDAO::getInstanciaSingleton();
//Se o nome da Column Family da DAO não foi definido, não continua
if (is_null($DAOObject->getNomeCF())) {
throw new WeLearn_DAO_CFNaoDefinidaException($classeDAO);
}
//Rotina para criar o objeto que representa a Column Family (pode ser modificado)
$CF = WL_Phpcassa::getInstance()->getColumnFamily($DAOObject->getNomeCF(), $opcoes);
$DAOObject->setCF($CF);
} elseif ($DaoPadrao) {
$DAOObject = $classeDAO::getInstanciaSingleton();
} else {
$DAOObject = new $classeDAO();
}
return $DAOObject;
}
示例11: setupAliasAutoloader
/**
* Aliases concrete5 classes to shorter class name aliases
*
* IDEs will not recognize these classes by default. A symbols file can be generated to
* assist IDEs by running SymbolGenerator::render() via PHP or executing the command-line
* 'concrete/bin/concrete5 c5:ide-symbols
*/
protected function setupAliasAutoloader()
{
$loader = $this;
spl_autoload_register(function ($class) use($loader) {
$list = ClassAliasList::getInstance();
if (array_key_exists($class, $aliases = $list->getRegisteredAliases())) {
// we have an alias for it, but we don't have it yet loaded
// (because after all, we're in the auto loader.)
$fullClass = $aliases[$class];
if (!class_exists($fullClass, false)) {
spl_autoload_call($fullClass);
}
// finally, we set up a class alias for this list. We do this now because
// we don't know earlier what namespace it'll be in
class_alias($fullClass, $class);
}
});
}
示例12: __call
public function __call($method, $args)
{
/* check registered operations */
if (isset($this->registered[$method])) {
$operation = $this->registered[$method];
return call_user_func_array(array($operation, 'run'), $args);
}
$class = '\\GenPHP\\Operation\\' . ucfirst($method) . 'Operation';
if (!class_exists($class)) {
spl_autoload_call($class);
}
if (class_exists($class)) {
$operation = new $class($this->self);
return call_user_func_array(array($operation, 'run'), $args);
} else {
throw new Exception("Operation class not found: {$class}");
}
}
示例13: load_library
public static function load_library($library)
{
// Primeiramente é necessário identificar se é uma classe no próprio módulo
// Para isto, o objeto deve iniciar com duplo underline
// Exemplo: __exemplo passará a ser site_exemplo_library
if (substr($library, 0, 2) === '__') {
// Se for, a informação é substituida pelo módulo
$library = join('_', core::get_caller_module_path()) . '_' . substr($library, 2);
}
// Anexa o sulfixo das bibliotecas
$library .= '_library';
// Se a classe já tiver sido carregada, evita o processo
if (isset(self::$_loaded_classes[$library])) {
return $library;
}
// Agora, é necessário carregar tal classe
spl_autoload_call($library);
// Salva em loaded classes e retorna
self::$_loaded_classes[$library] = true;
return $library;
}
示例14: this
/** Returns a checker or a converter for the given type. First checks for
one explicitly defined for the type, then attempts to load the class
specified by the type hint and checks again for an explicitly defined -er
for the type, then looks for a wildcard typehint defined to an enclosing
namespace if the type is namespaced, then finally gives up and returns
null.
The class load is so classes can self-register type hints, rather than
needing to maintain them all in this (or a specifically included) file,
which could easily become unweildy. Note however that merely autoloading
a subclass does not trip the autoloader for a parent class, and thus you
cannot rely on tripping the autoloader for wildcard typehints. */
protected function getErForType($kind, $type)
{
$array = $this->{"{$kind}ers"};
if (isset($array[$type])) {
return $array[$type];
}
// No explicit handler, trip the autoloader machinery then look for an
// explicit -er again
if (!class_exists($type, false) && !interface_exists($type, false) && !trait_exists($type, false)) {
spl_autoload_call($type);
if (isset($array[$type])) {
return $array[$type];
}
}
// Check for a whole-namespace -er
$namespaces = explode('\\', $type);
while (array_pop($namespaces) && count($namespaces)) {
$wildns = join('\\', $namespaces) . '\\*';
if (isset($array[$wildns])) {
return $array[$wildns];
}
}
return null;
}
示例15: sanitize
public function sanitize(&$data)
{
// manually trigger autoloading, as it's not done in some edge cases due to PHP bugs (see #60149)
if (!class_exists('Raven_Serializer')) {
spl_autoload_call('Raven_Serializer');
}
$data = Raven_Serializer::serialize($data);
}