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 IniConfiguration
 5: {
 6:   
 7:   /** @var string */
 8:   protected $iniPath;
 9:   
10:   /** @var array */
11:   protected $settings;
12:   
13:   /** @var array */
14:   protected $rewriteOptions;
15:   
16:   /**
17:    * @param string $iniPath
18:    * @param array $rewriteOptions
19:    */
20:   public function __construct($iniPath, array $rewriteOptions = array())
21:   {
22:     $this->iniPath = $iniPath;
23:     $this->rewriteOptions = $rewriteOptions;
24:   }
25:   
26:   /**
27:    * @param string $section
28:    * @param string $variable
29:    * @return mixed
30:    */
31:   public function get($section, $variable = NULL)
32:   {
33:     $this->read();
34:     if (!isset($this->settings[$section])) {
35:       throw new ConfigurationException('Section ' . $section . ' not found (' . $this->iniPath . ')');
36:     }
37:     $sectionData = $this->settings[$section];
38:     if ($variable !== NULL) {
39:       if (!isset($sectionData[$variable])) {
40:         throw new ConfigurationException('Variable '.$variable.' not found in ' . $section . ' ('.$this->iniPath.')');
41:       }
42:       return $sectionData[$variable];
43:     }
44:     return $sectionData;
45:   }
46:   
47:   /**
48:    * @return string
49:    */
50:   public function getTempPath()
51:   {
52:     $temp = $this->get('local', 'tempPath');
53:     if (!is_writable($temp)) {
54:       throw new ApiException('Directory ' . $temp . ' is not writable or doesn\'t exist.');
55:     }
56:     return $temp;
57:   }
58:   
59:   /**
60:    */
61:   protected function read()
62:   {
63:     if ($this->settings !== NULL) {
64:       return;
65:     }
66:     
67:     if (!is_file($this->iniPath)) {
68:       throw new ConfigurationException('Ini file ' . $this->iniPath . ' not found.');
69:     }
70:     
71:     $this->settings = parse_ini_file($this->iniPath, TRUE);
72:     $this->settings = array_replace_recursive($this->settings, $this->rewriteOptions);
73:   }
74:   
75: }
API documentation generated by ApiGen