本文整理汇总了PHP中class_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP class_exists函数的具体用法?PHP class_exists怎么用?PHP class_exists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了class_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factory
/**
* 工厂, 创建操作各种数据库的对象.
*
* @param string|null $db_type 数据库类型, 如果传递 null 或者不传递则默认为 local RThink_Config 的
* db_type
* @param array $options 数据库配置参数
* @return object 操作相应数据库的对象
* @throws em_db_exception
*/
public static function factory($options, $db_type)
{
$adapter_name = ucfirst($db_type) . 'Adapter';
$class_name = 'RThink_Db_' . $adapter_name;
class_exists($class_name, false) || (require 'RThink/Db/' . $adapter_name . '.php');
return new $class_name($options);
}
示例2: __construct
/**
* Setup the config based on either the Configure::read() values
* or the PaypalIpnConfig in config/paypal_ipn_config.php
*
* Will attempt to read configuration in the following order:
* Configure::read('PaypalIpn')
* App::import() of config/paypal_ipn_config.php
* App::import() of plugin's config/paypal_ipn_config.php
*/
function __construct()
{
$this->config = Configure::read('PaypalIpn');
if (empty($this->config)) {
$importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php');
if (!class_exists('PaypalIpnConfig')) {
App::import($importConfig);
}
if (!class_exists('PaypalIpnConfig')) {
// Import from paypal plugin configuration
$importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php';
App::import($importConfig);
}
if (!class_exists('PaypalIpnConfig')) {
trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR);
}
if (!PHP5) {
$config =& new PaypalIpnConfig();
} else {
$config = new PaypalIpnConfig();
}
$vars = get_object_vars($config);
foreach ($vars as $property => $configuration) {
if (strpos($property, 'encryption_') === 0) {
$name = substr($property, 11);
$this->encryption[$name] = $configuration;
} else {
$this->config[$property] = $configuration;
}
}
}
parent::__construct();
}
示例3: init
/**
* Initialize the Cache Engine
*
* Called automatically by the cache frontend
* To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
*
* @param array $settings array of setting for the engine
* @return boolean True if the engine has been successfully initialized, false if not
*/
public function init($settings = array())
{
if (!class_exists('Memcache')) {
return false;
}
if (!isset($settings['prefix'])) {
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
}
$settings += array('engine' => 'Memcache', 'servers' => array('127.0.0.1'), 'compress' => false, 'persistent' => true);
parent::init($settings);
if ($this->settings['compress']) {
$this->settings['compress'] = MEMCACHE_COMPRESSED;
}
if (is_string($this->settings['servers'])) {
$this->settings['servers'] = array($this->settings['servers']);
}
if (!isset($this->_Memcache)) {
$return = false;
$this->_Memcache = new Memcache();
foreach ($this->settings['servers'] as $server) {
list($host, $port) = $this->_parseServerString($server);
if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) {
$return = true;
}
}
return $return;
}
return true;
}
示例4: __call
public function __call($s_method_name, $arr_arguments)
{
if (!method_exists($this, $s_method_name)) {
// если еще не имлементировали
$s_match = "";
$s_method_prefix = '';
$s_method_base = '';
$arr_matches = array();
$bSucc = preg_match("/[A-Z_]/", $s_method_name, $arr_matches);
if ($bSucc) {
$s_match = $arr_matches[0];
$i_match = strpos($s_method_name, $s_match);
$s_method_prefix = substr($s_method_name, 0, $i_match) . "/";
$s_method_base = substr($s_method_name, 0, $i_match + ($s_match === "_" ? 1 : 0));
}
$s_class_enter = "__" . $s_method_name;
// метод, общий для всех режимов
if (!class_exists($s_class_enter)) {
$s_entermethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . ".lib.php";
$this->__loadLib($s_entermethod_lib);
$this->__implement($s_class_enter);
}
$s_class_mode = "__" . $s_method_name . "_";
// метод, выбираемый в зависимости от режима
if (!class_exists($s_class_mode)) {
$s_modemethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . "_" . cmsController::getInstance()->getCurrentMode() . ".lib.php";
$this->__loadLib($s_modemethod_lib);
$this->__implement($s_class_mode);
}
}
return parent::__call($s_method_name, $arr_arguments);
}
示例5: create
/**
* Factory method that creates a cache object based on configuration
* @param $name Name of definitions handled by cache
* @param $config Instance of HTMLPurifier_Config
*/
public function create($type, $config)
{
$method = $config->get('Cache', 'DefinitionImpl');
if ($method === null) {
return new HTMLPurifier_DefinitionCache_Null($type);
}
if (!empty($this->caches[$method][$type])) {
return $this->caches[$method][$type];
}
if (isset($this->implementations[$method]) && class_exists($class = $this->implementations[$method], false)) {
$cache = new $class($type);
} else {
if ($method != 'Serializer') {
trigger_error("Unrecognized DefinitionCache {$method}, using Serializer instead", E_USER_WARNING);
}
$cache = new HTMLPurifier_DefinitionCache_Serializer($type);
}
foreach ($this->decorators as $decorator) {
$new_cache = $decorator->decorate($cache);
// prevent infinite recursion in PHP 4
unset($cache);
$cache = $new_cache;
}
$this->caches[$method][$type] = $cache;
return $this->caches[$method][$type];
}
示例6: addComplexType
/**
* Add a complex type by recursivly using all the class properties fetched via Reflection.
*
* @param string $type Name of the class to be specified
* @return string XSD Type for the given PHP type
*/
public function addComplexType($type)
{
if (!class_exists($type)) {
throw new \Zend\Soap\WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type));
}
$dom = $this->getContext()->toDomDocument();
$class = new \ReflectionClass($type);
$complexType = $dom->createElement('xsd:complexType');
$complexType->setAttribute('name', $type);
$all = $dom->createElement('xsd:all');
foreach ($class->getProperties() as $property) {
if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) {
/**
* @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
* node for describing other classes used as attribute types for current class
*/
$element = $dom->createElement('xsd:element');
$element->setAttribute('name', $property->getName());
$element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
$all->appendChild($element);
}
}
$complexType->appendChild($all);
$this->getContext()->getSchema()->appendChild($complexType);
$this->getContext()->addType($type);
return "tns:{$type}";
}
示例7: tearDown
/**
* Run after the test.
*
* @return void
*/
public function tearDown()
{
if (class_exists('Mockery')) {
Mockery::close();
}
Container::getInstance()->flush();
}
示例8: plgAcymailingContentplugin
function plgAcymailingContentplugin(&$subject, $config)
{
parent::__construct($subject, $config);
if (!isset($this->params)) {
$plugin = JPluginHelper::getPlugin('acymailing', 'contentplugin');
$this->params = new acyParameter($plugin->params);
}
$this->paramsContent = JComponentHelper::getParams('com_content');
JPluginHelper::importPlugin('content');
$this->dispatcherContent = JDispatcher::getInstance();
$excludedHandlers = array('plgContentEmailCloak', 'pluginImageShow');
$excludedNames = array('system' => array('SEOGenerator', 'SEOSimple'), 'content' => array('webeecomment', 'highslide', 'smartresizer', 'phocagallery'));
$excludedType = array_keys($excludedNames);
if (!ACYMAILING_J16) {
foreach ($this->dispatcherContent->_observers as $id => $observer) {
if (is_array($observer) and in_array($observer['handler'], $excludedHandlers)) {
$this->dispatcherContent->_observers[$id]['event'] = '';
} elseif (is_object($observer)) {
if (in_array($observer->_type, $excludedType) and in_array($observer->_name, $excludedNames[$observer->_type])) {
$this->dispatcherContent->_observers[$id] = null;
}
}
}
}
if (!class_exists('JSite')) {
include_once ACYMAILING_ROOT . 'includes' . DS . 'application.php';
}
}
示例9: output
public function output(Pagemill_Data $data, Pagemill_Stream $stream)
{
//$inner = $data->parseVariables($this->rawOutput(), false);
$tmp = new Pagemill_Stream(true);
foreach ($this->children() as $child) {
$child->process($data, $tmp);
}
$inner = html_entity_decode($tmp->peek(), ENT_COMPAT, 'UTF-8');
$data->set('value', $inner);
$use = $data->parseVariables($this->getAttribute('use'));
if ($use) {
// Use the requested editor if available
if (class_exists($use)) {
if (is_subclass_of($use, __CLASS__)) {
$sub = new $use($this->name(), $this->attributes(), $this, $this->docType());
$sub->output($data, $stream);
return;
} else {
trigger_error("Requested editor class '{$cls}' does not appear to be an editor subclass.");
}
} else {
trigger_error("Requested editor class '{$cls}' does not exist.");
}
}
if (TYPEF_DEFAULT_EDITOR != '') {
// Use the requested editor if available
$use = TYPEF_DEFAULT_EDITOR;
if (class_exists($use)) {
if (is_subclass_of($use, __CLASS__)) {
$sub = new $use($this->name(), $this->attributes(), $this, $this->docType());
$sub->output($data, $stream);
return;
} else {
trigger_error("Configured editor class '{$use}' does not appear to be an editor subclass.");
}
} else {
trigger_error("Configured editor class '{$use}' does not exist.");
}
}
// Use CKEditor if available
if (class_exists('Typeframe_Tag_Editor_CkEditor')) {
$sub = new Typeframe_Tag_Editor_CkEditor($this->name(), $this->attributes(), $this, $this->docType());
$sub->process($data, $stream);
return;
}
// No editor available. Use a plain textarea.
$attribs = '';
foreach ($this->attributes() as $k => $v) {
if ($k != 'use') {
$attribs .= " {$k}=\"" . $data->parseVariables($v) . "\"";
}
}
if (!$this->getAttribute('cols')) {
$attribs .= ' cols="80"';
}
if (!$this->getAttribute('rows')) {
$attribs .= ' rows="25"';
}
$stream->puts("<textarea{$attribs}>" . $inner . "</textarea>");
}
示例10: setUp
protected function setUp()
{
parent::setUp();
if (!class_exists('Imagick')) {
$this->markTestSkipped('Imagick is not installed');
}
}
示例11: DOMImplementation
/**
* Create a new XML document.
* If $url is set, the DOCTYPE definition is treated as a PUBLIC
* definition; $dtd should contain the ID, and $url should contain the
* URL. Otherwise, $dtd should be the DTD name.
*/
function &createDocument($type, $dtd, $url = null)
{
$version = '1.0';
if (class_exists('DOMImplementation')) {
// Use the new (PHP 5.x) DOM
$impl =& new DOMImplementation();
// only generate a DOCTYPE if type is non-empty
if ($type != '') {
$domdtd = $impl->createDocumentType($type, isset($url) ? $dtd : '', isset($url) ? $url : $dtd);
$doc = $impl->createDocument($version, '', $domdtd);
} else {
$doc = $impl->createDocument($version, '');
}
// ensure we are outputting UTF-8
$doc->encoding = 'UTF-8';
} else {
// Use the XMLNode class
$doc =& new XMLNode();
$doc->setAttribute('version', $version);
$doc->setAttribute('type', $type);
$doc->setAttribute('dtd', $dtd);
$doc->setAttribute('url', $url);
}
return $doc;
}
示例12: factory
/**
* create a new adapter switch IDp name or ID
*
* @param string $id The id or name of the IDp
* @param array $params (optional) required parameters by the adapter
*/
function factory($id, $params = NULL)
{
Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::factory( {$id} )");
# init the adapter config and params
$this->id = $id;
$this->params = $params;
$this->id = $this->getProviderCiId($this->id);
$this->config = $this->getConfigById($this->id);
# check the IDp id
if (!$this->id) {
throw new Exception("No provider ID specified.", 2);
}
# check the IDp config
if (!$this->config) {
throw new Exception("Unknown Provider ID, check your configuration file.", 3);
}
# check the IDp adapter is enabled
if (!$this->config["enabled"]) {
throw new Exception("The provider '{$this->id}' is not enabled.", 3);
}
# include the adapter wrapper
if (isset($this->config["wrapper"]) && is_array($this->config["wrapper"])) {
require_once $this->config["wrapper"]["path"];
if (!class_exists($this->config["wrapper"]["class"])) {
throw new Exception("Unable to load the adapter class.", 3);
}
$this->wrapper = $this->config["wrapper"]["class"];
} else {
require_once Hybrid_Auth::$config["path_providers"] . $this->id . ".php";
$this->wrapper = "Hybrid_Providers_" . $this->id;
}
# create the adapter instance, and pass the current params and config
$this->adapter = new $this->wrapper($this->id, $this->config, $this->params);
return $this;
}
示例13: getModelForBean
public function getModelForBean(OODBBean $bean)
{
$model = $bean->getMeta("type");
$prefix = $this->defaultNamespace;
$typeMap = $this->typeMap;
if (isset($typeMap[$model])) {
$modelName = $typeMap[$model];
} else {
if (strpos($model, '_') !== FALSE) {
$modelParts = explode('_', $model);
$modelName = '';
foreach ($modelParts as $part) {
$modelName .= ucfirst($part);
}
$modelName = $prefix . $modelName;
if (!class_exists($modelName)) {
//second try
$modelName = $prefix . ucfirst($model);
if (!class_exists($modelName)) {
return NULL;
}
}
} else {
$modelName = $prefix . ucfirst($model);
if (!class_exists($modelName)) {
return NULL;
}
}
}
$obj = self::factory($modelName);
$obj->loadBean($bean);
return $obj;
}
示例14: create
private static function create($str, $type)
{
if (!class_exists($type)) {
throw new PPP_Token_UnrecognizedTokenException($type);
}
return new $type($str);
}
示例15: controller_render
function controller_render($name, $action)
{
if (!$name) {
$name = 'default';
}
$name = strtolower($name);
$ret = preg_match('/(^[a-z][a-z]*?[a-z]$)/', $name);
if ($ret <= 0) {
return '控制器名称非法' . $ret . $name;
}
$path = _ROOT . 'controller/' . $name . '.php';
if (!file_exists($path)) {
return '控制器不存在';
}
include_once $path;
$classname = $name . 'Controller';
if (!class_exists($classname)) {
return '控制器声明不完全';
}
$o = new $classname();
if (!method_exists($o, 'render')) {
return '控制器未继承BaseController::Render';
}
define('BASE_CONTROLLER', $name);
return call_user_method('render', $o, $action);
}