Added traits

This commit is contained in:
Timothy Warren 2012-03-05 12:01:55 -05:00
parent d71fe56630
commit bcfc97a2c3
2 changed files with 16 additions and 14 deletions

View File

@ -15,12 +15,12 @@
/**
* Parent class of base class, contains much of the magic
*/
class JSObject{
trait JSObject {
/**
* Constructor for creating the objects
*/
function __construct($members = array())
public function __construct($members = array())
{
// Add the passed parameters to the object
foreach($members as $name => $value)
@ -35,7 +35,7 @@ class JSObject{
* @param string $name
* @param array $args
*/
function __call($name, $args)
public function __call($name, $args)
{
if(is_callable($this->$name))
{
@ -66,7 +66,7 @@ class JSObject{
*
* @return string
*/
function __toString()
public function __toString()
{
if(ENVIRONMENT == 'DEVELOPMENT')
{
@ -113,7 +113,7 @@ class JSObject{
*
* @param string $name
*/
function __get($name)
public function __get($name)
{
$path = SYS_PATH."{$name}.php";
$class = "{$name}";
@ -152,7 +152,9 @@ class JSObject{
*
* @extends JSObject
*/
class miniMVC extends JSObject{
class miniMVC {
use JSObject;
private static $instance;
private static $count;
@ -160,7 +162,7 @@ class miniMVC extends JSObject{
/**
* Constructor - Any classes loaded here become subclasses of miniMVC
*/
function __construct()
protected function __construct()
{
self::$instance =& $this;
}
@ -171,7 +173,7 @@ class miniMVC extends JSObject{
* @param string $name
* @param array $args
*/
function __call($name, $args)
public function __call($name, $args)
{
if(is_callable(self::$instance->$name))
{
@ -227,7 +229,7 @@ class miniMVC extends JSObject{
*
* @param string $name
*/
function load_class($name, $type='class')
public function load_class($name, $type='class')
{
switch($type)
{
@ -278,7 +280,7 @@ class miniMVC extends JSObject{
*
* @param string $name
*/
function unload($name)
public function unload($name)
{
if(isset($this->$name))
{
@ -291,7 +293,7 @@ class miniMVC extends JSObject{
*
* @param string $name
*/
function load_config($name)
public function load_config($name)
{
$path = APP_PATH . "config/{$name}.php";

View File

@ -14,10 +14,10 @@
/**
* Class for displaying output and setting http headers
*
* @extends JSObject
*/
class Output extends JSObject{
class Output{
use JSObject;
private $buffer, $headers;