Overview

Namespaces

  • Datadepo
    • Api
      • DataStores
      • Structures
      • Synchronizers

Classes

  • Datadepo\Api\ApiWrapper
  • Datadepo\Api\Collector
  • Datadepo\Api\DataDepoResponse
  • Datadepo\Api\DataDepoSync
  • Datadepo\Api\DataStores\PdoDataStore
  • Datadepo\Api\IniConfiguration
  • Datadepo\Api\RunningFiles
  • Datadepo\Api\Structures\AbstractStructure
  • Datadepo\Api\Structures\BusinessLine
  • Datadepo\Api\Structures\BusinessSupplierLine
  • Datadepo\Api\Structures\CategoryLine
  • Datadepo\Api\Structures\DataLine
  • Datadepo\Api\Structures\ImageLine
  • Datadepo\Api\Structures\ParameterLine
  • Datadepo\Api\Structures\PriceLine
  • Datadepo\Api\Structures\RelatedLine
  • Datadepo\Api\Structures\StoreLine
  • Datadepo\Api\Structures\SupplierBankAccountLine
  • Datadepo\Api\Structures\SupplierLine
  • Datadepo\Api\Structures\SupplierPersonLine
  • Datadepo\Api\Structures\VariantLine
  • Datadepo\Api\Synchronizers\AbstractSynchronizer
  • Datadepo\Api\Synchronizers\BusinessSynchronizer
  • Datadepo\Api\Synchronizers\CategorySynchronizer
  • Datadepo\Api\Synchronizers\DataSynchronizer
  • Datadepo\Api\Synchronizers\SuppliersSynchronizer

Interfaces

  • Datadepo\Api\DataStores\IDataStore

Exceptions

  • Datadepo\Api\ApiException
  • Datadepo\Api\ConfigurationException
  • Datadepo\Api\DataDepoRunningException
  • Datadepo\Api\DataDepoSuspendedException
  • Overview
  • Namespace
  • Class
 1: <?php
 2: namespace Datadepo\Api;
 3: 
 4: class RunningFiles
 5: {
 6:   
 7:   /** @var IniConfiguration */
 8:   protected $iniConfiguration;
 9:   
10:   /** @var string */
11:   protected $filename;
12:   
13:   /**
14:    * @param IniConfiguration $iniConfiguration
15:    * @param string $filename
16:    */
17:   public function __construct(IniConfiguration $iniConfiguration, $filename)
18:   {
19:     $this->iniConfiguration = $iniConfiguration;
20:     $this->filename = $filename;
21:   }
22:   
23:   /**
24:    * @return bool
25:    */
26:   public function exists()
27:   {
28:     if (!$this->isActive()) {
29:       return FALSE;
30:     }
31:     $file = $this->getRunningFile();
32:     return is_file($file) && $this->isValid($file);
33:   }
34:   
35:   /**
36:    */
37:   public function create()
38:   {
39:     if (!$this->isActive()) {
40:       return FALSE;
41:     }
42:     file_put_contents($this->getRunningFile(), time());
43:   }
44:   
45:   /**
46:    */
47:   public function delete()
48:   {
49:     if (!$this->isActive()) {
50:       return FALSE;
51:     }
52:     unlink($this->getRunningFile());
53:   }
54:   
55:   
56:   /**
57:    * @return bool
58:    */
59:   protected function isActive()
60:   {
61:     return $this->iniConfiguration->get('local', 'createRunningFiles');
62:   }
63:   
64:   /**
65:    * @return string
66:    */
67:   protected function getRunningFile()
68:   {
69:     $tempPath = $this->iniConfiguration->getTempPath();
70:     return $tempPath . '/' . $this->filename . '.running';
71:   }
72:   
73:   /**
74:    * @param string $file
75:    * @reutrn bool
76:    */
77:   protected function isValid($file)
78:   {
79:     $c = file_get_contents($file);
80:     $validity = $this->iniConfiguration->get('local', 'runningFileValidity');
81:     return $c + $validity >= time();
82:   }
83:   
84: }
API documentation generated by ApiGen