first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class WPML_XML_Config_Read_File implements WPML_XML_Config_Read {
|
||||
private $file_full_path;
|
||||
private $transform;
|
||||
private $validate;
|
||||
|
||||
function __construct( $file_full_path, WPML_XML_Config_Validate $validate, WPML_XML_Transform $transform ) {
|
||||
$this->file_full_path = $file_full_path;
|
||||
$this->validate = $validate;
|
||||
$this->transform = $transform;
|
||||
}
|
||||
|
||||
function get() {
|
||||
if ( file_exists( $this->file_full_path ) && $this->validate->from_file( $this->file_full_path ) ) {
|
||||
$xml = file_get_contents( $this->file_full_path );
|
||||
|
||||
return $this->transform->get( $xml );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
class WPML_XML_Config_Read_Option implements WPML_XML_Config_Read {
|
||||
private $option;
|
||||
private $transform;
|
||||
private $validate;
|
||||
|
||||
/**
|
||||
* WPML_XML_Config_Read_Option constructor.
|
||||
*
|
||||
* @param \WPML_WP_Option $option
|
||||
* @param \WPML_XML_Config_Validate $validate
|
||||
* @param \WPML_XML_Transform $transform
|
||||
*/
|
||||
function __construct( WPML_WP_Option $option, WPML_XML_Config_Validate $validate, WPML_XML_Transform $transform ) {
|
||||
$this->option = $option;
|
||||
$this->validate = $validate;
|
||||
$this->transform = $transform;
|
||||
}
|
||||
|
||||
function get() {
|
||||
if ( $this->option->get() ) {
|
||||
$content = $this->option->get();
|
||||
|
||||
if ( $this->validate->from_string( $content ) ) {
|
||||
return $this->transform->get( $content );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* @author OnTheGo Systems
|
||||
*/
|
||||
interface WPML_XML_Config_Read {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user