當前位置: 首頁>>代碼示例>>PHP>>正文


PHP spl_autoload_call函數代碼示例

本文整理匯總了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);
 }
開發者ID:badlamer,項目名稱:hhvm,代碼行數:7,代碼來源:spl_autoload_call_reentry.php

示例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);
 }
開發者ID:seven07ve,項目名稱:vendorepuestos,代碼行數:36,代碼來源:sfAutoloadAgain.class.php

示例3: autoLoadAnnotation

 public static function autoLoadAnnotation()
 {
     if (!self::$annotationIsLoad) {
         foreach (self::$annotationList as $annotation) {
             spl_autoload_call(self::$annotationPackage . $annotation);
         }
         self::$annotationIsLoad = true;
     }
 }
開發者ID:toshy62,項目名稱:openldapobject,代碼行數:9,代碼來源:AnnotationManager.php

示例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();
 }
開發者ID:corneltek,項目名稱:universal,代碼行數:9,代碼來源:BasePathClassLoaderTest.php

示例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);
    }
開發者ID:corneltek,項目名稱:formkit,代碼行數:11,代碼來源:ResponseUtilsTest.php

示例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;
     }
 }
開發者ID:openldapobject,項目名稱:openldapobject,代碼行數:12,代碼來源:AnnotationManager.php

示例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);
             }
         }
     });
 }
開發者ID:seytar,項目名稱:psx,代碼行數:12,代碼來源:Bootstrap.php

示例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;
     }
 }
開發者ID:openldapobject,項目名稱:openldapobject,代碼行數:14,代碼來源:GenerateCommand.php

示例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);
     }
 }
開發者ID:ppiedaderawnet,項目名稱:concrete5,代碼行數:19,代碼來源:AliasClassLoader.php

示例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;
 }
開發者ID:00victor00,項目名稱:WeLearn,代碼行數:61,代碼來源:AbstractDAOFactory.php

示例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);
         }
     });
 }
開發者ID:ceko,項目名稱:concrete5-1,代碼行數:25,代碼來源:ClassLoader.php

示例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}");
     }
 }
開發者ID:ravenscroftj,項目名稱:GenPHP,代碼行數:18,代碼來源:OperationMixin.php

示例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;
 }
開發者ID:rentalhost,項目名稱:core,代碼行數:21,代碼來源:core_caller.php

示例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;
 }
開發者ID:bettrlife,項目名稱:elephander,代碼行數:36,代碼來源:TypeHintHandler.php

示例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);
 }
開發者ID:anthonyryan1,項目名稱:raven-php,代碼行數:8,代碼來源:Client.php


注:本文中的spl_autoload_call函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。