Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
Fixes write accessors were not available
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeymakinen committed Aug 11, 2016
1 parent b766fa2 commit 224b362
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class Facade
*
* @var array
*/
private static $_accessors = [];
private static $_accessors;

/**
* The facaded application.
Expand All @@ -29,7 +29,7 @@ abstract class Facade
*
* @var object[]
*/
private static $_components = [];
private static $_components;

/**
* Returns a component ID being facaded.
Expand All @@ -51,14 +51,6 @@ public static function getFacadeComponent()
$id = static::getFacadeComponentId();
if (!isset(self::$_components[$id])) {
self::$_components[$id] = static::getFacadeApplication()->get($id);
self::$_accessors[$id] = [];
foreach ((new \ReflectionClass(self::$_components[$id]))->getProperties(
\ReflectionProperty::IS_PUBLIC & ~\ReflectionProperty::IS_STATIC
) as $property) {
$accessor = ucfirst($property->getName());
self::$_accessors[$id]['get' . $accessor] = $property->getName();
self::$_accessors[$id]['set' . $accessor] = $property->getName();
}
}
return self::$_components[$id];
}
Expand Down Expand Up @@ -96,6 +88,16 @@ public static function setFacadeApplication(Application $value)
public static function __callStatic($name, $arguments)
{
$id = static::getFacadeComponentId();
if (!isset(self::$_accessors[$id])) {
self::$_accessors[$id] = [];
foreach ((new \ReflectionClass(static::getFacadeComponent()))->getProperties(
\ReflectionProperty::IS_PUBLIC & ~\ReflectionProperty::IS_STATIC
) as $property) {
$accessor = ucfirst($property->getName());
self::$_accessors[$id]['get' . $accessor] = $property->getName();
self::$_accessors[$id]['set' . $accessor] = $property->getName();
}
}
if (isset(self::$_accessors[$id][$name])) {
if ($name[0] === 'g') {
return static::getFacadeComponent()->{self::$_accessors[$id][$name]};
Expand Down

0 comments on commit 224b362

Please sign in to comment.