Пример #1
0
 /**
  *
  * @throws \Exception
  * @return boolean
  */
 public function connect()
 {
     $this->session = ssh2_connect($this->config->host, $this->config->port);
     if (false === $this->session) {
         throw new \Exception("Echec de la connexion ssh " . print_r($this->config->toArray(), true));
     }
     $auth = ssh2_auth_pubkey_file($this->session, $this->config->username, $this->config->pubkeyfile, $this->config->privkeyfile);
     if (true !== $auth) {
         throw new \Exception("Echec de l'authentification ssh " . print_r($this->config->toArray(), true));
     }
     return true;
 }
Пример #2
0
 /**
  * @return DocumentManager
  */
 public function getDocumentManager()
 {
     $factory = new DocumentManagerFactory();
     $sm = Bootstrap::getServiceManager();
     $sm->setAllowOverride(true);
     $config = $sm->get('Config');
     $c = new Config(['eoko' => ['odm' => ['hydrator' => ['class' => 'Zend\\Stdlib\\Hydrator\\ClassMethods', 'strategies' => ['Eoko\\ODM\\Metadata\\Annotation\\DateTime' => new DateTimeFormatterStrategy()]]]]]);
     $c->merge(new Config($config));
     $sm->setService('Config', $c->toArray());
     return $factory->createService($sm);
 }
Пример #3
0
 /**
  * Merges the app config with the siteaccess config
  */
 public function init()
 {
     // Add siteaccess specific config
     $configHandler = new Config($this->serviceManager->get('config'));
     $configHandler->merge($this->addConfig());
     $this->serviceManager->setAllowOverride(true);
     $this->serviceManager->setService('config', $configHandler->toArray());
     $this->serviceManager->setAllowOverride(false);
     // not needed I think
     #$this->baseXMSServices->setService( 'siteaccess', $this );
 }
 /**
  * Process
  *
  * @param  Config $config
  * @return Config
  * @throws InvalidArgumentException
  */
 public function process(Config $config)
 {
     $data = $config->toArray();
     array_walk_recursive($data, function (&$value, $key) {
         if (preg_match('/callable\\((.*)\\)/', $value, $matches)) {
             list($class, $method) = array_map('trim', explode(',', $matches[1]));
             $value = [new $class(), $method];
         }
     });
     return new Config($data, true);
 }
Пример #5
0
 /**
  * Get an array of strings representing formats in which a specified record's
  * data may be exported (empty if none).  Legal values: "BibTeX", "EndNote",
  * "MARC", "MARCXML", "RDF", "RefWorks".
  *
  * @param \VuFind\RecordDriver\AbstractBase $driver Record driver
  *
  * @return array Strings representing export formats.
  */
 public function getFormatsForRecord($driver)
 {
     // Get an array of enabled export formats (from config, or use defaults
     // if nothing in config array).
     $active = isset($this->mainConfig->Export) ? $this->mainConfig->Export->toArray() : ['RefWorks' => true, 'EndNote' => true];
     // Loop through all possible formats:
     $formats = [];
     foreach (array_keys($this->exportConfig->toArray()) as $format) {
         if (isset($active[$format]) && $active[$format] && $this->recordSupportsFormat($driver, $format)) {
             $formats[] = $format;
         }
     }
     // Send back the results:
     return $formats;
 }
Пример #6
0
 /**
  * Get an array of strings representing formats in which a specified record's
  * data may be exported (empty if none).  Legal values: "BibTeX", "EndNote",
  * "MARC", "MARCXML", "RDF", "RefWorks".
  *
  * @param \VuFind\RecordDriver\AbstractBase $driver Record driver
  *
  * @return array Strings representing export formats.
  */
 public function getFormatsForRecord($driver)
 {
     // Get an array of enabled export formats (from config, or use defaults
     // if nothing in config array).
     $active = $this->getActiveFormats('record');
     // Loop through all possible formats:
     $formats = [];
     foreach (array_keys($this->exportConfig->toArray()) as $format) {
         if (in_array($format, $active) && $this->recordSupportsFormat($driver, $format)) {
             $formats[] = $format;
         }
     }
     // Send back the results:
     return $formats;
 }
Пример #7
0
 public function init(ServiceLocatorInterface $serviceLocator)
 {
     $application = $serviceLocator->get('application');
     // Add siteaccess specific config
     $configHandler = new Config($application->getConfig());
     $configHandler->merge($this->addConfig());
     //TODO: avoid config in context of the siteaccess
     $this->config = $configHandler->toArray();
     $application->getServiceManager()->setService('accumulator', new Accumulator());
     $application->getServiceManager()->setFactory('xmldb', 'BaseXMS\\BaseXFactory');
     //TODO: remove all references to baseXMSServices
     $this->baseXMSServices = $application->getServiceManager();
     // not needed I think
     #$this->baseXMSServices->setService( 'siteaccess', $this );
 }
Пример #8
0
 /**
  * @throws \ErrorException
  *
  * @return array
  */
 public function getNavigation()
 {
     try {
         $navigationDefinition = Factory::fromFile($this->rootNavigationFile, true);
     } catch (\Exception $e) {
         $navigationDefinition = new Config([]);
     }
     foreach ($this->navigationSchemaFinder->getSchemaFiles() as $moduleNavigationFile) {
         if (!file_exists($moduleNavigationFile->getPathname())) {
             throw new ErrorException('Navigation-File does not exist: ' . $moduleNavigationFile);
         }
         $configFromFile = Factory::fromFile($moduleNavigationFile->getPathname(), true);
         $navigationDefinition->merge($configFromFile);
     }
     return $navigationDefinition->toArray();
 }
Пример #9
0
 /**
  * Substitute defined variables, if any found and return the new configuration object
  *
  * @param Config $config
  * @param string $prefix
  * @param string $suffix
  * @return Config
  */
 protected function substituteVars(Config $config, $prefix = '{', $suffix = '}')
 {
     $arrayConfig = $config->toArray();
     if (isset($arrayConfig['variables'])) {
         $vars = array_map(function ($x) use($prefix, $suffix) {
             return $prefix . $x . $suffix;
         }, array_keys($arrayConfig['variables']));
         $vals = array_values($arrayConfig['variables']);
         $tokens = array_combine($vars, $vals);
         $processor = new Token();
         $processor->setTokens($tokens);
         $processor->process($config);
         // Remove variables node
         unset($config->variables);
     }
     return $config;
 }
Пример #10
0
 /**
  * 构造函数
  *
  * @param Config $config            
  * @param string $collection            
  * @param string $database            
  * @param string $cluster            
  * @param string $collectionOptions            
  * @throws \Exception
  */
 public function __construct(Config $config, $collection = null, $database = DEFAULT_DATABASE, $cluster = DEFAULT_CLUSTER, $collectionOptions = null)
 {
     // 检测是否加载了FirePHP
     if (!class_exists("FirePHP")) {
         throw new \Exception('请安装FirePHP');
     }
     if (!class_exists("MongoClient")) {
         throw new \Exception('请安装MongoClient');
     }
     if ($collection === null) {
         throw new \Exception('$collection集合为空');
     }
     $this->_collection = $collection;
     $this->_database = $database;
     $this->_cluster = $cluster;
     $this->_collectionOptions = $collectionOptions;
     $this->_configInstance = $config;
     $this->_config = $config->toArray();
     if (!isset($this->_config[$this->_cluster])) {
         throw new \Exception('Config error:no cluster key');
     }
     if (!isset($this->_config[$this->_cluster]['dbs'][$this->_database])) {
         throw new \Exception('Config error:no database init');
     }
     if (!isset($this->_config[$this->_cluster]['dbs'][DB_ADMIN])) {
         throw new \Exception('Config error:admin database init');
     }
     if (!isset($this->_config[$this->_cluster]['dbs'][DB_BACKUP])) {
         throw new \Exception('Config error:backup database init');
     }
     if (!isset($this->_config[$this->_cluster]['dbs'][DB_MAPREDUCE])) {
         throw new \Exception('Config error:mapreduce database init');
     }
     $this->_db = $this->_config[$this->_cluster]['dbs'][$this->_database];
     if (!$this->_db instanceof \MongoDB) {
         throw new \Exception('$this->_db is not instanceof \\MongoDB');
     }
     $this->_admin = $this->_config[$this->_cluster]['dbs'][DB_ADMIN];
     if (!$this->_admin instanceof \MongoDB) {
         throw new \Exception('$this->_admin is not instanceof \\MongoDB');
     }
     $this->_backup = $this->_config[$this->_cluster]['dbs'][DB_BACKUP];
     if (!$this->_backup instanceof \MongoDB) {
         throw new \Exception('$this->_backup is not instanceof \\MongoDB');
     }
     $this->_mapreduce = $this->_config[$this->_cluster]['dbs'][DB_MAPREDUCE];
     if (!$this->_mapreduce instanceof \MongoDB) {
         throw new \Exception('$this->_mapreduce is not instanceof \\MongoDB');
     }
     $this->_fs = new \MongoGridFS($this->_db, GRIDFS_PREFIX);
     // 默认执行几个操作
     // 第一个操作,判断集合是否创建,如果没有创建,则进行分片处理(目前采用_ID作为片键)
     if (APPLICATION_ENV === 'production') {
         $this->shardingCollection();
     }
     parent::__construct($this->_db, $this->_collection);
     /**
      * 设定读取优先级
      * MongoClient::RP_PRIMARY 只读取主db
      * MongoClient::RP_PRIMARY_PREFERRED 读取主db优先
      * MongoClient::RP_SECONDARY 只读从db优先
      * MongoClient::RP_SECONDARY_PREFERRED 读取从db优先
      */
     // $this->db->setReadPreference(\MongoClient::RP_SECONDARY_PREFERRED);
     $this->db->setReadPreference(\MongoClient::RP_PRIMARY_PREFERRED);
 }
Пример #11
0
 public function testSetOptionsOmitsAccessorsRequiringObjectsOrMultipleParams()
 {
     $options = $this->getOptions();
     $config = new Config($options);
     $options['config'] = $config;
     $options['options'] = $config->toArray();
     $options['pluginLoader'] = true;
     $options['view'] = true;
     $options['translator'] = true;
     $options['attrib'] = true;
     $this->group->setOptions($options);
 }
Пример #12
0
 /**
  * Root elements that are not assigned to any section needs to be
  * on the top of config.
  * 
  * @see    http://framework.zend.com/issues/browse/ZF-6289
  * @param  Zend\Config
  * @return Zend\Config
  */
 protected function _sortRootElements(\Zend\Config\Config $config)
 {
     $configArray = $config->toArray();
     $sections = array();
     // remove sections from config array
     foreach ($configArray as $key => $value) {
         if (is_array($value)) {
             $sections[$key] = $value;
             unset($configArray[$key]);
         }
     }
     // readd sections to the end
     foreach ($sections as $key => $value) {
         $configArray[$key] = $value;
     }
     return new \Zend\Config\Config($configArray);
 }
Пример #13
0
 /**
  * Export config in a format to be stored to config file
  *
  * @param Config $config
  * @return string
  */
 private static function dumpConfig(Config $config)
 {
     return '<' . "?php\nreturn " . var_export($config->toArray(), 1) . ";\n";
 }
Пример #14
0
 public function testZF6995_toArrayDoesNotDisturbInternalIterator()
 {
     $config = new Config(range(1, 10));
     $config->rewind();
     $this->assertEquals(1, $config->current());
     $config->toArray();
     $this->assertEquals(1, $config->current());
 }
Пример #15
0
 /**
  * Return from element with system map tree
  * @return \Zly\Form\Element\Tree 
  */
 public function getMapTreeElement()
 {
     $sysmap = $this->getSysmap();
     $root = $this->getRoot();
     $root->name = 'Modules';
     $root->_childrens = $sysmap;
     $rootedSysmap = new Config($root->toArray(), true);
     $formElement = new \Zly\Form\Element\Tree('sysmap_id');
     $formElement->setValueKey('hash');
     $formElement->setTitleKey('name');
     $formElement->setChildrensKey('_childrens');
     $formElement->setMultiOptions(array($rootedSysmap->toArray()));
     return $formElement;
 }
Пример #16
0
 /**
  * 
  * @param Config $value
  * @return Config
  */
 public function process(Config $value)
 {
     return new Config($this->interpolator->interpolate($value->toArray(), $this->variables));
 }
Пример #17
0
<?php

set_include_path(realpath(dirname(__FILE__) . '/../../library'));
spl_autoload_register(function ($class) {
    require_once ltrim(str_replace('\\', '/', $class), '/') . '.php';
});
use Zend\Authentication\AuthenticationService;
$auth = new AuthenticationService();
use Zend\Config\Config;
$config = new Config(require_once 'config.php');
$options = $config->toArray();
use Zend\Oauth\Consumer as OauthConsumer;
$consumer = new OauthConsumer($options);
use Ja\Authentication\Adapter\Oauth as OauthAdapter;
$adapter = new OauthAdapter();
$adapter->setConsumer($consumer);
if (isset($_GET['oauth_token'])) {
    $adapter->setQueryData($_GET);
}
if ($auth->hasIdentity()) {
    header("Location: index.php");
}
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
    header('Location: index.php');
} else {
    echo "Error authenticating: " . implode('<br />', $result->getMessages());
}
Пример #18
0
 public function testSetOptionsSkipsCallsToSetOptionsAndSetConfig()
 {
     $options = $this->getOptions();
     $config = new Config($options);
     $options['config'] = $config;
     $options['options'] = $config->toArray();
     $this->form->setOptions($options);
 }
Пример #19
0
 /**
  * @depends testMerge
  * @link http://framework.zend.com/issues/browse/ZF2-186
  */
 public function testZF2_186_mergeReplacingUnnamedConfigSettings()
 {
     $arrayA = array('flag' => true, 'text' => 'foo', 'list' => array('a', 'b', 'c'), 'aSpecific' => 12);
     $arrayB = array('flag' => false, 'text' => 'bar', 'list' => array('d', 'e'), 'bSpecific' => 100);
     $mergeResult = array('flag' => false, 'text' => 'bar', 'list' => array('a', 'b', 'c', 'd', 'e'), 'aSpecific' => 12, 'bSpecific' => 100);
     $configA = new Config($arrayA);
     $configB = new Config($arrayB);
     $configA->merge($configB);
     // merge B onto A
     $this->assertEquals($mergeResult, $configA->toArray());
 }
Пример #20
0
 /**
  * {@inheritdoc}
  * @throws Exception\ErrorException
  */
 public function getSchemaConfig($table = null, $include_options = true)
 {
     $results = $this->executeQuery($table);
     $references = [];
     $config = new Config(['tables' => []], true);
     $tables = $config->offsetGet('tables');
     foreach ($results as $r) {
         // Setting table information
         $table_name = $r['table_name'];
         if (!$tables->offsetExists($table_name)) {
             $table_def = ['name' => $table_name, 'columns' => [], 'primary_keys' => [], 'unique_keys' => [], 'foreign_keys' => [], 'references' => [], 'indexes' => []];
             if ($include_options) {
                 $table_def['options'] = ['comment' => $r['table_comment'], 'collation' => $r['table_collation'], 'type' => $r['table_type'], 'engine' => $r['engine']];
             }
             $tables->offsetSet($table_name, $table_def);
         }
         $table = $tables->offsetGet($table_name);
         $columns = $table->columns;
         $column_name = $r['column_name'];
         $data_type = strtolower($r['data_type']);
         $col_def = ['type' => $data_type, 'primary' => $r['constraint_type'] == 'PRIMARY KEY', 'nullable' => $r['is_nullable'] == 'YES', 'default' => $r['column_default']];
         if ($r['constraint_type'] == 'PRIMARY KEY') {
             $col_def['primary'] = true;
             $col_def['autoincrement'] = $r['extra'] == 'auto_increment';
         }
         $has_charset = false;
         if (in_array($data_type, ['int', 'tinyint', 'mediumint', 'bigint', 'int', 'smallint', 'year'])) {
             $col_def['unsigned'] = (bool) preg_match('/unsigned/', strtolower($r['column_type']));
             $col_def['precision'] = is_numeric($r['numeric_precision']) ? (int) $r['numeric_precision'] : null;
         } elseif (in_array($data_type, ['real', 'double precision', 'decimal', 'numeric', 'float', 'dec', 'fixed'])) {
             $col_def['precision'] = is_numeric($r['numeric_precision']) ? (int) $r['numeric_precision'] : null;
             $col_def['scale'] = is_numeric($r['numeric_scale']) ? (int) $r['numeric_scale'] : null;
         } elseif (in_array($data_type, ['timestamp', 'date', 'time', 'datetime'])) {
             // nothing yet
         } elseif (in_array($data_type, ['char', 'varchar', 'binary', 'varbinary', 'text', 'tinytext', 'mediumtext', 'longtext'])) {
             $col_def['octet_length'] = is_numeric($r['character_octet_length']) ? (int) $r['character_octet_length'] : null;
             $col_def['length'] = is_numeric($r['character_maximum_length']) ? (int) $r['character_maximum_length'] : null;
             $has_charset = true;
         } elseif (in_array($data_type, ['blob', 'tinyblob', 'mediumblob', 'longblob'])) {
             $col_def['octet_length'] = (int) $r['character_octet_length'];
             $col_def['length'] = (int) $r['character_maximum_length'];
         } elseif (in_array($data_type, ['enum', 'set'])) {
             $col_def['octet_length'] = (int) $r['character_octet_length'];
             $col_def['length'] = (int) $r['character_maximum_length'];
             $def = $r['column_type'];
             preg_match_all("/'([^']+)'/", $def, $matches);
             if (is_array($matches[1]) && count($matches) > 0) {
                 $col_def['values'] = $matches[1];
             }
         }
         if ($include_options) {
             $col_def['options'] = ['comment' => $r['column_comment'], 'definition' => $r['column_type'], 'column_key' => $r['column_key'], 'ordinal_position' => $r['ordinal_position'], 'constraint_type' => $r['constraint_type']];
             if ($has_charset) {
                 $col_def['options']['charset'] = $r['character_set_name'];
                 $col_def['options']['collation'] = $r['collation_name'];
             }
         }
         $columns[$column_name] = $col_def;
         $foreign_keys = $table->foreign_keys;
         $unique_keys = $table->unique_keys;
         $constraint_name = $r['constraint_name'];
         $referenced_table_name = $r['referenced_table_name'];
         $referenced_column_name = $r['referenced_column_name'];
         switch ($r['constraint_type']) {
             case 'PRIMARY KEY':
                 $table->primary_keys = array_merge($table->primary_keys->toArray(), (array) $column_name);
                 break;
             case 'UNIQUE':
                 if (!$unique_keys->offsetExists($constraint_name)) {
                     $unique_keys[$constraint_name] = [];
                 }
                 $unique_keys[$constraint_name] = array_merge($unique_keys[$constraint_name]->toArray(), (array) $column_name);
                 break;
             case 'FOREIGN KEY':
                 /*
                                     if (!$foreign_keys->offsetExists($constraint_name)) {
                    $foreign_keys[$constraint_name] = array();
                                     }
                 *
                 */
                 $fk = ['referenced_table' => $referenced_table_name, 'referenced_column' => $referenced_column_name, 'constraint_name' => $constraint_name];
                 $foreign_keys[$column_name] = $fk;
                 //$table->references[$referenced_table_name] = array($column_name => $r['referenced_column_name']);
                 if (!array_key_exists($referenced_table_name, $references)) {
                     $references[$referenced_table_name] = [];
                 }
                 $k = "{$table_name}:{$referenced_column_name}->{$column_name}";
                 $references[$referenced_table_name][$k] = ['column' => $column_name, 'referencing_table' => $table_name, 'referencing_column' => $referenced_column_name, 'constraint_name' => $constraint_name];
                 break;
         }
     }
     foreach ($references as $referenced_table_name => $refs) {
         if ($tables->offsetExists($referenced_table_name)) {
             $table = $tables[$referenced_table_name];
             $table->references = $refs;
         }
     }
     $array = new ArrayObject($config->toArray());
     unset($config);
     return $array;
 }
Пример #21
0
 /**
  * Set options using an instance of type Zend_Config
  *
  * @param \Zend\Config\Config $config
  * @return \Zend\Cache\Frontend\Core
  */
 public function setConfig(Config\Config $config)
 {
     $options = $config->toArray();
     while (list($name, $value) = each($options)) {
         $this->setOption($name, $value);
     }
     return $this;
 }
 /**
  * Return object (table/schema) configuration
  *
  * @throws Exception\ErrorException
  *
  * @param string $table
  * @param boolean $include_options
  * @return array
  */
 protected function getObjectConfig($table = null, $include_options = false)
 {
     $schema = $this->schema;
     $qSchema = $this->adapter->getPlatform()->quoteValue($schema);
     if ($table !== null) {
         $qTable = $this->adapter->getPlatform()->quoteValue($table);
         $table_clause = "and (t.TABLE_NAME = {$qTable} or (kcu.referenced_table_name = {$qTable} and kcu.constraint_name = 'FOREIGN KEY'))";
         $table_join_condition = "(t.table_name = kcu.table_name or  kcu.referenced_table_name = t.table_name)";
     } else {
         $table_join_condition = "t.table_name = kcu.table_name";
         $table_clause = '';
     }
     $query = "\n\n            SELECT\n                    t.table_name,\n                    c.column_name,\n                    c.data_type,\n                    c.column_type,\n\n                    c.extra,\n\n                    tc.constraint_type,\n                    kcu.constraint_name,\n                    kcu.referenced_table_name,\n                    kcu.referenced_column_name,\n\n                    c.column_default,\n                    c.is_nullable,\n                    c.numeric_precision,\n                    c.numeric_scale,\n                    c.character_octet_length,\n                    c.character_maximum_length,\n                    c.ordinal_position,\n\n                    c.column_key, -- UNI/MUL/PRI\n                    c.character_set_name,\n\n\n                    c.collation_name,\n\n                    c.column_comment,\n\n                    t.table_type,\n                    t.engine,\n                    t.table_comment,\n                    t.table_collation\n\n            FROM `INFORMATION_SCHEMA`.`COLUMNS` c\n            INNER JOIN `INFORMATION_SCHEMA`.`TABLES` t on c.TABLE_NAME = t.TABLE_NAME\n            LEFT JOIN `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` kcu\n               on (\n                    {$table_join_condition}\n                     and kcu.table_schema = t.table_schema\n                     and kcu.column_name = c.column_name\n                 )\n              LEFT JOIN\n                `INFORMATION_SCHEMA`.`TABLE_CONSTRAINTS` tc\n               on (\n                     t.table_name = tc.table_name\n                      and tc.table_schema = t.table_schema\n                      and tc.constraint_name = kcu.constraint_name\n                  )\n\n\n            where c.TABLE_SCHEMA = {$qSchema}\n            and t.TABLE_SCHEMA = {$qSchema}\n            {$table_clause}\n            and (kcu.table_schema = {$qSchema}  or kcu.table_schema is null)\n\n            and (kcu.column_name = c.column_name or kcu.column_name is null)\n            order by t.table_name, c.ordinal_position\n        ";
     $this->disableInnoDbStats();
     try {
         $results = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
     } catch (\Exception $e) {
         //@codeCoverageIgnoreStart
         $this->restoreInnoDbStats();
         throw new Exception\ErrorException(__METHOD__ . ": " . $e->getMessage());
         //@codeCoverageIgnoreEnd
     }
     $this->restoreInnoDbStats();
     $references = array();
     $config = new Config(array('tables' => array()), true);
     $tables = $config->offsetGet('tables');
     foreach ($results as $r) {
         // Setting table information
         $table_name = $r['table_name'];
         if (!$tables->offsetExists($table_name)) {
             $table_def = array('name' => $table_name, 'columns' => array(), 'primary_keys' => array(), 'unique_keys' => array(), 'foreign_keys' => array(), 'references' => array(), 'indexes' => array());
             if ($include_options) {
                 $table_def['options'] = array('comment' => $r['table_comment'], 'collation' => $r['table_collation'], 'type' => $r['table_type'], 'engine' => $r['engine']);
             }
             $tables->offsetSet($table_name, $table_def);
         }
         $table = $tables->offsetGet($table_name);
         $columns = $table->columns;
         $column_name = $r['column_name'];
         $data_type = strtolower($r['data_type']);
         $col_def = array('type' => $data_type, 'primary' => $r['constraint_type'] == 'PRIMARY KEY', 'nullable' => $r['is_nullable'] == 'YES', 'default' => $r['column_default']);
         if ($r['constraint_type'] == 'PRIMARY KEY') {
             $col_def['primary'] = true;
             $col_def['autoincrement'] = $r['extra'] == 'auto_increment';
         }
         $has_charset = false;
         if (in_array($data_type, array('int', 'tinyint', 'mediumint', 'bigint', 'int', 'smallint', 'year'))) {
             $col_def['unsigned'] = (bool) preg_match('/unsigned/', strtolower($r['column_type']));
             $col_def['precision'] = $r['numeric_precision'];
         } elseif (in_array($data_type, array('real', 'double precision', 'decimal', 'numeric', 'float', 'dec', 'fixed'))) {
             $col_def['precision'] = $r['numeric_precision'];
             $col_def['scale'] = $r['numeric_scale'];
         } elseif (in_array($data_type, array('timestamp', 'date', 'time', 'datetime'))) {
             // nothing yet
         } elseif (in_array($data_type, array('char', 'varchar', 'binary', 'varbinary', 'text', 'tinytext', 'mediumtext', 'longtext'))) {
             $col_def['octet_length'] = $r['character_octet_length'];
             $col_def['length'] = $r['character_maximum_length'];
             $has_charset = true;
         } elseif (in_array($data_type, array('blob', 'tinyblob', 'mediumblob', 'longblob'))) {
             $col_def['octet_length'] = $r['character_octet_length'];
             $col_def['length'] = $r['character_maximum_length'];
         } elseif (in_array($data_type, array('enum', 'set'))) {
             $col_def['octet_length'] = $r['character_octet_length'];
             $col_def['length'] = $r['character_maximum_length'];
             $def = $r['column_type'];
             preg_match_all("/'([^']+)'/", $def, $matches);
             if (is_array($matches[1]) && count($matches) > 0) {
                 $col_def['values'] = $matches[1];
             }
         }
         if ($include_options) {
             $col_def['options'] = array('comment' => $r['column_comment'], 'definition' => $r['column_type'], 'column_key' => $r['column_key'], 'ordinal_position' => $r['ordinal_position'], 'constraint_type' => $r['constraint_type']);
             if ($has_charset) {
                 $col_def['options']['charset'] = $r['character_set_name'];
                 $col_def['options']['collation'] = $r['collation_name'];
             }
         }
         $columns[$column_name] = $col_def;
         $foreign_keys = $table->foreign_keys;
         $unique_keys = $table->unique_keys;
         $constraint_name = $r['constraint_name'];
         $referenced_table_name = $r['referenced_table_name'];
         $referenced_column_name = $r['referenced_column_name'];
         switch ($r['constraint_type']) {
             case 'PRIMARY KEY':
                 $table->primary_keys = array_merge($table->primary_keys->toArray(), (array) $column_name);
                 break;
             case 'UNIQUE':
                 if (!$unique_keys->offsetExists($constraint_name)) {
                     $unique_keys[$constraint_name] = array();
                 }
                 $unique_keys[$constraint_name] = array_merge($unique_keys[$constraint_name]->toArray(), (array) $column_name);
                 break;
             case 'FOREIGN KEY':
                 /*
                                     if (!$foreign_keys->offsetExists($constraint_name)) {
                    $foreign_keys[$constraint_name] = array();
                                     }
                 *
                 */
                 $fk = array('referenced_table' => $referenced_table_name, 'referenced_column' => $referenced_column_name, 'constraint_name' => $constraint_name);
                 $foreign_keys[$column_name] = $fk;
                 //$table->references[$referenced_table_name] = array($column_name => $r['referenced_column_name']);
                 if (!array_key_exists($referenced_table_name, $references)) {
                     $references[$referenced_table_name] = array();
                 }
                 $references[$referenced_table_name][] = array('column' => $column_name, 'referenced_column' => $referenced_column_name, 'constraint_name' => $constraint_name);
                 break;
         }
     }
     foreach ($references as $referenced_table_name => $refs) {
         if ($tables->offsetExists($referenced_table_name)) {
             $table = $tables[$referenced_table_name];
             $references = $table->references;
             $references[$referenced_table_name] = $refs;
         }
     }
     $array = $config->toArray();
     unset($config);
     return $array;
 }
Пример #23
0
 protected function merge(array $global, array $local)
 {
     if (!$local) {
         return $global;
     }
     $global = new Config($global);
     $local = new Config($local);
     $global->merge($local);
     return $global->toArray();
 }
Пример #24
0
 /**
  * Constructor.
  *
  * @param \Zend\Config\Config $config Configuration
  */
 public function __construct($config)
 {
     $this->config = $config->toArray();
 }
Пример #25
0
 /**
  * Set options from config object
  *
  * @param  Config $config
  * @return DisplayGroup
  */
 public function setConfig(Config $config)
 {
     return $this->setOptions($config->toArray());
 }
Пример #26
0
 protected function getOpenGraphData()
 {
     if (!empty($this->openGraphData)) {
         return $this->openGraphData;
     }
     $data = new Config($this->getDefaults());
     $page = $this->getPage();
     // CMS page
     if ($page->getPageId()) {
         /** @var \WShafer\OpenGraph\Repository\OpenGraphRepository $repo */
         $repo = $this->entityManager->getRepository('WShafer\\OpenGraph\\Entity\\OpenGraph');
         $savedData = new Config($repo->getOpenGraphAsArrayByPage($page));
         $data->merge($savedData);
     }
     $this->openGraphData = $data->toArray();
     return $this->openGraphData;
 }