| 1 |
|
<?php |
| 2 |
|
/** |
| 3 |
|
* Xyster Framework |
| 4 |
|
* |
| 5 |
|
* This source file is subject to the new BSD license that is bundled |
| 6 |
|
* with this package in the file LICENSE.txt. |
| 7 |
|
* It is also available through the world-wide-web at this URL: |
| 8 |
|
* http://www.opensource.org/licenses/bsd-license.php |
| 9 |
|
* |
| 10 |
|
* @category Xyster |
| 11 |
|
* @package Xyster_Container |
| 12 |
|
* @copyright Copyright LibreWorks, LLC (http://libreworks.net) |
| 13 |
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
| 14 |
|
* @version $Id$ |
| 15 |
|
*/ |
| 16 |
|
namespace Xyster\Container\Provider; |
| 17 |
|
/** |
| 18 |
|
* Abstract provider deletate class |
| 19 |
|
* |
| 20 |
|
* @category Xyster |
| 21 |
|
* @package Xyster_Container |
| 22 |
|
* @copyright Copyright LibreWorks, LLC (http://libreworks.net) |
| 23 |
|
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
| 24 |
|
*/ |
| 25 |
|
class Caching extends Delegate |
| 26 |
1 |
{ |
| 27 |
|
protected $_reference; |
| 28 |
|
|
| 29 |
|
/** |
| 30 |
|
* Get an instance of the provided component. |
| 31 |
|
* |
| 32 |
|
* This method will usually create a new instance each time it is called, |
| 33 |
|
* but that is not required. For example, a provider could keep a reference |
| 34 |
|
* to the same object or store it in an external scope. |
| 35 |
|
* |
| 36 |
|
* @param \Xyster\Container\IContainer $container The container (used for dependency resolution) |
| 37 |
|
* @param \Xyster\Type\Type $into Optional. The type into which this component will be injected |
| 38 |
|
* @return mixed The component |
| 39 |
|
*/ |
| 40 |
|
public function get(\Xyster\Container\IContainer $container, \Xyster\Type\Type $into = null) |
| 41 |
|
{ |
| 42 |
1 |
if ( $this->_reference === null ) { |
| 43 |
1 |
$this->_reference = $this->_delegate->get($container, $into); |
| 44 |
1 |
} |
| 45 |
1 |
return $this->_reference; |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
/** |
| 49 |
|
* Gets the label for the type of provider (for instance Caching or Singleton). |
| 50 |
|
* |
| 51 |
|
* @return string The provider label |
| 52 |
|
*/ |
| 53 |
|
public function getLabel() |
| 54 |
|
{ |
| 55 |
1 |
return 'Caching'; |
| 56 |
|
} |
| 57 |
1 |
} |