Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezoperationmemento.php
Go to the documentation of this file.
1 <?php
17 class eZOperationMemento extends eZPersistentObject
18 {
19 public $MainMemento;
20 public $MementoData;
21 static function definition()
22 {
23 return array( 'fields' => array( 'id' => array( 'name' => 'ID',
24 'datatype' => 'integer',
25 'default' => 0,
26 'required' => true ),
27 'main' => array( 'name' => 'Main',
28 'datatype' => 'integer',
29 'default' => 0,
30 'required' => true ),
31 'memento_key' => array( 'name' => 'MementoKey',
32 'datatype' => 'string',
33 'default' => '',
34 'required' => true ),
35 'main_key' => array( 'name' => 'MainKey',
36 'datatype' => 'string',
37 'default' => '',
38 'required' => true,
39 'foreign_class' => 'eZOperationMemento',
40 'foreign_attribute' => 'memento_key',
41 'multiplicity' => '1..*' ),
42 'memento_data' => array( 'name' => 'MementoData',
43 'datatype' => 'text',
44 'default' => '',
45 'required' => true ) ),
46 'function_attributes' => array( 'main_memento' => 'mainMemento' ),
47 'keys' => array( 'id' ),
48 "increment_key" => "id",
49 'class_name' => 'eZOperationMemento',
50 'name' => 'ezoperation_memento' );
51 }
52
53 function &mainMemento()
54 {
55 if ( !isset( $this->MainMemento ) )
56 {
57 $this->MainMemento = eZOperationMemento::fetchMain( $this->attribute( 'main_key' ) );
58 }
59 return $this->MainMemento;
60 }
61
62 static function fetch( $mementoKey, $asObject = true )
63 {
64 if ( is_array( $mementoKey ) )
65 {
66 $mementoKey = eZOperationMemento::createKey( $mementoKey );
67 }
68
69 return eZPersistentObject::fetchObject( eZOperationMemento::definition(),
70 null,
71 array( 'memento_key' => $mementoKey ),
72 $asObject );
73 }
74
75 static function fetchChild( $mementoKey, $asObject = true )
76 {
77 if ( is_array( $mementoKey ) )
78 {
79 $mementoKey = eZOperationMemento::createKey( $mementoKey );
80 }
81
82 return eZPersistentObject::fetchObject( eZOperationMemento::definition(),
83 null,
84 array( 'memento_key' => $mementoKey,
85 'main' => 0 ),
86 $asObject );
87 }
88
89 static function fetchMain( $mementoKey, $asObject = true )
90 {
91 if ( is_array( $mementoKey ) )
92 {
93 $mementoKey = eZOperationMemento::createKey( $mementoKey );
94 }
95
96 return eZPersistentObject::fetchObject( eZOperationMemento::definition(),
97 null,
98 array( 'memento_key' => $mementoKey,
99 'main' => 1 ),
100 $asObject );
101 }
102
103 static function fetchList( $mementoKey, $asObject = true )
104 {
105 if ( is_array( $mementoKey ) )
106 {
107 $mementoKey = eZOperationMemento::createKey( $mementoKey );
108 }
109
110 return eZPersistentObject::fetchObjectList( eZOperationMemento::definition(),
111 null,
112 array( 'memento_key' => $mementoKey,
113 'main' => 0 ),
114 null,
115 null,
116 $asObject );
117 }
118
119 function setData( $data = array() )
120 {
121 $this->MementoData = serialize( $data );
122 }
123
124 function data()
125 {
126 return unserialize( $this->MementoData );
127 }
128
129 static function create( $mementoKey, $data = array(), $isMainKey = false, $mainKey = null )
130 {
131 if( is_array( $mementoKey ) )
132 {
133 $mementoKey = eZOperationMemento::createKey( $mementoKey );
134 }
135
136 $serializedData = serialize( $data );
137 return new eZOperationMemento( array( 'id' => null,
138 'main' => ( $isMainKey ? 1 : 0 ),
139 'memento_key' => $mementoKey,
140 'main_key' => ( $isMainKey ? $mementoKey : $mainKey ),
141 'memento_data' => $serializedData ) );
142 }
143
144 static function createKey( $parameters )
145 {
146 $string = '';
147 foreach ( $parameters as $key => $value )
148 {
149 if ( is_array( $value ) )
150 $string .= $key . serialize( $value );
151 else
152 $string .= $key . $value;
153 }
154 return md5( $string );
155 }
156
161 static function cleanup()
162 {
163 $db = eZDB::instance();
164 $db->query( "DELETE FROM ezoperation_memento" );
165 }
166
167 }
168
169 ?>
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZOperationMemento
The class eZOperationMemento does.
Definition: ezoperationmemento.php:18
eZOperationMemento\data
data()
Definition: ezoperationmemento.php:124
eZOperationMemento\setData
setData( $data=array())
Definition: ezoperationmemento.php:119
eZOperationMemento\fetchList
static fetchList( $mementoKey, $asObject=true)
Definition: ezoperationmemento.php:103
eZOperationMemento\$MainMemento
$MainMemento
Definition: ezoperationmemento.php:19
eZOperationMemento\fetch
static fetch( $mementoKey, $asObject=true)
Definition: ezoperationmemento.php:62
eZOperationMemento\definition
static definition()
Definition: ezoperationmemento.php:21
eZOperationMemento\createKey
static createKey( $parameters)
Definition: ezoperationmemento.php:144
eZOperationMemento\mainMemento
& mainMemento()
Definition: ezoperationmemento.php:53
eZOperationMemento\create
static create( $mementoKey, $data=array(), $isMainKey=false, $mainKey=null)
Definition: ezoperationmemento.php:129
eZOperationMemento\cleanup
static cleanup()
Definition: ezoperationmemento.php:161
eZOperationMemento\fetchMain
static fetchMain( $mementoKey, $asObject=true)
Definition: ezoperationmemento.php:89
eZOperationMemento\fetchChild
static fetchChild( $mementoKey, $asObject=true)
Definition: ezoperationmemento.php:75
eZOperationMemento\$MementoData
$MementoData
Definition: ezoperationmemento.php:20
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\fetchObject
static fetchObject( $def, $field_filters, $conds, $asObject=true, $grouping=null, $custom_fields=null)
Definition: ezpersistentobject.php:213
eZPersistentObject\attribute
attribute( $attr, $noFunction=false)
Definition: ezpersistentobject.php:1329
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.