Пример #1
0
 /**
  * 
  * @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;
 }
 /**
  * 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
0
 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
0
 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();
 }
 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
0
 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';
 }
 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);
 }
 /**
  *	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);
             }
         }
     }
 }
 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
0
 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
0
 /**
  * {@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
0
 /**
  * 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
0
 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);
 }
 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;
 }
 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));
 }
Пример #16
0
 public function __construct()
 {
     if (get_parent_class()) {
         parent::__construct();
     }
     $this->callMethod('api_');
 }
Пример #17
0
 private function format_controller_methods($path, $file)
 {
     $this->load->helper("url");
     $controller = array();
     // only show php files
     if (($extension = substr($file, strrpos($file, ".") + 1)) == "php") {
         // include the class
         include_once $path . "/" . $file;
         $parts = explode(".", $file);
         $class_lower = $parts["0"];
         $class = ucfirst($class_lower);
         // check if a class actually exists
         if (class_exists($class) and get_parent_class($class) == "MY_Controller") {
             // get a list of all methods
             $controller["name"] = $class;
             $controller["path"] = base_url() . $class_lower;
             $controller["methods"] = array();
             // get a list of all public methods
             foreach (get_class_methods($class) as $method) {
                 $reflect = new ReflectionMethod($class, $method);
                 if ($reflect->isPublic()) {
                     // ignore some methods
                     $object = new $class();
                     if (!in_array($method, $object->internal_methods)) {
                         $method_array = array();
                         $method_array["name"] = $method;
                         $method_array["path"] = base_url() . $class_lower . "/" . $method;
                         $controller["methods"][] = $method_array;
                     }
                 }
             }
         }
     }
     return $controller;
 }
Пример #18
0
 /**
  * Saves any current addresses to session
  */
 public function __destruct()
 {
     Mage::getSingleton('avatax/session')->setAddresses($this->_cache);
     if (method_exists(get_parent_class(), '__destruct')) {
         parent::__destruct();
     }
 }
 public function setEntity($entity)
 {
     $this->entity = $entity;
     $this->metaData = $this->manager->getClassMetadata($entity)->getMetadata()[0];
     $parent = get_parent_class($this->metaData->rootEntityName);
     $this->parentMetaData = $this->manager->getClassMetadata($parent)->getMetadata()[0];
 }
Пример #20
0
 /**
  * @param EntityConfigEvent $event
  */
 public function updateEntity(EntityConfigEvent $event)
 {
     $className = $event->getClassName();
     $parentClassName = get_parent_class($className);
     if (!$parentClassName) {
         return;
     }
     if (ExtendHelper::isExtendEntityProxy($parentClassName)) {
         // When application is installed parent class will be replaced (via class_alias)
         $extendClass = $parentClassName;
     } else {
         // During install parent class is not replaced (via class_alias)
         $shortClassName = ExtendHelper::getShortClassName($className);
         if (ExtendHelper::getShortClassName($parentClassName) !== 'Extend' . $shortClassName) {
             return;
         }
         $extendClass = ExtendHelper::getExtendEntityProxyClassName($parentClassName);
     }
     $configManager = $event->getConfigManager();
     $config = $configManager->getProvider('extend')->getConfig($className);
     $hasChanges = false;
     if (!$config->is('is_extend')) {
         $config->set('is_extend', true);
         $hasChanges = true;
     }
     if (!$config->is('extend_class', $extendClass)) {
         $config->set('extend_class', $extendClass);
         $hasChanges = true;
     }
     if ($hasChanges) {
         $configManager->persist($config);
     }
 }
Пример #21
0
 public function __construct($passName)
 {
     if (get_parent_class($passName) != 'SandboxedPass') {
         throw new Exception($passName . ' is not a sandboxed pass (SandboxedPass)');
     }
     $this->passes = ['ExternalPass' => new $passName()];
 }
Пример #22
0
 /**
  * Launch the method that which call was replaced by the advice
  *
  * @param $args mixed The arguments the original method was expected to receive
  * @return mixed
  */
 public function process($args = null)
 {
     if ($this->class_name == get_class($this->pointcut[0]) && $this->process_method == $this->pointcut[1]) {
         $method = new ReflectionMethod(get_parent_class($this->class_name), $this->process_method);
     } else {
         $method = new ReflectionMethod($this->class_name, $this->process_method);
     }
     // the method must be accessible to invoke it
     if (!$method->isPublic()) {
         $not_accessible = true;
         $method->setAccessible(true);
     }
     // if this is a static method : invoked object is null
     $object = $this->pointcut[0];
     if (!is_object($object)) {
         $object = null;
     }
     // invoke
     if (func_num_args()) {
         $result = $method->invokeArgs($object, func_get_args());
     } elseif ($this->parameters) {
         $parameters = array_slice($this->parameters, 0, count($this->parameters) / 2);
         $result = $method->invokeArgs($object, $parameters);
     } else {
         $result = $method->invoke($object);
     }
     // the method must be not accessible again
     if (isset($not_accessible)) {
         $method->setAccessible(false);
     }
     return $result;
 }
Пример #23
0
 public function getEntityClass()
 {
     if ($this instanceof \Doctrine\ORM\Proxy\Proxy) {
         return get_parent_class($this);
     }
     return get_class($this);
 }
Пример #24
0
 /**
  * Creates a statistics page.
  *
  * @param $pageName string Name of the page
  * @return StatisticsPage Object of type dependant on the name specified.
  */
 public static function Create($pageName)
 {
     // calculate the name of the statistics page
     $statsPage = "Stats" . $pageName;
     global $filepath;
     // check the stats page definition exists...
     if (file_exists($filepath . "/includes/statistics/Stats" . $pageName . ".php")) {
         // and include it.
         require_once $filepath . "/includes/statistics/Stats" . $pageName . ".php";
     } else {
         // class def doesn't exist: error
         die("Unknown statistics page: " . $statsPage);
     }
     // ok, so the file where the class def should be exists, but we need to check the class
     // itself exists.
     if (class_exists($statsPage)) {
         // the class exists, all is ok.
         // create the stats page object
         $object = new $statsPage();
         // check the newly created object has inherits from StatisticsPage class
         if (get_parent_class($object) == "StatisticsPage") {
             // all is good, return the new statistics page object
             return $object;
         } else {
             // oops. this is our class, named correctly, but it's a bad definition.
             die("Unrecognised statistics page definition.");
         }
     } else {
         // file exists, but no definition of the class
         die("No definition for statistics page: " . $statsPage);
     }
 }
 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     // prepare value
     if ($this->_operator === 'equals' && empty($this->_value)) {
         // @see 0009362: allow to filter for empty datetimes
         $operator = 'isnull';
         $value = array($this->_value);
     } else {
         $operator = $this->_operator;
         $value = $this->_getDateValues($operator, $this->_value);
         if (!is_array($value)) {
             // NOTE: (array) null is an empty array
             $value = array($value);
         }
     }
     // quote field identifier
     $field = $this->_getQuotedFieldName($_backend);
     $db = Tinebase_Core::getDb();
     $dbCommand = Tinebase_Backend_Sql_Command::factory($db);
     // append query to select object
     foreach ((array) $this->_opSqlMap[$operator]['sqlop'] as $num => $operator) {
         if (isset($value[$num]) || array_key_exists($num, $value)) {
             if (get_parent_class($this) === 'Tinebase_Model_Filter_Date' || in_array($operator, array('isnull', 'notnull'))) {
                 $_select->where($field . $operator, $value[$num]);
             } else {
                 $_select->where($dbCommand->setDate($field) . $operator, new Zend_Db_Expr($dbCommand->setDateValue($value[$num])));
             }
         } else {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' No filter value found, skipping operator: ' . $operator);
             }
         }
     }
 }
Пример #26
0
 function findTemplate($view)
 {
     static $tplCache = array();
     if (isset($tplCache[$this->type][$view])) {
         return $tplCache[$this->type][$view];
     }
     $lastClass = get_class($this);
     $classList = array($this->type, str_replace('SugarField', '', $lastClass));
     while ($lastClass = get_parent_class($lastClass)) {
         $classList[] = str_replace('SugarField', '', $lastClass);
     }
     array_pop($classList);
     // remove this class - $base handles that
     $tplName = '';
     global $current_language;
     foreach ($classList as $className) {
         if (isset($current_language)) {
             $tplName = SugarAutoLoader::existingCustomOne('include/SugarFields/Fields/' . $className . '/' . $current_language . '.' . $view . '.tpl');
             if ($tplName) {
                 break;
             }
         }
         $tplName = SugarAutoLoader::existingCustomOne('include/SugarFields/Fields/' . $className . '/' . $view . '.tpl');
         if ($tplName) {
             break;
         }
     }
     if (empty($tplName)) {
         $tplName = $this->getBase($view);
     }
     $tplCache[$this->type][$view] = $tplName;
     return $tplName;
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->registerClassAutoloadExceptions();
     $bindings = array();
     foreach ($this->getAbstracts() as $abstract) {
         // Validator and seeder cause problems
         if (in_array($abstract, ['validator', 'seeder'])) {
             continue;
         }
         try {
             $concrete = $this->laravel->make($abstract);
             if (is_object($concrete)) {
                 $class = get_class($concrete);
                 if (strpos($class, 'Proxy_') === 0) {
                     $class = get_parent_class($class);
                 }
                 $bindings[$abstract] = $class;
             }
         } catch (\Exception $e) {
             if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                 $this->comment("Cannot make '{$abstract}': " . $e->getMessage());
             }
         }
     }
     $content = $this->view->make('ide-helper::meta', ['bindings' => $bindings, 'methods' => $this->methods])->render();
     $filename = $this->option('filename');
     $written = $this->files->put($filename, $content);
     if ($written !== false) {
         $this->info("A new meta file was written to {$filename}");
     } else {
         $this->error("The meta file could not be created at {$filename}");
     }
 }
 function __construct()
 {
     parent::__construct('EbatNs_RequestHeaderType', 'urn:ebay:apis:eBLBaseComponents');
     if (!isset(self::$_elements[__CLASS__])) {
         self::$_elements[__CLASS__] = array_merge(self::$_elements[get_parent_class()], array('RequesterCredentials' => array('required' => true, 'type' => 'EbatNs_RequesterCredentialType', 'nsURI' => 'http://www.w3.org/2001/XMLSchema')));
     }
 }
Пример #29
0
 /**
  * contructor, creates node with reference to record and any options
  *
  * @param object $record                    instance of Doctrine_Record
  * @param array $options                    options
  */
 public function __construct(Doctrine_Record $record, $options)
 {
     $this->record = $record;
     $this->options = $options;
     // Make sure that the tree object of the root class is used in the case
     // of column aggregation inheritance (single table inheritance).
     $class = $record->getTable()->getComponentName();
     $thisTable = $record->getTable();
     $table = $thisTable;
     if ($thisTable->getOption('inheritanceMap')) {
         // Move up the hierarchy until we find the "subclasses" option. This option
         // MUST be set on the root class of the user's hierarchy that uses STI.
         while (!($subclasses = $table->getOption('subclasses'))) {
             $class = get_parent_class($class);
             $reflectionClass = new ReflectionClass($class);
             if ($reflectionClass->isAbstract()) {
                 continue;
             }
             if ($class == 'Doctrine_Record') {
                 throw new Doctrine_Node_Exception("No subclasses specified. You are " . "using Single Table Inheritance with NestedSet but you have " . "not specified the subclasses correctly. Make sure you use " . "setSubclasses() in the root class of your hierarchy.");
             }
             $table = $table->getConnection()->getTable($class);
         }
     }
     if ($thisTable !== $table) {
         $this->_tree = $table->getTree();
     } else {
         $this->_tree = $thisTable->getTree();
     }
 }
Пример #30
0
 /**
  * Create test views from config.
  *
  * @param string $class
  *   The name of the test class. Installs the listed test views *in order*.
  * @param array $modules
  *   The module directories to look in for test views.
  */
 public static function createTestViews($class, array $modules)
 {
     $views = array();
     while ($class) {
         if (property_exists($class, 'testViews')) {
             $views = array_merge($views, $class::$testViews);
         }
         $class = get_parent_class($class);
     }
     if (!empty($views)) {
         $storage = \Drupal::entityManager()->getStorage('view');
         $module_handler = \Drupal::moduleHandler();
         foreach ($modules as $module) {
             $config_dir = drupal_get_path('module', $module) . '/test_views';
             if (!is_dir($config_dir) || !$module_handler->moduleExists($module)) {
                 continue;
             }
             $file_storage = new FileStorage($config_dir);
             $available_views = $file_storage->listAll('views.view.');
             foreach ($views as $id) {
                 $config_name = 'views.view.' . $id;
                 if (in_array($config_name, $available_views)) {
                     $storage->create($file_storage->read($config_name))->save();
                 }
             }
         }
     }
     // Rebuild the router once.
     \Drupal::service('router.builder')->rebuild();
 }