Closed Awilum closed 3 years ago
Okey, issue solved
for my personal driver Config instead of:
class Config extends ConfigurationOption
{
use IOConfigurationOptionTrait;
}
I do this:
class Config extends ConfigurationOption
{
/**
* @var boolean
*/
protected $secureFileManipulation = false;
/**
* @var bool
*/
protected $htaccess = true;
/**
* @var string
*/
protected $securityKey = '';
/**
* @var string
*/
protected $cacheFileExtension = 'php';
/**
* @return string
*/
public function getSecurityKey(): string
{
return $this->securityKey;
}
/**
* @param string $securityKey
* @return Config
*/
public function setSecurityKey(string $securityKey): self
{
$this->securityKey = $securityKey;
return $this;
}
/**
* @return bool
*/
public function getHtaccess(): bool
{
return $this->htaccess;
}
/**
* @param bool $htaccess
* @return Config
*/
public function setHtaccess(bool $htaccess): self
{
$this->htaccess = $htaccess;
return $this;
}
/**
* @return bool
*/
public function isSecureFileManipulation(): bool
{
return $this->secureFileManipulation;
}
/**
* @param bool $secureFileManipulation
* @return self
*/
public function setSecureFileManipulation(bool $secureFileManipulation): self
{
$this->secureFileManipulation = $secureFileManipulation;
return $this;
}
/**
* @return string
*/
public function getCacheFileExtension(): string
{
return $this->cacheFileExtension;
}
/**
* @param string $cacheFileExtension
* @return self
* @throws PhpfastcacheInvalidConfigurationException
*/
public function setCacheFileExtension(string $cacheFileExtension): self
{
$this->cacheFileExtension = 'php';
return $this;
}
}
Hello
Its a bit unconventional but instead of rewriting the whole trait, just rewrite the method by rewriting IOConfigurationOptionTrait::setCacheFileExtension().
Create a trait:
trait YourIOConfigurationOptionTrait
{
use IOConfigurationOptionTrait;
public function setCacheFileExtension(string $cacheFileExtension): self
{
$this->cacheFileExtension = $cacheFileExtension;
return $this;
}
}
and in your driver:
class YourDriverConfig
{
use YourIOConfigurationOptionTrait;
}
You can even rewrite the setCacheFileExtension
method directly in your config class without extending the trait.
Otherwise your setter will be completely useless, do it properly :)
@Geolim4 Thanks for your reply!
I want to create PHP Arrays Driver that will store data as PHP Arrays in the php files. The issue I have, that I can't save php files with
php
file extension because of this:and I don't understand why this method is not allowing to set custom extension. it is says Set Cache File Extension but I'm still can't do this, because it is anyway compare it to SAFE_FILE_EXTENSIONS
How to set
php
file extension ?