Ejemplo n.º 1
0
 /**
  * Make data configuration to file options.php inside directory config
  *
  * @return mixed
  */
 public function saveAnalyticAction()
 {
     $this->view->disable();
     //Is not $_POST
     if (!$this->request->isPost()) {
         return $this->currentRedirect();
     }
     $filename = ROOT_DIR . 'common/config/options.php';
     if (!file_exists($filename)) {
         $makeFile = ZFunction::makeFile($filename);
     }
     if (file_exists($filename)) {
         $analytic = ['googleAnalytic' => $this->request->getPost('analytic')];
         $data = new AdapterPhp($filename);
         $result = array_merge($data->toArray(), $analytic);
         $result = '<?php return ' . var_export($result, true) . ';';
         if (!file_put_contents($filename, $result)) {
             throw new \Exception("Data was not saved", 1);
         }
         $this->flashSession->success(t('Data was successfully deleted'));
         return $this->currentRedirect();
     }
     return $this->currentRedirect();
 }
Ejemplo n.º 2
0
 public function saveConfig($arrayConfig)
 {
     $filename = ROOT_DIR . 'content/options/options.php';
     if (!file_exists($filename)) {
         $makeFile = ZFunction::makeFile($filename);
         file_put_contents($filename, "<?php return [];");
     }
     if (file_exists($filename)) {
         $data = new AdapterPhp($filename);
         $result = array_merge($data->toArray(), $arrayConfig);
         $result = '<?php return ' . var_export($result, true) . ';';
         if (!file_put_contents($filename, $result)) {
             return false;
         }
         return true;
     }
 }
Ejemplo n.º 3
0
 /**
  * 設定ファイルを丸ごと配列で取得
  * @return array
  */
 public function getArray()
 {
     return $this->config->toArray();
 }