1: <?php
2: /**
3: * LICENSE (BSD)
4: *
5: * Copyright (c) 2013, Gerd Christian Kunze
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions are
10: * met:
11: *
12: * * Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: *
15: * * Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: *
19: * * Neither the name of Gerd Christian Kunze nor the names of the
20: * contributors may be used to endorse or promote products derived from
21: * this software without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34: *
35: * Instance
36: * 14.02.2013 11:25
37: */
38: namespace MOC\Extension\Zip;
39: use MOC\Api;
40: use MOC\Generic\Device\Extension;
41:
42: /**
43: *
44: */
45: /** @noinspection PhpUndefinedClassInspection */
46: class Instance implements Extension {
47:
48: /** @var Instance $Singleton */
49: private static $Singleton = null;
50:
51: /**
52: * Get Singleton/Instance
53: *
54: * @static
55: * @return Instance
56: */
57: public static function InterfaceInstance() {
58: require_once( '3rdParty/pclzip.lib.php' );
59: if( self::$Singleton === null ) {
60: self::$Singleton = new Instance();
61: } return self::$Singleton;
62: }
63:
64: /**
65: * Get Changelog
66: *
67: * @static
68: * @return \MOC\Core\Changelog
69: */
70: public static function InterfaceChangelog() {
71: return Api::Core()->Changelog()->Create( __CLASS__ )
72: ->Build()->Clearance( '18.02.2013 11:22', 'Alpha' )
73: ;
74: }
75:
76: /**
77: * Get Dependencies
78: *
79: * @static
80: * @return \MOC\Core\Depending
81: */
82: public static function InterfaceDepending() {
83: return Api::Core()->Depending();
84: }
85:
86: /** @var \PclZip[] $InstanceQueue */
87: private $InstanceQueue = array();
88: /** @var \PclZip $InstanceCurrent */
89: private $InstanceCurrent = null;
90:
91: /**
92: * @return Instance
93: */
94: public function Create() {
95: $Instance = new \PclZip('');
96: if( null === $this->InstanceCurrent ) {
97: $this->InstanceCurrent = $Instance;
98: return $this;
99: } else {
100: array_push( $this->InstanceQueue, $this->InstanceCurrent );
101: $this->InstanceCurrent = $Instance;
102: return $this;
103: }
104: }
105:
106: /**
107: * @return null|\PclZip
108: */
109: public function Current() {
110: return $this->InstanceCurrent;
111: }
112:
113: /**
114: * @return Instance
115: */
116: public function Destroy() {
117: if( count( $this->InstanceQueue ) ) {
118: $this->InstanceCurrent = array_pop( $this->InstanceQueue );
119: } else {
120: $this->InstanceCurrent = null;
121: }
122: return $this;
123: }
124:
125: /**
126: * Set external Extension-Instance
127: *
128: * Contains:
129: * - Set new (external created) 3rdParty Instance to Current
130: *
131: * @param $Instance
132: *
133: * @return Extension
134: */
135: public function Define( $Instance ) {
136: // TODO: Implement Define() method.
137: }
138:
139: /**
140: * Select Index as active 3rdParty Instance
141: *
142: * @param int $Index
143: *
144: * @return Extension
145: */
146: public function Select( $Index ) {
147: // TODO: Implement Select() method.
148: }
149:
150: /**
151: * Get Index for Select() from Current() 3rdParty Instance
152: *
153: * @return int
154: */
155: public function Index() {
156: // TODO: Implement Index() method.
157: }
158:
159: }
160: