mirror of
https://github.com/felixfoertsch/wordpress-dev-env.git
synced 2026-04-18 15:28:44 +02:00
93 lines
1.6 KiB
PHP
93 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
*
|
|
*/
|
|
|
|
namespace WCFE\Libraries;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
class ResStorage {
|
|
|
|
/**
|
|
* put your comment there...
|
|
*
|
|
* @var mixed
|
|
*/
|
|
private $basePath;
|
|
|
|
/**
|
|
* put your comment there...
|
|
*
|
|
* @var mixed
|
|
*/
|
|
private $baseUrl;
|
|
|
|
/**
|
|
* put your comment there...
|
|
*
|
|
* @param mixed $baseUrl
|
|
* @param mixed $basePath
|
|
* @return ResStorage
|
|
*/
|
|
public function __construct( $baseUrl, $basePath )
|
|
{
|
|
$this->baseUrl = $baseUrl;
|
|
$this->basePath = $basePath;
|
|
}
|
|
|
|
/**
|
|
* put your comment there...
|
|
*
|
|
*/
|
|
public function getBasePath()
|
|
{
|
|
return $this->basePath;
|
|
}
|
|
|
|
/**
|
|
* put your comment there...
|
|
*
|
|
*/
|
|
public function getBaseUrl()
|
|
{
|
|
return $this->baseUrl;
|
|
}
|
|
|
|
/**
|
|
* put your comment there...
|
|
*
|
|
* @param mixed $name
|
|
*/
|
|
public function & getRes( $class )
|
|
{
|
|
|
|
# Get url for the requested class
|
|
$url = $this->baseUrl;
|
|
$path = $this->basePath;
|
|
|
|
$resClassEntities = explode( '\\', $class );
|
|
|
|
# Remove base namespace as it represnt baseUrl!
|
|
array_shift( $resClassEntities );
|
|
|
|
# Remove class name
|
|
array_pop( $resClassEntities );
|
|
|
|
$urlPathToRes = implode( '/', $resClassEntities );
|
|
$filePathToRes = implode( DIRECTORY_SEPARATOR, $resClassEntities );
|
|
|
|
$resUrl = "{$url}/{$urlPathToRes}";
|
|
$resPath = "{$path}/{$filePathToRes}";
|
|
|
|
# Generate unique name for the rquested resource
|
|
$queueName = implode( '-', explode( '\\', strtolower( $class ) ) );
|
|
|
|
# Create res class
|
|
$resObject = new $class( $queueName, $resUrl, $resPath );
|
|
|
|
return $resObject;
|
|
}
|
|
|
|
} |