use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
-use Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel;
+use Org\Mxchange\CoreFramework\Traits\Compressor\Channel\CompressorChannelTrait;
+use Org\Mxchange\CoreFramework\Traits\Handler\Io\IoHandlerTrait;
// Import SPL stuff
use \SplFileInfo;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
+ // Load traits
+ use CompressorChannelTrait;
+ use IoHandlerTrait;
+
/**
* The file's extension
*/
*/
private $indexKey = '__idx';
- /**
- * The file I/O instance for the template loader
- */
- private $fileIoInstance = NULL;
-
- /**
- * A Compressor instance
- */
- private $compressorChannelInstance = NULL;
-
/**
* The protected constructor. Do never instance from outside! You need to
* set a local file path. The class will then validate it.
// Get an instance
$databaseInstance = new CachedLocalFileDatabase();
- // Get a new compressor channel instance
- $compressorChannelInstance = ObjectFactory::createObjectByConfiguredName('compressor_channel_class');
-
// Set the compressor channel
- $databaseInstance->setCompressorChannelInstance($compressorChannelInstance);
+ $databaseInstance->setCompressorChannelInstance(ObjectFactory::createObjectByConfiguredName('compressor_channel_class'));
- // Get a file IO handler
- $fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class');
-
- // ... and set it
- $databaseInstance->setFileIoInstance($fileIoInstance);
+ // Get a file IO handler and set it
+ $databaseInstance->setFileIoInstance(ObjectFactory::createObjectByConfiguredName('file_io_class'));
// "Connect" to the database
$databaseInstance->connectToDatabase();
public final function getIndexKey () {
return $this->indexKey;
}
- /**
- * Private getter for file IO instance
- *
- * @return $fileIoInstance An instance to the file I/O sub-system
- */
- protected final function getFileIoInstance () {
- return $this->fileIoInstance;
- }
-
- /**
- * Setter for file I/O instance
- *
- * @param $fileIoInstance An instance to the file I/O sub-system
- * @return void
- */
- public final function setFileIoInstance (IoHandler $fileIoInstance) {
- $this->fileIoInstance = $fileIoInstance;
- }
-
- /**
- * Setter for compressor channel
- *
- * @param $compressorChannelInstance An instance of a CompressorChannel class
- * @return void
- */
- protected final function setCompressorChannelInstance (CompressorChannel $compressorChannelInstance) {
- $this->compressorChannelInstance = $compressorChannelInstance;
- }
-
- /**
- * Getter for compressor channel
- *
- * @return $compressorChannelInstance An instance of a CompressorChannel class
- */
- protected final function getCompressorChannelInstance () {
- return $this->compressorChannelInstance;
- }
/**
* Reads a local data file and returns it's contents in an array