simplify index.php file
This commit is contained in:
parent
1167ea6b0b
commit
d4d700efe6
@ -27,7 +27,7 @@
|
||||
</a>
|
||||
</g>
|
||||
<!-- \\miniMVC -->
|
||||
<g id="node5" class="node"><title>\\miniMVC</title>
|
||||
<g id="node4" class="node"><title>\\miniMVC</title>
|
||||
<a xlink:href="sys.core.miniMVC.html" xlink:title="miniMVC" target="_parent">
|
||||
<polygon fill="none" stroke="black" points="453,-304 389,-304 389,-268 453,-268 453,-304"/>
|
||||
<text text-anchor="middle" x="421" y="-282.6" font-family="Courier,monospace" font-size="11.00">miniMVC</text>
|
||||
@ -56,29 +56,19 @@
|
||||
<polygon fill="none" stroke="black" points="493.464,-30.6617 482.919,-29.6361 490.523,-37.0139 493.464,-30.6617"/>
|
||||
</g>
|
||||
<!-- \\MM -->
|
||||
<g id="node4" class="node"><title>\\MM</title>
|
||||
<a xlink:href="sys.core.miniMVC.html" xlink:title="MM" target="_parent">
|
||||
<g id="node6" class="node"><title>\\MM</title>
|
||||
<a xlink:href="sys.core.MM.html" xlink:title="MM" target="_parent">
|
||||
<polygon fill="none" stroke="black" points="268,-277 214,-277 214,-241 268,-241 268,-277"/>
|
||||
<text text-anchor="middle" x="241" y="-255.6" font-family="Courier,monospace" font-size="11.00">MM</text>
|
||||
</a>
|
||||
</g>
|
||||
<!-- \\ArrayObject -->
|
||||
<g id="node15" class="node"><title>\\ArrayObject</title>
|
||||
<ellipse fill="none" stroke="black" cx="71" cy="-259" rx="71.107" ry="18"/>
|
||||
<text text-anchor="middle" x="71" y="-254.4" font-family="Times Roman,serif" font-size="14.00" fill="gray">\ArrayObject</text>
|
||||
</g>
|
||||
<!-- \\MM->\\ArrayObject -->
|
||||
<g id="edge7" class="edge"><title>\\MM->\\ArrayObject</title>
|
||||
<path fill="none" stroke="black" d="M213.687,-259C196.92,-259 174.483,-259 152.374,-259"/>
|
||||
<polygon fill="none" stroke="black" points="152.26,-255.5 142.26,-259 152.26,-262.5 152.26,-255.5"/>
|
||||
</g>
|
||||
<!-- \\miniMVC->\\MM -->
|
||||
<g id="edge9" class="edge"><title>\\miniMVC->\\MM</title>
|
||||
<g id="edge7" class="edge"><title>\\miniMVC->\\MM</title>
|
||||
<path fill="none" stroke="black" d="M388.403,-281.111C357.322,-276.448 310.563,-269.434 278.075,-264.561"/>
|
||||
<polygon fill="none" stroke="black" points="278.475,-261.082 268.067,-263.06 277.437,-268.005 278.475,-261.082"/>
|
||||
</g>
|
||||
<!-- \\MM_Page -->
|
||||
<g id="node6" class="node"><title>\\MM_Page</title>
|
||||
<g id="node5" class="node"><title>\\MM_Page</title>
|
||||
<a xlink:href="sys.core.page.html" xlink:title="MM_Page" target="_parent">
|
||||
<polygon fill="none" stroke="black" points="659,-250 595,-250 595,-214 659,-214 659,-250"/>
|
||||
<text text-anchor="middle" x="627" y="-228.6" font-family="Courier,monospace" font-size="11.00">MM_Page</text>
|
||||
@ -92,10 +82,20 @@
|
||||
</a>
|
||||
</g>
|
||||
<!-- \\MM_Page->\\MM_Output -->
|
||||
<g id="edge11" class="edge"><title>\\MM_Page->\\MM_Output</title>
|
||||
<g id="edge9" class="edge"><title>\\MM_Page->\\MM_Output</title>
|
||||
<path fill="none" stroke="black" d="M594.359,-232C561.071,-232 509.002,-232 470.611,-232"/>
|
||||
<polygon fill="none" stroke="black" points="470.172,-228.5 460.172,-232 470.172,-235.5 470.172,-228.5"/>
|
||||
</g>
|
||||
<!-- \\ArrayObject -->
|
||||
<g id="node17" class="node"><title>\\ArrayObject</title>
|
||||
<ellipse fill="none" stroke="black" cx="71" cy="-259" rx="71.107" ry="18"/>
|
||||
<text text-anchor="middle" x="71" y="-254.4" font-family="Times Roman,serif" font-size="14.00" fill="gray">\ArrayObject</text>
|
||||
</g>
|
||||
<!-- \\MM->\\ArrayObject -->
|
||||
<g id="edge11" class="edge"><title>\\MM->\\ArrayObject</title>
|
||||
<path fill="none" stroke="black" d="M213.687,-259C196.92,-259 174.483,-259 152.374,-259"/>
|
||||
<polygon fill="none" stroke="black" points="152.26,-255.5 142.26,-259 152.26,-262.5 152.26,-255.5"/>
|
||||
</g>
|
||||
<!-- \\MM_Controller -->
|
||||
<g id="node7" class="node"><title>\\MM_Controller</title>
|
||||
<a xlink:href="sys.core.controller.html" xlink:title="MM_Controller" target="_parent">
|
||||
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
@ -159,7 +159,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -433,7 +433,7 @@ dynamic methods</h2>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -757,7 +757,7 @@ dynamic methods</h2>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -199,7 +199,7 @@ of the singleton</h2>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -710,7 +710,7 @@ dynamic methods</h2>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -639,7 +639,7 @@ Used for outputing HTML</h2>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1174,7 +1174,7 @@ supports</p></p>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -143,7 +143,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -608,7 +608,7 @@ dynamic methods</h2>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -66,7 +66,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -74,12 +74,14 @@
|
||||
<div class="package-contents"></div>
|
||||
<div class="package-contents"></div>
|
||||
<div class="package-contents"></div>
|
||||
<div class="package-contents"></div>
|
||||
<div class="package-contents"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -63,7 +63,7 @@
|
||||
</script><div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -78,7 +78,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -68,7 +68,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -163,6 +163,12 @@
|
||||
<div class="subelement response"><code>\self</code></div>
|
||||
</div></div>
|
||||
</div>
|
||||
<a name="init" id="init"></a><div class="element clickable function init" data-toggle="collapse" data-target=".init .collapse">
|
||||
<h2>Load required classes for bootstraping</h2>
|
||||
<pre>init() : void</pre>
|
||||
<div class="labels"></div>
|
||||
<div class="row collapse"><div class="span8"><p class="long_description"></p></div></div>
|
||||
</div>
|
||||
<a name="is_like_array" id="is_like_array"></a><div class="element clickable function is_like_array" data-toggle="collapse" data-target=".is_like_array .collapse">
|
||||
<h2>Utility function to check if a variable is set, and is an array or object</h2>
|
||||
<pre>is_like_array(mixed $var) : bool</pre>
|
||||
@ -427,7 +433,7 @@ display them cleanly</h2>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -66,7 +66,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -114,7 +114,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -99,7 +99,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -96,7 +96,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -63,9 +63,9 @@
|
||||
<i class="icon-custom icon-class"></i> Classes</li>
|
||||
<li><a href="#MM_Model" title="Base Model Class">MM_Model</a></li>
|
||||
<li><a href="#DB" title="Extend PHP's PDO class to add some more functionality">DB</a></li>
|
||||
<li><a href="#MM" title="Class for standalone JSObject objects">MM</a></li>
|
||||
<li><a href="#miniMVC" title="Base class for the framework">miniMVC</a></li>
|
||||
<li><a href="#MM_Page" title="Class for building pages">MM_Page</a></li>
|
||||
<li><a href="#MM" title="Class for standalone JSObject objects">MM</a></li>
|
||||
<li><a href="#MM_Controller" title="Base Controller Class">MM_Controller</a></li>
|
||||
<li><a href="#MM_Output" title="Class for displaying output and setting http headers">MM_Output</a></li>
|
||||
</ul>
|
||||
@ -136,7 +136,7 @@
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -79,6 +79,7 @@
|
||||
<li class="function "><a href="#controller_methods" title="controller_methods :: Returns routable methods for the specified controller class"><span class="description">Returns routable methods for the specified controller class</span><pre>controller_methods</pre></a></li>
|
||||
<li class="function "><a href="#do_include" title="do_include :: Array_map callback to load a folder of classes at once"><span class="description">Array_map callback to load a folder of classes at once</span><pre>do_include</pre></a></li>
|
||||
<li class="function "><a href="#get_instance" title="get_instance :: Singleton getter function"><span class="description">Singleton getter function</span><pre>get_instance</pre></a></li>
|
||||
<li class="function "><a href="#init" title="init :: Load required classes for bootstraping"><span class="description">Load required classes for bootstraping</span><pre>init</pre></a></li>
|
||||
<li class="function "><a href="#is_like_array" title="is_like_array :: Utility function to check if a variable is set, and is an array or object"><span class="description">Utility function to check if a variable is set, and is an array or object</span><pre>is_like_array</pre></a></li>
|
||||
<li class="function "><a href="#load_file" title="load_file :: Function to search through the tree to find the necessary file"><span class="description">Function to search through the tree to find the necessary file</span><pre>load_file</pre></a></li>
|
||||
<li class="function "><a href="#on_error" title="on_error :: Custom error handler"><span class="description">Custom error handler</span><pre>on_error</pre></a></li>
|
||||
@ -197,6 +198,12 @@ display them cleanly</span><pre>shutdown</pre></a></li>
|
||||
<div class="subelement response"><code>\self</code></div>
|
||||
</div></div>
|
||||
</div>
|
||||
<a name="init" id="init"></a><div class="element clickable function init" data-toggle="collapse" data-target=".init .collapse">
|
||||
<h2>Load required classes for bootstraping</h2>
|
||||
<pre>init() : void</pre>
|
||||
<div class="labels"></div>
|
||||
<div class="row collapse"><div class="span8"><p class="long_description"></p></div></div>
|
||||
</div>
|
||||
<a name="is_like_array" id="is_like_array"></a><div class="element clickable function is_like_array" data-toggle="collapse" data-target=".is_like_array .collapse">
|
||||
<h2>Utility function to check if a variable is set, and is an array or object</h2>
|
||||
<pre>is_like_array(mixed $var) : bool</pre>
|
||||
@ -460,7 +467,7 @@ display them cleanly</h2>
|
||||
<div class="row"><footer class="span12">
|
||||
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
|
||||
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
|
||||
generated on 2012-05-16T09:06:14-04:00.<br></footer></div>
|
||||
generated on 2012-05-16T16:47:16-04:00.<br></footer></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -155,7 +155,7 @@
|
||||
</method>
|
||||
</class>
|
||||
</file>
|
||||
<file path="sys/core/miniMVC.php" hash="c7e3e16b5780ba1122da5382b94dc1c0" package="miniMVC">
|
||||
<file path="sys/core/traits.php" hash="31b716d9af4d97d256d85c4d75324dbe" package="miniMVC">
|
||||
<docblock line="2">
|
||||
<description><![CDATA[MiniMVC]]></description>
|
||||
<long-description><![CDATA[<p>Convention-based micro-framework for PHP</p>]]></long-description>
|
||||
@ -246,131 +246,89 @@
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
</docblock>
|
||||
</function>
|
||||
<class final="false" abstract="false" namespace="default" line="196" package="miniMVC\System">
|
||||
<name>MM</name>
|
||||
<full_name>\MM</full_name>
|
||||
<extends>\ArrayObject</extends>
|
||||
<docblock line="190">
|
||||
<description><![CDATA[Class for standalone JSObject objects]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="190" name="package" description="miniMVC"/>
|
||||
<tag line="190" name="subpackage" description="System"/>
|
||||
</file>
|
||||
<file path="sys/core/miniMVC.php" hash="9b4d9d57c9b4bb276e6b688c1e606cfd" package="miniMVC">
|
||||
<docblock line="2">
|
||||
<description><![CDATA[MiniMVC]]></description>
|
||||
<long-description><![CDATA[<p>Convention-based micro-framework for PHP</p>]]></long-description>
|
||||
<tag line="2" name="package" description="miniMVC"/>
|
||||
<tag line="2" name="author" description="Timothy J. Warren"/>
|
||||
<tag line="2" name="copyright" description="Copyright (c) 2011 - 2012"/>
|
||||
<tag line="2" name="link" description="https://github.com/timw4mail/miniMVC" link="https://github.com/timw4mail/miniMVC"/>
|
||||
<tag line="2" name="license" description="http://philsturgeon.co.uk/code/dbad-license"/>
|
||||
</docblock>
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="205" package="">
|
||||
<name>__construct</name>
|
||||
<type>function</type>
|
||||
<docblock line="200">
|
||||
<description><![CDATA[Create the ArrayObject/JSObject hybrid object]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="200" name="param" description="array" type="" variable="$members"/>
|
||||
</docblock>
|
||||
<argument line="205">
|
||||
<name>$members</name>
|
||||
<default><![CDATA[[]]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
</method>
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="226" package="">
|
||||
<name>__call</name>
|
||||
<type>function</type>
|
||||
<docblock line="218">
|
||||
<description><![CDATA[Allow calling of array methods on the object and
|
||||
dynamic methods]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="218" name="param" description="" type="string" variable="$name">
|
||||
<type by_reference="false">string</type>
|
||||
</tag>
|
||||
<tag line="218" name="param" description="" type="array" variable="$params">
|
||||
<type by_reference="false">array</type>
|
||||
</tag>
|
||||
<tag line="218" name="return" description="" type="mixed">
|
||||
<type by_reference="false">mixed</type>
|
||||
</tag>
|
||||
</docblock>
|
||||
<argument line="226">
|
||||
<name>$name</name>
|
||||
<default><![CDATA[]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
<argument line="226">
|
||||
<name>$params</name>
|
||||
<default><![CDATA[[]]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
</method>
|
||||
</class>
|
||||
<class final="false" abstract="false" namespace="default" line="252" package="miniMVC\System">
|
||||
<class final="false" abstract="false" namespace="default" line="22" package="miniMVC\System">
|
||||
<name>miniMVC</name>
|
||||
<full_name>\miniMVC</full_name>
|
||||
<extends>\MM</extends>
|
||||
<docblock line="246">
|
||||
<docblock line="16">
|
||||
<description><![CDATA[Base class for the framework]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="246" name="package" description="miniMVC"/>
|
||||
<tag line="246" name="subpackage" description="System"/>
|
||||
<tag line="16" name="package" description="miniMVC"/>
|
||||
<tag line="16" name="subpackage" description="System"/>
|
||||
</docblock>
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="261" package="">
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="31" package="">
|
||||
<name>__construct</name>
|
||||
<type>function</type>
|
||||
<docblock line="256">
|
||||
<docblock line="26">
|
||||
<description><![CDATA[Constructor - Any classes loaded here become subclasses of miniMVC]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="256" name="param" description="" type="array" variable="$members">
|
||||
<tag line="26" name="param" description="" type="array" variable="$members">
|
||||
<type by_reference="false">array</type>
|
||||
</tag>
|
||||
</docblock>
|
||||
<argument line="261">
|
||||
<argument line="31">
|
||||
<name>$members</name>
|
||||
<default><![CDATA[[]]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
</method>
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="275" package="">
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="45" package="">
|
||||
<name>load_class</name>
|
||||
<type>function</type>
|
||||
<docblock line="269">
|
||||
<docblock line="39">
|
||||
<description><![CDATA[Method to load classes into the singleton]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="269" name="param" description="" type="string" variable="$name">
|
||||
<tag line="39" name="param" description="" type="string" variable="$name">
|
||||
<type by_reference="false">string</type>
|
||||
</tag>
|
||||
<tag line="269" name="return" description="" type="object">
|
||||
<tag line="39" name="return" description="" type="object">
|
||||
<type by_reference="false">object</type>
|
||||
</tag>
|
||||
</docblock>
|
||||
<argument line="275">
|
||||
<argument line="45">
|
||||
<name>$name</name>
|
||||
<default><![CDATA[]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
</method>
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="331" package="">
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="101" package="">
|
||||
<name>unload</name>
|
||||
<type>function</type>
|
||||
<docblock line="326">
|
||||
<docblock line="96">
|
||||
<description><![CDATA[Convenience function to remove an object from the singleton]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="326" name="param" description="" type="string" variable="$name">
|
||||
<tag line="96" name="param" description="" type="string" variable="$name">
|
||||
<type by_reference="false">string</type>
|
||||
</tag>
|
||||
</docblock>
|
||||
<argument line="331">
|
||||
<argument line="101">
|
||||
<name>$name</name>
|
||||
<default><![CDATA[]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
</method>
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="346" package="">
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="116" package="">
|
||||
<name>load_config</name>
|
||||
<type>function</type>
|
||||
<docblock line="341">
|
||||
<docblock line="111">
|
||||
<description><![CDATA[Convenience function to load config files]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="341" name="param" description="" type="string" variable="$name">
|
||||
<tag line="111" name="param" description="" type="string" variable="$name">
|
||||
<type by_reference="false">string</type>
|
||||
</tag>
|
||||
</docblock>
|
||||
<argument line="346">
|
||||
<argument line="116">
|
||||
<name>$name</name>
|
||||
<default><![CDATA[]]></default>
|
||||
<type/>
|
||||
@ -945,6 +903,70 @@ page.</p>]]></long-description>
|
||||
</method>
|
||||
</class>
|
||||
</file>
|
||||
<file path="sys/core/MM.php" hash="410a3090f18ff4e538690a3f44dfc75c" package="miniMVC">
|
||||
<docblock line="2">
|
||||
<description><![CDATA[MiniMVC]]></description>
|
||||
<long-description><![CDATA[<p>Convention-based micro-framework for PHP</p>]]></long-description>
|
||||
<tag line="2" name="package" description="miniMVC"/>
|
||||
<tag line="2" name="author" description="Timothy J. Warren"/>
|
||||
<tag line="2" name="copyright" description="Copyright (c) 2011 - 2012"/>
|
||||
<tag line="2" name="link" description="https://github.com/timw4mail/miniMVC" link="https://github.com/timw4mail/miniMVC"/>
|
||||
<tag line="2" name="license" description="http://philsturgeon.co.uk/code/dbad-license"/>
|
||||
</docblock>
|
||||
<class final="false" abstract="false" namespace="default" line="22" package="miniMVC\System">
|
||||
<name>MM</name>
|
||||
<full_name>\MM</full_name>
|
||||
<extends>\ArrayObject</extends>
|
||||
<docblock line="16">
|
||||
<description><![CDATA[Class for standalone JSObject objects]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="16" name="package" description="miniMVC"/>
|
||||
<tag line="16" name="subpackage" description="System"/>
|
||||
</docblock>
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="31" package="">
|
||||
<name>__construct</name>
|
||||
<type>function</type>
|
||||
<docblock line="26">
|
||||
<description><![CDATA[Create the ArrayObject/JSObject hybrid object]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="26" name="param" description="array" type="" variable="$members"/>
|
||||
</docblock>
|
||||
<argument line="31">
|
||||
<name>$members</name>
|
||||
<default><![CDATA[[]]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
</method>
|
||||
<method final="false" abstract="false" static="false" visibility="public" namespace="default" line="52" package="">
|
||||
<name>__call</name>
|
||||
<type>function</type>
|
||||
<docblock line="44">
|
||||
<description><![CDATA[Allow calling of array methods on the object and
|
||||
dynamic methods]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="44" name="param" description="" type="string" variable="$name">
|
||||
<type by_reference="false">string</type>
|
||||
</tag>
|
||||
<tag line="44" name="param" description="" type="array" variable="$params">
|
||||
<type by_reference="false">array</type>
|
||||
</tag>
|
||||
<tag line="44" name="return" description="" type="mixed">
|
||||
<type by_reference="false">mixed</type>
|
||||
</tag>
|
||||
</docblock>
|
||||
<argument line="52">
|
||||
<name>$name</name>
|
||||
<default><![CDATA[]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
<argument line="52">
|
||||
<name>$params</name>
|
||||
<default><![CDATA[[]]]></default>
|
||||
<type/>
|
||||
</argument>
|
||||
</method>
|
||||
</class>
|
||||
</file>
|
||||
<file path="sys/core/controller.php" hash="04d74f84fc24b2a7440f48f44214cc38" package="miniMVC">
|
||||
<docblock line="2">
|
||||
<description><![CDATA[MiniMVC]]></description>
|
||||
@ -1432,7 +1454,7 @@ of the singleton]]></description>
|
||||
</method>
|
||||
</class>
|
||||
</file>
|
||||
<file path="sys/common.php" hash="a48dbb60b8941616059508efd3681357" package="miniMVC">
|
||||
<file path="sys/common.php" hash="48438a8d54cc55b706e1bbffd840e4c4" package="miniMVC">
|
||||
<docblock line="2">
|
||||
<description><![CDATA[MiniMVC]]></description>
|
||||
<long-description><![CDATA[<p>Convention-based micro-framework for PHP</p>]]></long-description>
|
||||
@ -1693,8 +1715,19 @@ display them cleanly]]></description>
|
||||
<type/>
|
||||
</argument>
|
||||
</function>
|
||||
<function namespace="default" line="413" package="miniMVC">
|
||||
<name>init</name>
|
||||
<type>function</type>
|
||||
<docblock line="408">
|
||||
<description><![CDATA[Load required classes for bootstraping]]></description>
|
||||
<long-description><![CDATA[]]></long-description>
|
||||
<tag line="408" name="return" description="" type="void">
|
||||
<type by_reference="false">void</type>
|
||||
</tag>
|
||||
</docblock>
|
||||
</function>
|
||||
</file>
|
||||
<file path="index.php" hash="93d31b713e13e7687899b53f6b375502" package="miniMVC">
|
||||
<file path="index.php" hash="7cd9f43d62c56f7e06a84f9841567d59" package="miniMVC">
|
||||
<docblock line="2">
|
||||
<description><![CDATA[MiniMVC]]></description>
|
||||
<long-description><![CDATA[<p>Convention-based micro-framework for PHP</p>]]></long-description>
|
||||
@ -1710,12 +1743,6 @@ display them cleanly]]></description>
|
||||
<include line="55" type="Require" package="Default">
|
||||
<name>common.php</name>
|
||||
</include>
|
||||
<include line="58" type="Require Once" package="Default">
|
||||
<name>db/autoload.php</name>
|
||||
</include>
|
||||
<include line="61" type="Require Once" package="Default">
|
||||
<name>core/miniMVC.php</name>
|
||||
</include>
|
||||
<constant namespace="default" line="28" package="miniMVC\App">
|
||||
<name>ENVIRONMENT</name>
|
||||
<value><![CDATA['DEVELOPMENT']]></value>
|
||||
|
17
index.php
17
index.php
@ -54,22 +54,7 @@ require(MM_APP_PATH.'config/config.php');
|
||||
// Require the most important files
|
||||
require(MM_SYS_PATH . "common.php");
|
||||
|
||||
// Load Database classes
|
||||
require_once(MM_SYS_PATH.'db/autoload.php');
|
||||
|
||||
// Load system libraries
|
||||
require_once(MM_SYS_PATH.'core/miniMVC.php');
|
||||
array_map('do_include', glob(MM_SYS_PATH.'core/*.php'));
|
||||
|
||||
// Catch fatal errors, don't show them
|
||||
error_reporting((-1) & ~(E_ERROR | E_PARSE));
|
||||
register_shutdown_function('shutdown');
|
||||
|
||||
//Set error handlers
|
||||
set_error_handler('on_error');
|
||||
set_exception_handler('on_exception');
|
||||
|
||||
// And away we go!
|
||||
route();
|
||||
init();
|
||||
|
||||
// End of index.php
|
@ -403,4 +403,34 @@ function do_include($path)
|
||||
require_once($path);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Load required classes for bootstraping
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
// Catch fatal errors, don't show them
|
||||
error_reporting((-1) & ~(E_ERROR | E_PARSE));
|
||||
register_shutdown_function('shutdown');
|
||||
|
||||
//Set error handlers
|
||||
set_error_handler('on_error');
|
||||
set_exception_handler('on_exception');
|
||||
|
||||
// Load Database classes
|
||||
require_once(MM_SYS_PATH.'db/autoload.php');
|
||||
|
||||
// Load system libraries
|
||||
require_once(MM_SYS_PATH.'core/traits.php');
|
||||
require_once(MM_SYS_PATH.'core/MM.php');
|
||||
require_once(MM_SYS_PATH.'core/miniMVC.php');
|
||||
array_map('do_include', glob(MM_SYS_PATH.'core/*.php'));
|
||||
|
||||
// Map to the appropriate module/controller/function
|
||||
route();
|
||||
}
|
||||
|
||||
// End of common.php
|
70
sys/core/MM.php
Normal file
70
sys/core/MM.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* MiniMVC
|
||||
*
|
||||
* Convention-based micro-framework for PHP
|
||||
*
|
||||
* @package miniMVC
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2011 - 2012
|
||||
* @link https://github.com/timw4mail/miniMVC
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class for standalone JSObject objects
|
||||
*
|
||||
* @package miniMVC
|
||||
* @subpackage System
|
||||
*/
|
||||
class MM extends ArrayObject {
|
||||
|
||||
use JSObject;
|
||||
|
||||
/**
|
||||
* Create the ArrayObject/JSObject hybrid object
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
public function __construct($members = [])
|
||||
{
|
||||
parent::__construct($members);
|
||||
|
||||
// Add the passed parameters to the object
|
||||
foreach($members as $name => &$value)
|
||||
{
|
||||
$this->$name = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Allow calling of array methods on the object and
|
||||
* dynamic methods
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $params = [])
|
||||
{
|
||||
// Allow array operations on the object
|
||||
if (substr($name, 0, 6) === 'array_' && is_callable($name))
|
||||
{
|
||||
$args = array_merge($this->getArrayCopy(), $args);
|
||||
return call_user_func_array($name, $args);
|
||||
}
|
||||
|
||||
// Allow dynamic method calls
|
||||
if(is_callable($this->$name))
|
||||
{
|
||||
//Call the dynamic function
|
||||
return call_user_func_array($this->$name, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End of MM.php
|
@ -11,236 +11,6 @@
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ! JSObject Trait
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parent trait of base class, contains much of the magic
|
||||
*
|
||||
* @package miniMVC
|
||||
* @subpackage System
|
||||
*/
|
||||
trait JSObject {
|
||||
|
||||
/**
|
||||
* Constructor for creating the objects
|
||||
*
|
||||
* @param array $members
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($members = [])
|
||||
{
|
||||
// Add the passed parameters to the object
|
||||
foreach($members as $name => &$value)
|
||||
{
|
||||
$this->$name = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PHP magic method to facilitate dynamic methods
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $params
|
||||
*/
|
||||
public function __call($name, $params = [])
|
||||
{
|
||||
if(is_callable($this->$name))
|
||||
{
|
||||
//Call the dynamic function
|
||||
return call_user_func_array($this->$name, $params);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prints out the contents of the object when used as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if(ENVIRONMENT == 'DEVELOPMENT')
|
||||
{
|
||||
$args = func_get_args();
|
||||
$method = ( ! empty($args)) ? $args[0] : "print_r";
|
||||
$data = (isset($args[1])) ? $args[1] : [];
|
||||
|
||||
if(empty($data))
|
||||
{
|
||||
$data =& $this;
|
||||
}
|
||||
|
||||
$output = '<pre>';
|
||||
|
||||
if($method == "var_dump")
|
||||
{
|
||||
ob_start();
|
||||
var_dump($data);
|
||||
$output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
else if($method == "var_export")
|
||||
{
|
||||
ob_start();
|
||||
var_export($data);
|
||||
$output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
else
|
||||
{
|
||||
$output .= print_r($data, TRUE);
|
||||
}
|
||||
|
||||
return $output . '</pre>';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PHP magic method that is called when an object is treated as a function
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
public static function __invoke($args = [])
|
||||
{
|
||||
$class = __CLASS__;
|
||||
return new $class($args);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ! Singleton Trait
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Singleton pattern
|
||||
*
|
||||
* @package miniMVC
|
||||
* @subpackage System
|
||||
*/
|
||||
trait Singleton {
|
||||
|
||||
/**
|
||||
* Singleton object
|
||||
*
|
||||
* @var self
|
||||
*/
|
||||
protected static $instance;
|
||||
|
||||
/**
|
||||
* Protected constructor for creating the one instance
|
||||
*/
|
||||
abstract protected function __construct();
|
||||
|
||||
/**
|
||||
* PHP magic method that is called when an object is treated as a function
|
||||
*
|
||||
* @param array $params
|
||||
* @return self
|
||||
*/
|
||||
public static function __invoke($params = [])
|
||||
{
|
||||
return self::get_instance($params);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Singleton getter function
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function &get_instance()
|
||||
{
|
||||
if ( ! isset(self::$instance))
|
||||
{
|
||||
$class = __CLASS__;
|
||||
|
||||
self::$instance = new $class;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Magic function called when cloning an object
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
trigger_error('Clone is not allowed.', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ! Base Classes
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class for standalone JSObject objects
|
||||
*
|
||||
* @package miniMVC
|
||||
* @subpackage System
|
||||
*/
|
||||
class MM extends ArrayObject {
|
||||
|
||||
use JSObject;
|
||||
|
||||
/**
|
||||
* Create the ArrayObject/JSObject hybrid object
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
public function __construct($members = [])
|
||||
{
|
||||
parent::__construct($members);
|
||||
|
||||
// Add the passed parameters to the object
|
||||
foreach($members as $name => &$value)
|
||||
{
|
||||
$this->$name = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Allow calling of array methods on the object and
|
||||
* dynamic methods
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $params = [])
|
||||
{
|
||||
// Allow array operations on the object
|
||||
if (substr($name, 0, 6) === 'array_' && is_callable($name))
|
||||
{
|
||||
$args = array_merge($this->getArrayCopy(), $args);
|
||||
return call_user_func_array($name, $args);
|
||||
}
|
||||
|
||||
// Allow dynamic method calls
|
||||
if(is_callable($this->$name))
|
||||
{
|
||||
//Call the dynamic function
|
||||
return call_user_func_array($this->$name, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
186
sys/core/traits.php
Normal file
186
sys/core/traits.php
Normal file
@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/**
|
||||
* MiniMVC
|
||||
*
|
||||
* Convention-based micro-framework for PHP
|
||||
*
|
||||
* @package miniMVC
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2011 - 2012
|
||||
* @link https://github.com/timw4mail/miniMVC
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ! JSObject Trait
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parent trait of base class, contains much of the magic
|
||||
*
|
||||
* @package miniMVC
|
||||
* @subpackage System
|
||||
*/
|
||||
trait JSObject {
|
||||
|
||||
/**
|
||||
* Constructor for creating the objects
|
||||
*
|
||||
* @param array $members
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($members = [])
|
||||
{
|
||||
// Add the passed parameters to the object
|
||||
foreach($members as $name => &$value)
|
||||
{
|
||||
$this->$name = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PHP magic method to facilitate dynamic methods
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $params
|
||||
*/
|
||||
public function __call($name, $params = [])
|
||||
{
|
||||
if(is_callable($this->$name))
|
||||
{
|
||||
//Call the dynamic function
|
||||
return call_user_func_array($this->$name, $params);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prints out the contents of the object when used as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if(ENVIRONMENT == 'DEVELOPMENT')
|
||||
{
|
||||
$args = func_get_args();
|
||||
$method = ( ! empty($args)) ? $args[0] : "print_r";
|
||||
$data = (isset($args[1])) ? $args[1] : [];
|
||||
|
||||
if(empty($data))
|
||||
{
|
||||
$data =& $this;
|
||||
}
|
||||
|
||||
$output = '<pre>';
|
||||
|
||||
if($method == "var_dump")
|
||||
{
|
||||
ob_start();
|
||||
var_dump($data);
|
||||
$output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
else if($method == "var_export")
|
||||
{
|
||||
ob_start();
|
||||
var_export($data);
|
||||
$output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
else
|
||||
{
|
||||
$output .= print_r($data, TRUE);
|
||||
}
|
||||
|
||||
return $output . '</pre>';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PHP magic method that is called when an object is treated as a function
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
public static function __invoke($args = [])
|
||||
{
|
||||
$class = __CLASS__;
|
||||
return new $class($args);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ! Singleton Trait
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Singleton pattern
|
||||
*
|
||||
* @package miniMVC
|
||||
* @subpackage System
|
||||
*/
|
||||
trait Singleton {
|
||||
|
||||
/**
|
||||
* Singleton object
|
||||
*
|
||||
* @var self
|
||||
*/
|
||||
protected static $instance;
|
||||
|
||||
/**
|
||||
* Protected constructor for creating the one instance
|
||||
*/
|
||||
abstract protected function __construct();
|
||||
|
||||
/**
|
||||
* PHP magic method that is called when an object is treated as a function
|
||||
*
|
||||
* @param array $params
|
||||
* @return self
|
||||
*/
|
||||
public static function __invoke($params = [])
|
||||
{
|
||||
return self::get_instance($params);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Singleton getter function
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function &get_instance()
|
||||
{
|
||||
if ( ! isset(self::$instance))
|
||||
{
|
||||
$class = __CLASS__;
|
||||
|
||||
self::$instance = new $class;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Magic function called when cloning an object
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
trigger_error('Clone is not allowed.', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// End of traits.php
|
Loading…
Reference in New Issue
Block a user