phpdoc/Library/Object/RegistryInvokable.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="robots" content="index, follow, all" />
<title>Library\Object\RegistryInvokable | Library</title>
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../../css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="../../css/sami.css">
<script src="../../js/jquery-1.11.1.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script src="../../js/typeahead.min.js"></script>
<script src="../../sami.js"></script>
<meta name="MobileOptimized" content="width">
<meta name="HandheldFriendly" content="true">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
</head>
<body id="class" data-name="class:Library_Object_RegistryInvokable" data-root-path="../../">
<div id="content">
<div id="left-column">
<div id="control-panel">
<form id="search-form" action="../../search.html" method="GET">
<span class="glyphicon glyphicon-search"></span>
<input name="search"
class="typeahead form-control"
type="search"
placeholder="Search">
</form>
</div>
<div id="api-tree"></div>
</div>
<div id="right-column">
<nav id="site-nav" class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-elements">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../index.html">Library</a>
</div>
<div class="collapse navbar-collapse" id="navbar-elements">
<ul class="nav navbar-nav">
<li><a href="../../classes.html">Classes</a></li>
<li><a href="../../namespaces.html">Namespaces</a></li>
<li><a href="../../interfaces.html">Interfaces</a></li>
<li><a href="../../traits.html">Traits</a></li>
<li><a href="../../doc-index.html">Index</a></li>
<li><a href="../../search.html">Search</a></li>
</ul>
</div>
</div>
</nav>
<div class="namespace-breadcrumbs">
<ol class="breadcrumb">
<li><span class="label label-default">class</span></li>
<li><a href="../../Library.html">Library</a></li>
<li><a href="../../Library/Object.html">Object</a></li>
<li>RegistryInvokable</li>
</ol>
</div>
<div id="page-content">
<div class="page-header">
<h1>RegistryInvokable</h1>
</div>
<p> class
<strong>RegistryInvokable</strong> implements
<a href="../../Library/Object/InvokableInterface.html"><abbr title="Library\Object\InvokableInterface">InvokableInterface</abbr></a>
</p>
<div class="description">
<p>Magic handling of properties access</p> <p><h2>Presentation</h2>
<p>This model will store any property dynamically set in the <code>$_data</code> registry:</p>
<pre><code>$obj->prop = value => $_data[prop] = value
$obj->setProp(value) => $_data[prop] = value
</code></pre>
<p>Depending on the flag of the object, to access the property, use:</p>
<pre><code>echo $obj->prop // if flag=PUBLIC_PROPERTIES
echo $obj->getProp() // if flag=PROTECTED_PROPERTIES
</code></pre>
<p>Be very careful about the properties names as they will all be transformed in lower case
and underscore:</p>
<pre><code>$obj->myPropertyName => $_data[ my_property_name ]
$obj->myProperty_name => $_data[ my_property_name ]
$obj->setMyPropertyName => $_data[ my_property_name ]
$obj->setMyProperty_name => $_data[ my_property_name ]
</code></pre>
<h2>Flags</h2>
<p>Three constants flags are defined in the class to let you choose the visibility of the object
properties:</p>
<ul>
<li><code>PUBLIC_PROPERTIES</code>: every type of property invocation is allowed,</li>
<li><code>PROTECTED_PROPERTIES</code>: only magic getter is allowed: <code>$obj->getProp()</code>, <code>$obj->prop</code> will return <code>null</code>,</li>
<li><code>UNAUTHORIZED_PROPERTIES</code>: only magic getter is allowed and an exception will be thrown using <code>$obj->prop</code></li>
</ul>
<p>Default flag of the class is <code>PROTECTED_PROPERTIES</code> to force the magic getter usage and allow you
to override these methods in your child class if necessary, without worrying about method existence.</p>
<h2>Rules</h2>
<p>All setter methods returns the object itself for chainability.</p> </div>
<h2>Constants</h2>
<table class="table table-condensed">
<tr>
<td>PUBLIC_PROPERTIES</td>
<td class="last">
<p><em>Defines all registry properties as public</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PROTECTED_PROPERTIES</td>
<td class="last">
<p><em>Defines all registry properties as protected</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>UNAUTHORIZED_PROPERTIES</td>
<td class="last">
<p><em>Defines all registry properties as protected and throw an error if an access is done</em></p>
<p>
</p>
</td>
</tr>
</table>
<h2>Methods</h2>
<div class="container-fluid underlined">
<div class="row">
<div class="col-md-2 type">
</div>
<div class="col-md-8 type">
<a href="#method___construct">__construct</a>(
array $data = null,
int $flag = self::PROTECTED_PROPERTIES)
<p>Object constructor</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
<a href="../../Library/Object/RegistryInvokable.html"><abbr title="Library\Object\RegistryInvokable">RegistryInvokable</abbr></a>
</div>
<div class="col-md-8 type">
<a href="#method_setFlag">setFlag</a>(
int $flag)
<p>Set the object flag for registry properties visibility</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
int
</div>
<div class="col-md-8 type">
<a href="#method_getFlag">getFlag</a>()
<p>Get the object flag for registry properties visibility</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
mixed
</div>
<div class="col-md-8 type">
<a href="#method___call">__call</a>(
string $name,
array $arguments)
<p>Magic handler when calling a non-existing method on an object</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
static
mixed
</div>
<div class="col-md-8 type">
<a href="#method___callStatic">__callStatic</a>(
string $name,
array $arguments)
<p>Avoiding magic static handler</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
mixed
</div>
<div class="col-md-8 type">
<a href="#method___get">__get</a>(
string $name)
<p>Magic getter</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
<a href="../../Library/Object/InvokableInterface.html"><abbr title="Library\Object\InvokableInterface">InvokableInterface</abbr></a>
</div>
<div class="col-md-8 type">
<a href="#method___set">__set</a>(
string $name,
mixed $value)
<p>Magic setter</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
bool
</div>
<div class="col-md-8 type">
<a href="#method___isset">__isset</a>(
string $name)
<p>Magic checker</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
<a href="../../Library/Object/InvokableInterface.html"><abbr title="Library\Object\InvokableInterface">InvokableInterface</abbr></a>
</div>
<div class="col-md-8 type">
<a href="#method___unset">__unset</a>(
string $name)
<p>Magic unsetter</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
mixed
</div>
<div class="col-md-8 type">
<a href="#method_getData">getData</a>(
string $name = null,
mixed $default = null)
<p>Global getter</p> </div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2 type">
mixed
</div>
<div class="col-md-8 type">
<a href="#method_setData">setData</a>($value, $arg2 = null)
<p>Global setter</p> </div>
<div class="col-md-2"></div>
</div>
</div>
<h2>Details</h2>
<div id="method-details">
<div class="method-item">
<h3 id="method___construct">
<div class="location">at line 115</div>
<code>
<strong>__construct</strong>(
array $data = null,
int $flag = self::PROTECTED_PROPERTIES)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Object constructor</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
array</td>
<td>$data</td>
<td>The object data to load in registry (optional)</td>
</tr>
<tr>
<td>
int</td>
<td>$flag</td>
<td>The object flag (one of the class constants - default is <code>self::PROTECTED_PROPERTIES</code>)</td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method_setFlag">
<div class="location">at line 130</div>
<code>
<a href="../../Library/Object/RegistryInvokable.html"><abbr title="Library\Object\RegistryInvokable">RegistryInvokable</abbr></a>
<strong>setFlag</strong>(
int $flag)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Set the object flag for registry properties visibility</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
int</td>
<td>$flag</td>
<td>Must be one of the class constants</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
<a href="../../Library/Object/RegistryInvokable.html"><abbr title="Library\Object\RegistryInvokable">RegistryInvokable</abbr></a></td>
<td>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method_getFlag">
<div class="location">at line 141</div>
<code>
int
<strong>getFlag</strong>()</code>
</h3>
<div class="details">
<div class="method-description">
<p>Get the object flag for registry properties visibility</p> </div>
<div class="tags">
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
int</td>
<td>The object flag value</td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method___call">
<div class="location">at line 162</div>
<code>
mixed
<strong>__call</strong>(
string $name,
array $arguments)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Magic handler when calling a non-existing method on an object</p> <p>Magic method handling <code>getProp(default)</code>, <code>setProp(value)</code>, <code>unsetProp()</code>, <code>issetProp()</code> or <code>resetProp()</code>.</p>
<p>Warning: the <code>reset</code> function here is the same as <code>unset</code> (not a real resetting to the original value).</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
string</td>
<td>$name</td>
<td>The non-existing method name called on the object</td>
</tr>
<tr>
<td>
array</td>
<td>$arguments</td>
<td>The arguments array passed calling the method</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
mixed</td>
<td>Must return the result of a magic method, or nothing if nothing can be done</td>
</tr>
</table>
<h4>See also</h4>
<table class="table table-condensed">
<tr>
<td><http://www.php.net/manual/en/language.oop5.overloading.php></td>
<td></td>
</tr>
<tr>
<td>Patterns\Commons\Registry::getEntry()</td>
<td></td>
</tr>
<tr>
<td>Patterns\Commons\Registry::setEntry()</td>
<td></td>
</tr>
<tr>
<td>Patterns\Commons\Registry::isEntry()</td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method___callStatic">
<div class="location">at line 201</div>
<code> static
mixed
<strong>__callStatic</strong>(
string $name,
array $arguments)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Avoiding magic static handler</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
string</td>
<td>$name</td>
<td>The non-existing method name called on the object</td>
</tr>
<tr>
<td>
array</td>
<td>$arguments</td>
<td>The arguments array passed calling the method</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
mixed</td>
<td>Must return the result of a magic method, or nothing if nothing can be done</td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method___get">
<div class="location">at line 221</div>
<code>
mixed
<strong>__get</strong>(
string $name)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Magic getter</p> <p>Magic method called when <code>getProp(arg, default)</code> or <code>$this->prop</code> are invoked. If the object
flag is set on <code>self::PROTECTED_PROPERTIES</code>, this will return null ; if the flag is set on
<code>self::UNAUTHORIZED_PROPERTIES</code>, an exception is thrown.</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
string</td>
<td>$name</td>
<td>The name of the property to get</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
mixed</td>
<td>This will return the result of a magic method, or nothing if nothing can be done</td>
</tr>
</table>
<h4>Exceptions</h4>
<table class="table table-condensed">
<tr>
<td><a href="../../Library/Object/InvokableAccessException.html"><abbr title="Library\Object\InvokableAccessException">InvokableAccessException</abbr></a></td>
<td>Throws an <code>InvokableAccessException</code> if direct access to properties is avoid by the
<code>self::UNAUTHORIZED_PROPERTIES</code> flag</td>
</tr>
</table>
<h4>See also</h4>
<table class="table table-condensed">
<tr>
<td><http://www.php.net/manual/en/language.oop5.overloading.php></td>
<td></td>
</tr>
<tr>
<td>Patterns\Commons\Registry::getEntry()</td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method___set">
<div class="location">at line 244</div>
<code>
<a href="../../Library/Object/InvokableInterface.html"><abbr title="Library\Object\InvokableInterface">InvokableInterface</abbr></a>
<strong>__set</strong>(
string $name,
mixed $value)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Magic setter</p> <p>Magic method called when <code>setProp(arg, value)</code> or <code>$this->arg = value</code> are invoked.</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
string</td>
<td>$name</td>
<td>The name of the property to get</td>
</tr>
<tr>
<td>
mixed</td>
<td>$value</td>
<td>The value to set for the property</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
<a href="../../Library/Object/InvokableInterface.html"><abbr title="Library\Object\InvokableInterface">InvokableInterface</abbr></a></td>
<td>Returns <code>$this</code> for method chaining</td>
</tr>
</table>
<h4>See also</h4>
<table class="table table-condensed">
<tr>
<td><http://www.php.net/manual/en/language.oop5.overloading.php></td>
<td></td>
</tr>
<tr>
<td>Patterns\Commons\Registry::setEntry()</td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method___isset">
<div class="location">at line 261</div>
<code>
bool
<strong>__isset</strong>(
string $name)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Magic checker</p> <p>Magic method called when <code>issetProp()</code>, <code>isset($this->prop)</code> or <code>empty($this->prop)</code> are invoked.</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
string</td>
<td>$name</td>
<td>The name of the property to get</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
bool</td>
<td>This will return <code>true</code> if the property exists, <code>false</code> otherwise</td>
</tr>
</table>
<h4>See also</h4>
<table class="table table-condensed">
<tr>
<td><http://www.php.net/manual/en/language.oop5.overloading.php></td>
<td></td>
</tr>
<tr>
<td>Patterns\Commons\Registry::isEntry()</td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method___unset">
<div class="location">at line 277</div>
<code>
<a href="../../Library/Object/InvokableInterface.html"><abbr title="Library\Object\InvokableInterface">InvokableInterface</abbr></a>
<strong>__unset</strong>(
string $name)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Magic unsetter</p> <p>Magic method called when <code>unsetProp()</code> or <code>unset($this->prop)</code> are invoked.</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
string</td>
<td>$name</td>
<td>The name of the property to get</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
<a href="../../Library/Object/InvokableInterface.html"><abbr title="Library\Object\InvokableInterface">InvokableInterface</abbr></a></td>
<td>Returns <code>$this</code> for method chaining</td>
</tr>
</table>
<h4>See also</h4>
<table class="table table-condensed">
<tr>
<td><http://www.php.net/manual/en/language.oop5.overloading.php></td>
<td></td>
</tr>
<tr>
<td>Patterns\Commons\Registry::_invokeUnset()</td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method_getData">
<div class="location">at line 293</div>
<code>
mixed
<strong>getData</strong>(
string $name = null,
mixed $default = null)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Global getter</p> <p>Get the value of a registry property or the whole registry array.</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td>
string</td>
<td>$name</td>
<td>The name of a property to get if so (optional)</td>
</tr>
<tr>
<td>
mixed</td>
<td>$default</td>
<td>A default value to send if the property doesn't exist in the object</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
mixed</td>
<td>The value of the property if so, the default value if the property doesn't exist, or
the flobal data array without a property name</td>
</tr>
</table>
</div>
</div>
</div>
<div class="method-item">
<h3 id="method_setData">
<div class="location">at line 314</div>
<code>
mixed
<strong>setData</strong>($value, $arg2 = null)</code>
</h3>
<div class="details">
<div class="method-description">
<p>Global setter</p> <p>Set the value of a registry property or the whole registry array.</p> </div>
<div class="tags">
<h4>Parameters</h4>
<table class="table table-condensed">
<tr>
<td></td>
<td>$value</td>
<td>
</td>
</tr>
<tr>
<td></td>
<td>$arg2</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table class="table table-condensed">
<tr>
<td>
mixed</td>
<td>The value of the property if so, the default value if the property doesn't exist, or
the flobal data array without a property name</td>
</tr>
</table>
<h4>Exceptions</h4>
<table class="table table-condensed">
<tr>
<td><abbr title="InvalidArgumentExcpetion">InvalidArgumentExcpetion</abbr></td>
<td>Throws an InvalidArgumentExcpetion if <code>$name</code> is null and <code>$value</code> is not an array</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
Generated by <a href="http://sami.sensiolabs.org/">Sami, the API Documentation Generator</a>.
</div>
</div>
</div>
</body>
</html>