Exemple #1
0
 public function install($options = array())
 {
     $config = $this->getServiceManager()->get('Config');
     //Setup database parameters
     $configFile = new \ATP\Config\File("config/autoload/global.php.blank");
     $configFile->apply($options);
     $configFile->save("config/autoload/global.php");
     //Setup a temp adapter for the ActiveRecord classes to use while installing
     $dbConfig = $config['db'];
     unset($dbConfig['database']);
     $dbConfig['host'] = $options['db_host'];
     $dbConfig['username'] = $options['db_user'];
     $dbConfig['password'] = $options['db_pass'];
     $adapter = new \Zend\Db\Adapter\Adapter($dbConfig);
     \ATP\ActiveRecord::setAdapter($adapter);
     //Create the database schema
     $adapter->query("CREATE DATABASE {$options['db_schema']}", \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
     //Add database to adapter
     $dbConfig['database'] = $options['db_schema'];
     $adapter = new \Zend\Db\Adapter\Adapter($dbConfig);
     \ATP\ActiveRecord::setAdapter($adapter);
     //Install database tables
     $this->installDatabaseEntries();
     //Reinitialize modules so its config is reloaded
     \ATPCore\Model\Module::init();
     //Set default parameters
     \ATPCore\Model\Parameter::init();
     foreach ($config['admin']['parameters'] as $id => $paramData) {
         $param = new \ATPCore\Model\Parameter();
         $param->identifier = $id;
         $param->value = $paramData['default'];
         $param->save();
     }
 }
Exemple #2
0
 public function installDatabaseEntries()
 {
     $db = \ATP\ActiveRecord::getAdapter();
     foreach ($this->getInstallDbQueries() as $sql) {
         $db->query($sql, \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
     }
 }
Exemple #3
0
 public function __construct($arc = null, $page = null)
 {
     parent::__construct();
     if (!is_null($arc) && !is_null($page)) {
         $nodes = $this->loadMultiple(array('where' => "arc_id = ? AND page_id = ?", 'data' => array($arc->id, $page->id)));
         $this->setFrom($nodes[0]);
     }
 }
 public function __construct()
 {
     parent::__construct();
     //Necessary to make sure the admin user class is loaded
     $user = new \ATPAdmin\Model\User();
 }
Exemple #5
0
 public function copyFrom($obj)
 {
     parent::copyFrom($obj);
     $this->_passwordHash = $obj->_passwordHash;
 }