本文整理汇总了PHP中get_parent_class函数的典型用法代码示例。如果您正苦于以下问题:PHP get_parent_class函数的具体用法?PHP get_parent_class怎么用?PHP get_parent_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_parent_class函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: classUses
/**
*
* @param mixed $class
* @param string $trait
* @param boolean $recursive
* @return boolean
*/
public static function classUses($class, $trait, $recursive = true)
{
if (!\is_object($class) && !\is_string($class)) {
return false;
}
$traits = \class_uses($class);
if ($recursive) {
$parent = \get_parent_class($class);
while ($parent !== false) {
$traits = \array_merge($traits, \class_uses($parent));
$parent = \get_parent_class($parent);
}
}
if (!is_array($trait)) {
$trait = (array) $trait;
}
foreach ($traits as $k => $t) {
if (\in_array($t, $trait)) {
return true;
}
if (self::classUses($t, $trait)) {
return true;
}
unset($traits[$k]);
}
return false;
}
示例2: _connectDB
/**
* Connect to database by using the given DSN string
*
* @author copied from PEAR::Auth, Martin Jansen, slightly modified
* @access private
* @param string DSN string
* @return mixed Object on error, otherwise bool
*/
function _connectDB($dsn)
{
// only include the db if one really wants to connect
require_once 'DB.php';
if (is_string($dsn) || is_array($dsn)) {
// put the dsn parameters in an array
// DB would be confused with an additional URL-queries, like ?table=...
// so we do it before connecting to the DB
if (is_string($dsn)) {
$dsn = DB::parseDSN($dsn);
}
$this->dbh = DB::Connect($dsn);
} else {
if (get_parent_class($dsn) == "db_common") {
$this->dbh = $dsn;
} else {
if (is_object($dsn) && DB::isError($dsn)) {
return new DB_Error($dsn->code, PEAR_ERROR_DIE);
} else {
return new PEAR_Error("The given dsn was not valid in file " . __FILE__ . " at line " . __LINE__, 41, PEAR_ERROR_RETURN, null, null);
}
}
}
if (DB::isError($this->dbh)) {
return new DB_Error($this->dbh->code, PEAR_ERROR_DIE);
}
return true;
}
示例3: merge
public function merge($input1, $input2, $output = 'object')
{
if (method_exists($this, 'toObject') && method_exists($this, 'toArray')) {
if (is_object($input1) && is_object($input2)) {
$ar1 = $this->toArray($input1);
$ar2 = $this->toArray($input2);
$result = array_merge($ar1, $ar2);
} elseif (is_object($input1) && is_array($input2)) {
$ar1 = $this->toArray($input1);
$result = array_merge($ar1, $input2);
} elseif (is_array($input1) && is_object($input2)) {
$ar2 = $this->toArray($input2);
$result = array_merge($input1, $ar2);
} elseif (is_array($input1) && is_array($input2)) {
$result = array_merge($input1, $input2);
}
if (isset($result)) {
return $output == 'object' ? $this->toObject($result) : $result;
} else {
throw new Exception(get_parent_class($this) . ' - SxCms_BaseMapper: merge failed! Incorrect $input1 and/or $input2');
return null;
}
} else {
throw new Exception(get_parent_class($this) . ' - SxCms_BaseMapper: methods toObject and toArray are required for merge!');
return null;
}
}
示例4: _beforeToHtml
protected function _beforeToHtml()
{
Mage::helper('wordpress')->log($this->__('%s has been deprecated; please use %s', get_class($this), get_parent_class($this)));
$this->setTemplate('wordpress/sidebar/widget/archives.phtml');
$this->setTitle($this->__('Archives'));
return parent::_beforeToHtml();
}
示例5: __construct
public function __construct($config = array())
{
// Only run this constructor on main library load
if (get_parent_class($this) !== FALSE) {
return;
}
foreach ($config as $key => $val) {
$this->{'_' . $key} = $val;
}
log_message('debug', 'Migrations class initialized');
// Are they trying to use migrations while it is disabled?
if ($this->_migration_enabled !== TRUE) {
show_error('Migrations has been loaded but is disabled or set up incorrectly.');
}
// If not set, set it
$this->_migration_path == '' and $this->_migration_path = APPPATH . 'migrations/';
// Add trailing slash if not set
$this->_migration_path = rtrim($this->_migration_path, '/') . '/';
// Load migration language
$this->lang->load('migration');
// They'll probably be using dbforge
$this->load->dbforge();
// If the migrations table is missing, make it
if (!$this->db->table_exists('migrations')) {
$this->dbforge->add_field(array('version' => array('type' => 'INT', 'constraint' => 3)));
$this->dbforge->create_table('migrations', TRUE);
$this->db->insert('migrations', array('version' => 0));
}
}
示例6: ADOdbDB
function ADOdbDB($libraryPath, $dbType, $preferredResType = ANYDB_RES_ASSOC)
{
$par = get_parent_class($this);
$this->{$par}($libraryPath, $dbType, $preferredResType);
$this->_id = 'ADODB';
require_once $this->_path . 'adodb.inc.php';
}
示例7: __wakeup
public function __wakeup()
{
$this->pluginLocator = \Magento\Framework\App\ObjectManager::getInstance();
$this->pluginList = $this->pluginLocator->get('Magento\\Framework\\Interception\\PluginList');
$this->chain = $this->pluginLocator->get('Magento\\Framework\\Interception\\Chain');
$this->subjectType = get_parent_class($this);
}
示例8: requireDefaultRecords
/**
* The process to automatically construct data object output configurations, executed on project build.
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Grab the list of data objects that have been completely removed.
foreach (DB::getConn()->tableList() as $table) {
// Delete existing output configurations for these data objects.
if (!class_exists($table)) {
$existing = DataObjectOutputConfiguration::get_one('DataObjectOutputConfiguration', "IsFor = '" . Convert::raw2sql($table) . "'");
$this->deleteConfiguration($table, $existing);
}
}
// Grab the list of all data object types, along with any inclusions/exclusions defined.
$objects = ClassInfo::subclassesFor('DataObject');
$inclusions = self::$custom_inclusions;
$exclusions = array_unique(array_merge(self::$exclusions, self::$custom_exclusions));
// Check existing output configurations for these data objects.
foreach ($objects as $object) {
$existing = DataObjectOutputConfiguration::get_one('DataObjectOutputConfiguration', "IsFor = '" . Convert::raw2sql($object) . "'");
// Delete existing output configurations for invalid data objects, or for those excluded.
if ($existing && (self::$disabled || get_parent_class($object) !== 'DataObject' || ClassInfo::classImplements($object, 'TestOnly') || count($inclusions) > 0 && !in_array($object, $inclusions) || count($inclusions) === 0 && in_array($object, $exclusions))) {
$this->deleteConfiguration($object, $existing);
} else {
if (!$existing && !self::$disabled && get_parent_class($object) === 'DataObject' && !ClassInfo::classImplements($object, 'TestOnly') && (count($inclusions) > 0 && in_array($object, $inclusions) || count($inclusions) === 0 && !in_array($object, $exclusions))) {
$this->addConfiguration($object);
}
}
}
}
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:31,代码来源:DataObjectOutputConfiguration.php
示例9: generate_inner_html
function generate_inner_html($links)
{
if (empty($links)) {
$this->sort_by = FALSE;
}
$inner_template = NULL;
switch ($this->mode) {
case SORT_BY:
$inner_template = PA::$blockmodule_path . '/' . (get_parent_class($this) ? get_parent_class($this) : get_class($this)) . '/cnmodule_sortby.php';
break;
default:
$inner_template = PA::$blockmodule_path . '/' . (get_parent_class($this) ? get_parent_class($this) : get_class($this)) . '/cnmodule.php';
}
$obj_inner_template = new Template($inner_template);
$obj_inner_template->set('links', $links);
$obj_inner_template->set('block_name', $this->html_block_id);
if (!empty($this->sort_by)) {
$obj_inner_template->set('sort_by', $this->sort_by);
$obj_inner_template->set('sorting_options', $this->sorting_options);
$obj_inner_template->set('selected_option', $this->selected_option);
}
$obj_inner_template->set('current_theme_path', PA::$theme_url);
$inner_html = $obj_inner_template->fetch();
return $inner_html;
}
示例10: prefix
public function prefix($model_prefix = null, $use_as_full = false)
{
// Se for uma string, é uma alteração de prefixo
if (is_string($model_prefix)) {
// Se precisar usar como prefixo completo, apenas altera
if ($use_as_full === true) {
$this->_prefix = $this->_prefix_full = $model_prefix;
} else {
$this->_prefix = $model_prefix;
$this->_prefix_full = $this->prefix() . $model_prefix;
}
} else {
// Se for necessário o prefixo completo (prefix())
if ($model_prefix !== false) {
// Se o prefixo completo não foi definido, define...
if ($this->_prefix_full === null) {
$parent_class = get_parent_class($this);
// Se o parent for um core_model, retorna null
if ($parent_class === 'core_model') {
return null;
}
// Se não, será necessário carregar a classe
$parent_class = self::_get_instance($parent_class);
$this->_prefix_full = $parent_class->prefix();
}
return $this->_prefix_full;
}
// Senão, retorna somente o prefixo (prefix(false))
return $this->_prefix;
}
}
示例11: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Place the tabs and actions blocks as various tests use them.
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('local_tasks_block');
// Collect admin permissions.
$class = get_class($this);
$adminPermissions = [];
while ($class) {
if (property_exists($class, 'adminPermissions')) {
$adminPermissions = array_merge($adminPermissions, $class::$adminPermissions);
}
$class = get_parent_class($class);
}
// Enable a random selection of 8 countries so we're not always
// testing with US and CA.
$countries = \Drupal::service('country_manager')->getAvailableList();
$country_ids = array_rand($countries, 8);
foreach ($country_ids as $country_id) {
// Don't use the country UI, we're not testing that here...
Country::load($country_id)->enable()->save();
}
// Last one of the 8 gets to be the store default country.
\Drupal::configFactory()->getEditable('uc_store.settings')->set('address.country', $country_id)->save();
// Create a store administrator user account.
$this->adminUser = $this->drupalCreateUser($adminPermissions);
// Create a test product.
$this->product = $this->createProduct(array('uid' => $this->adminUser->id(), 'promote' => 0));
}
示例12: __invoke
/**
* Render the output of a recommendation module.
*
* @param \VuFind\Recommend\RecommendInterface $recommend The recommendation
* object to render
*
* @return string
*/
public function __invoke($recommend)
{
// Set up the rendering context:
$contextHelper = $this->getView()->plugin('context');
$oldContext = $contextHelper($this->getView())->apply(['recommend' => $recommend]);
// Get the current recommendation module's class name, then start a loop
// in case we need to use a parent class' name to find the appropriate
// template.
$className = get_class($recommend);
$resolver = $this->getView()->resolver();
while (true) {
// Guess the template name for the current class:
$classParts = explode('\\', $className);
$template = 'Recommend/' . array_pop($classParts) . '.phtml';
if ($resolver->resolve($template)) {
// Try to render the template....
$html = $this->getView()->render($template);
$contextHelper($this->getView())->restore($oldContext);
return $html;
} else {
// If the template doesn't exist, let's see if we can inherit a
// template from a parent recommendation class:
$className = get_parent_class($className);
if (empty($className)) {
// No more parent classes left to try? Throw an exception!
throw new RuntimeException('Cannot find template for recommendation class: ' . get_class($recommend));
}
}
}
}
示例13: __construct
public function __construct(InputInterface $input, OutputInterface $output)
{
parent::__construct($input, $output);
$ref = new \ReflectionProperty(get_parent_class($this), 'lineLength');
$ref->setAccessible(true);
$ref->setValue($this, 120);
}
示例14: createTable
public function createTable($table, $fields = null, $indexes = null, $options = null, $advancedOptions = null)
{
$fieldSchemas = $indexSchemas = "";
if (!empty($options[self::ID])) {
$addOptions = $options[self::ID];
} elseif (!empty($options[get_class($this)])) {
Deprecation::notice('3.2', 'Use MySQLSchemaManager::ID for referencing mysql-specific table creation options');
$addOptions = $options[get_class($this)];
} elseif (!empty($options[get_parent_class($this)])) {
Deprecation::notice('3.2', 'Use MySQLSchemaManager::ID for referencing mysql-specific table creation options');
$addOptions = $options[get_parent_class($this)];
} else {
$addOptions = "ENGINE=InnoDB";
}
if (!isset($fields['ID'])) {
$fields['ID'] = "int(11) not null auto_increment";
}
if ($fields) {
foreach ($fields as $k => $v) {
$fieldSchemas .= "\"{$k}\" {$v},\n";
}
}
if ($indexes) {
foreach ($indexes as $k => $v) {
$indexSchemas .= $this->getIndexSqlDefinition($k, $v) . ",\n";
}
}
// Switch to "CREATE TEMPORARY TABLE" for temporary tables
$temporary = empty($options['temporary']) ? "" : "TEMPORARY";
$this->query("CREATE {$temporary} TABLE \"{$table}\" (\n\t\t\t\t{$fieldSchemas}\n\t\t\t\t{$indexSchemas}\n\t\t\t\tprimary key (ID)\n\t\t\t) {$addOptions}");
return $table;
}
示例15: fillClassInstance
private function fillClassInstance($instance, $data)
{
$instantiator = $this;
$valueProcessor = function ($value) use(&$valueProcessor, $instantiator) {
if ($value instanceof ArrayedObject) {
$value = $instantiator->instantiate($value);
}
if (is_array($value)) {
foreach ($value as &$innerValue) {
$innerValue = $valueProcessor($innerValue);
}
}
return $value;
};
$setObjectVarsClosure = function ($data, $class, &$valueProcessor) {
foreach ($data as $property => $value) {
if (property_exists($class, $property)) {
$value = $valueProcessor($value);
$this->{$property} = $value;
}
}
};
$class = get_class($instance);
do {
$bindedSetObjectVarsClosure = \Closure::bind($setObjectVarsClosure, $instance, $class);
$bindedSetObjectVarsClosure($data, $class, $valueProcessor);
} while ($class = get_parent_class($class));
}