Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
access-interceptor-scope-localizer-proxy.html
001 <!DOCTYPE html>
002 <html class="no-js" id="top">
003 <head>
004 <title>ProxyManager - Tuning the ProxyManager for production</title>
005
006 <meta name="description" content="A proxyManager write in php" />
007 <meta name="keywords" content="ProxyManager, proxy, manager, ocramius, Marco Pivetta, php, production" />
008 <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
009 <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600' rel='stylesheet' type='text/css'>
010 <link href="css/styles.css" rel="stylesheet" />
011 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/default.min.css">
012 <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
013 <script>hljs.initHighlightingOnLoad();</script>
014 <link rel="shortcut icon" href="favicon.ico">
015 </head>
016 <body>
017
018 <header class="site-header">
019 <div class="container">
020 <h1><a href="index.html"><img alt="ProxyManager" src="img/block.png" /></a></h1>
021
022 <nav class="main-nav" role="navigation">
023 <ul>
024 <li><a href="https://github.com/Ocramius/ProxyManager" target="_blank">Github</a>
025 <div class="bcms-clearfix"></div>
026 </li>
027 </ul>
028 </nav>
029 </div>
030 </header>
031 <main role="main">
032 <section class="component-content">
033
034 <div class="component-demo" id="live-demo">
035 <div class="container">
036 <div class="main-wrapper" style="text-align: right">
037 <iframe src="http://ghbtns.com/github-btn.html?user=ocramius&repo=ProxyManager&type=fork&count=true&size=large"
038 allowtransparency="true" frameborder="0" scrolling="0" width="310" height="40"></iframe>
039
040 <iframe src="http://ghbtns.com/github-btn.html?user=ocramius&repo=ProxyManager&type=watch&count=true&size=large"
041 allowtransparency="true" frameborder="0" scrolling="0" width="200" height="40"></iframe>
042
043 </div>
044 <div class="bcms-clearfix bcms-clearfix"></div>
045 </div>
046 </div>
047 <div class="component-info">
048 <div class="container">
049 <aside class="sidebar">
050 <nav class="spy-nav">
051 <ul>
052 <li><a href="index.html">Intro</a></li>
053 <li><a href="virtual-proxy.html">Virtual Proxy</a></li>
054 <li><a href="null-object.html">Null Objects</a></li>
055 <li><a href="ghost-object.html">Ghost Objects</a></li>
056 <li><a href="remote-object.html">Remote Object</a></li>
057 <li><a href="contributing.html">Contributing</a></li>
058 <li><a href="credits.html">Credits</a></li>
059 <li><a href="copyright.html">Copyright</a></li>
060 </ul>
061 </nav>
062 <div class="bcms-clearfix bcms-clearfix"></div>
063 <a class="btn btn-action btn-full download-component"
064 href="download.html">Download</a>
065 <div class="bcms-clearfix"></div>
066 </aside>
067
068 <div class="content">
069 <div class="bcms-clearfix"></div>
070 <h3 class="section-title">Access Interceptor Scope Localizer Proxy</h3>
071
072 <p>An access interceptor scope localizer is a smart reference proxy that allows you to dynamically define logic to be executed before or after any of the proxied object's methods' logic.</p>
073
074 <p>It works exactly like the <a href="access-interceptor-value-holder-proxy.html">access interceptor value holder</a>, with some minor differences in behavior.</p>
075
076 <p>The working concept of an access interceptor scope localizer is to localize scope of a proxied object:</p>
077
078 <pre>
079 <code class="php">
080 class Example
081 {
082 protected $foo;
083 protected $bar;
084 protected $baz;
085
086 public function doFoo()
087 {
088 // ...
089 }
090 }
091
092 class ExampleProxy extends Example
093 {
094 public function __construct(Example $example)
095 {
096 $this->foo = & $example->foo;
097 $this->bar = & $example->bar;
098 $this->baz = & $example->baz;
099 }
100
101 public function doFoo()
102 {
103 return parent::doFoo();
104 }
105 }
106 </code>
107 </pre>
108
109 <p>This allows to create a mirror copy of the real instance, where any change in the proxy or in the real instance is reflected in both objects.</p>
110
111 <p>The main advantage of this approach is that the proxy is now safe against fluent interfaces, which would break an <a href="access-interceptor-value-holder-proxy.html">access interceptor value holder</a> instead.</p>
112 <hr />
113 <h3>Differences with <a href="access-interceptor-value-holder-proxy.html">access interceptor value holder</a>:</h3>
114
115 <ul>
116 <li>It does <strong>NOT</strong> implement the <code>ProxyManager\Proxy\ValueHolderInterface</code>, since the proxy itself does not keep a reference to the original object being proxied</li>
117 <li>In all interceptor methods (see <a href="access-interceptor-value-holder-proxy.html">access interceptor value holder</a>), the $instance passed in is the proxy itself. There is no way to gather a reference to the original object right now, and that's mainly to protect from misuse.</li>
118 </ul>
119 <hr />
120
121 <h3>Known limitations</h3>
122
123 <ul>
124 <li>It is <strong>NOT</strong> possible to intercept access to public properties</li>
125 <li>It is <strong>NOT</strong> possible to proxy interfaces, since this proxy relies on <code>parent::method()</code> calls. Interfaces obviously don't provide a parent method implementation.</li>
126 <li>calling unset on a property of an access interceptor scope localizer (or the real instance) will cause the two objects to be un-synchronized, with possible unexpected behaviour.</li>
127 <li>serializing or un-serializing an access interceptor scope localizer (or the real instance) will not cause the real instance (or the proxy) to be serialized or un-serialized</li>
128 <li>if a proxied object contains private properties, then an exception will be thrown if you use PHP <code>< 5.4.0</code>.</li>
129 </ul>
130 <hr />
131 <h3>Example</h3>
132
133 <p>Here's an example of how you can create and use an access interceptor scope localizer :</p>
134
135 <pre>
136 <code class="php">
137 <?php
138
139 use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory as Factory;
140
141 require_once __DIR__ . '/vendor/autoload.php';
142
143 class Foo
144 {
145 public function doFoo()
146 {
147 echo "Foo!\n";
148 }
149 }
150
151 $factory = new Factory();
152
153 $proxy = $factory->createProxy(
154 new Foo(),
155 array('doFoo' => function () { echo "PreFoo!\n"; }),
156 array('doFoo' => function () { echo "PostFoo!\n"; })
157 );
158
159 $proxy->doFoo();
160 </code>
161 </pre>
162
163 <p>This send something like following to your output:</p>
164
165 <pre>
166 <code class="php">
167 PreFoo!
168 Foo!
169 PostFoo!
170 </code>
171 </pre>
172
173 <p>This is pretty much the same logic that you can find in <a href="access-interceptor-value-holder-proxy.html">access interceptor value holder</a>.</p>
174
175 </main>
176
177 <footer class="site-footer" role="contentinfo">
178 <div class="container">
179 <div class="footer-logos">
180 <ul>
181 <li><a href="index.html">Intro</a> | </li>
182 <li><a href="virtual-proxy.html">Virtual Proxy</a> | </li>
183 <li><a href="null-object.html">Null Objects</a> | </li>
184 <li><a href="ghost-object.html">Ghost Objects</a> | </li>
185 <li><a href="remote-object.html">Remote Object</a> | </li>
186 <li><a href="contributing.html">Contributing</a> | </li>
187 <li><a href="credits.html">Credits</a> | </li>
188 <li><a href="copyright.html">Copyright</a></li>
189 </ul>
190 </div>
191 </div>
192
193 <div class="bcms-clearfix"></div>
194 </footer>
195 <div class="bcms-clearfix"></div>
196 </body>
197 </html>
198