Beispiel #1
0
 public function __construct(Connection $connection, $config, $eshost, $esport, $eslog, $files)
 {
     $this->dbal = $connection;
     $this->config = $config;
     $this->eshost = $eshost;
     $this->esport = $esport;
     $this->eslog = $eslog;
     $this->files = $files;
     $this->eslogh = $this->eslog;
     $this->eslogi = 0;
     if (!file_exists($this->eslog)) {
         if (!mkdir($this->eslog, 0777, true)) {
             throw new Exception("Can't create direcoty '{$this->eslog}'");
         }
     }
     $this->eslog .= DIRECTORY_SEPARATOR . date('Y_m_d_H_i_s') . "_populate.log";
     UtilFilesystem::checkIfFileExistOrICanCreate($this->eslog, true);
     $this->eslogh = fopen($this->eslog, 'a');
     $this->url = $eshost . ':' . $esport;
     if (!@is_array($this->config['indexes'])) {
         throw new Exception("Invalid config, no 'indexes' key");
     }
     foreach ($this->config['indexes'] as &$data) {
         foreach ($data['types'] as $type => &$tdata) {
             foreach ($tdata['properties'] as $field => &$properties) {
                 if (!isset($properties['mapping'])) {
                     $properties['mapping'] = array();
                 }
                 if (!isset($properties['mapping']['field'])) {
                     $properties['mapping']['field'] = $field;
                 }
             }
         }
     }
 }
Beispiel #2
0
 public function __construct($file, $options = array())
 {
     UtilFilesystem::checkFile($file);
     $this->file = fopen($file, 'r');
     if (is_array($options)) {
         $this->options = array_merge(array('length' => 0, 'delimiter' => ',', 'enclosure' => '"', 'escape' => '\\', 'skip' => 0), $options);
     }
 }
Beispiel #3
0
 public function move()
 {
     $paths = $this->_extractHiddenPaths($this->request->request->all());
     foreach ($paths as $path => $file) {
         if (trim($file)) {
             $processor = $this->_getProcessorByPath($path);
             $config = $processor->getConfig();
             $tmp = $config['web'] . $config['dirtmp'] . $file;
             if (file_exists($tmp)) {
                 UtilFilesystem::rename($tmp, $config['web'] . $config['dir'] . $file);
                 UtilFilesystem::removeEmptyDirsToPath(dirname($tmp), $config['web'] . $config['dirtmp']);
             }
         }
     }
 }
 public function delete($entity)
 {
     /* @var $entity User */
     if ($path = $entity->getPath()) {
         $config = $this->getConfig();
         $tmp = $config['web'] . $config['dirtmp'] . $path;
         if (file_exists($tmp)) {
             UtilFilesystem::removeFile($tmp);
             UtilFilesystem::removeEmptyDirsToPath(dirname($tmp), $config['web'] . $config['dirtmp']);
         }
         $tmp = $config['web'] . $config['dir'] . $path;
         if (file_exists($tmp)) {
             UtilFilesystem::removeFile($tmp);
             UtilFilesystem::removeEmptyDirsToPath(dirname($tmp), $config['web'] . $config['dir']);
         }
     }
 }
Beispiel #5
0
 public function ver()
 {
     if (!$this->ver) {
         $root = AbstractApp::getRootDir();
         $file = $root . '/app/cache/prod/appProdUrlMatcher.php';
         try {
             UtilFilesystem::checkFile($file);
         } catch (\Exception $e) {
             $file = $root . '/vendor/autoload.php';
             try {
                 UtilFilesystem::checkFile($file);
             } catch (\Exception $e) {
                 echo "File '{$file}'' not exists, please run project in production mode once to create it\n";
                 die($e->getMessage());
             }
         }
         $d = new DateTime(date("c", filemtime($file)));
         $this->ver = $d->format('Y-m-d-H-i-s');
     }
     return $this->ver;
 }
Beispiel #6
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $id = $input->getArgument('id');
     $file = $input->getArgument('file');
     $state = $input->getArgument('state');
     if (is_string($state)) {
         $state = strtolower(trim($state));
         switch ($state) {
             case '1':
             case 'true':
                 $state = true;
                 break;
             case '0':
             case 'false':
                 $state = false;
                 break;
             default:
                 throw new Exception("Allowed values in state are: 1, true, 0, false");
         }
     }
     UtilFilesystem::toggleFlag($file, $id, $state);
     echo "Current state: " . (UtilFilesystem::toggleFlagGetState($file, $id) ? 'true' : 'false') . "\n";
 }
Beispiel #7
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // tworzenie katalogu głównego /app
     $app = AbstractApp::getStpaConfig('core.app');
     if (!file_exists($app)) {
         UtilFilesystem::checkDir(dirname($app), true);
         $output->writeln("<info>Tworzenie katalogu: </info><comment>{$app}</comment>");
         mkdir($app);
     }
     $list = $this->_findPartsClasses();
     if ($input->getOption('list') === false) {
         foreach ($list as $cls) {
             /* @var $cls AbstractInstallerPart */
             $cls->install($input, $output);
         }
     } else {
         $tmp = array();
         foreach ($list as $cls) {
             /* @var $cls AbstractInstallerPart */
             $tmp[] = str_pad($cls->getPrior(), 8, ' ', STR_PAD_LEFT) . ' : ' . get_class($cls);
         }
         $output->writeln(implode("\n", $tmp));
     }
 }
Beispiel #8
0
 public static function getStpaConfig($key = null, $default = null)
 {
     if (static::$stpaconfig === null) {
         $root = static::getRootDir();
         $config = "{$root}/stpaconfig.ini";
         try {
             UtilFilesystem::checkFile($config);
         } catch (Exception $ex) {
             $config = "{$root}/vendor/stopsopa/utils/src/Stopsopa/UtilsBundle/Resources/config/stpaconfig.ini";
         }
         static::$stpaconfig = parse_ini_file($config, true);
         $root = static::getRootDir();
         static::_bindConfig(static::$stpaconfig, $root);
     }
     return UtilArray::cascadeGet(static::$stpaconfig, $key, $default);
 }