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

Commit 9852f3a

Browse files
committed
Add hoa://Library/StringBuffer component.
It helps to resolve the temporary filename behind a string buffer.
1 parent 87a0d25 commit 9852f3a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

StringBuffer.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,57 @@ public function initializeWith ( $string ) {
269269
}
270270
}
271271

272+
/**
273+
* Class \Hoa\StringBuffer\_Protocol.
274+
*
275+
* hoa://Library/StringBuffer component.
276+
*
277+
* @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
278+
* @copyright Copyright © 2007-2013 Ivan Enderlin.
279+
* @license New BSD License
280+
*/
281+
282+
class _Protocol extends \Hoa\Core\Protocol {
283+
284+
/**
285+
* Component's name.
286+
*
287+
* @var \Hoa\Core\Protocol string
288+
*/
289+
protected $_name = 'StringBuffer';
290+
291+
292+
293+
/**
294+
* ID of the component.
295+
*
296+
* @access public
297+
* @param string $id ID of the component.
298+
* @return mixed
299+
*/
300+
public function reachId ( $id ) {
301+
302+
$stream = resolve(
303+
'hoa://Library/Stream#hoa://Library/StringBuffer#' . $id
304+
);
305+
306+
if(null === $stream)
307+
return null;
308+
309+
$meta = $stream->getStreamMetaData();
310+
311+
return $meta['uri'];
312+
}
313+
}
314+
315+
}
316+
namespace {
317+
318+
/**
319+
* Add the hoa://Library/StringBuffer component. Help to know to real path of a
320+
* stringbuffer.
321+
*/
322+
$protocol = \Hoa\Core::getInstance()->getProtocol();
323+
$protocol['Library'][] = new \Hoa\StringBuffer\_Protocol();
324+
272325
}

0 commit comments

Comments
 (0)