Example #1
0
 public function merge(Entity $entity, array $raw)
 {
     try {
         $processor = new Processor();
         $configuration = $this;
         $config = $processor->processConfiguration($configuration, array('database' => $raw));
         $entity->setSchema($config['database']);
         $entity->setUser($config['username']);
         $entity->setType($config['phptype']);
         $entity->setPort($config['port']);
         $entity->setHost($config['hostspec']);
         $entity->setPassword($config['password']);
     } catch (\Exception $e) {
         throw new InvalidConfigException($e->getMessage());
     }
     return $entity;
 }
Example #2
0
 /**
  * Loads a config Entity
  *
  * @access public
  * @param string $name the file name
  * @return Entity a config entity
  */
 public function load($name = '', EntityInterface $ent)
 {
     if (empty($name)) {
         $name = self::DEFAULTNAME . self::EXTENSION;
     }
     $config_ary = $this->getIo()->load($name, null);
     //send it to be validated and normalized using out configTree;
     if ($config_ary === NULL) {
         return NULL;
     } else {
         $ent->setType($config_ary['type']);
         $ent->setCharset($config_ary['charset']);
         $ent->setHost($config_ary['host']);
         $ent->setMemory($config_ary['memory']);
         $ent->setPassword($config_ary['password']);
         $ent->setPath($config_ary['path']);
         $ent->setPort($config_ary['port']);
         $ent->setSchema($config_ary['schema']);
         $ent->setUnixSocket($config_ary['socket']);
         $ent->setUser($config_ary['user']);
     }
     return $ent;
 }