Your IP : 18.191.137.153


Current Path : /home/bitrix/ext_www/rk_shared_core/local/modules/webprofy.offersgroup/lib/
Upload File :
Current File : /home/bitrix/ext_www/rk_shared_core/local/modules/webprofy.offersgroup/lib/settings.php

<?php
namespace Webprofy\Offersgroup;

/**
 * Class Settings
 * @package Webprofy\Offersgroup
 */
class Settings
{
	/**
	 * @return string
	 * GetOffersType
	 */
	public static function getOffersType(){
		//File and setting's exists
		$arFile = self::getSettings();
		if($arFile && $arFile['offers_type']){
			return $arFile['offers_type'];
		}

		//Create new file settings
		self::setOffersType('base');

		return 'base';
	}

	/**
	 * @param $type
	 * @return int
	 * SetOffersType
	 */
	public static function setOffersType($type)
	{
		if(($type == 'base') || ($type == 'multiple')){
			$arFile = self::getSettings();
			$arFile['offers_type'] = $type;
			return self::setSettings($arFile);
		}
	}

	/**
	 * @return mixed
	 * Return settings array
	 */
	public static function getSettings()
	{
		return json_decode(file_get_contents(self::getPath()), true);
	}

	/**
	 * @param $arData
	 * @return int
	 * Save settings array
	 */
	public static function setSettings($arData)
	{
		return file_put_contents(self::getPath(), json_encode($arData));
	}

	/**
	 * @return string
	 * Path to settings.json
	 */
	public static function getPath()
	{
		return dirname(__DIR__) . '/settings.json';
	}
}