Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106046764
DifferentialHunkModern.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Mar 21, 20:39
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Mar 23, 20:39 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25103430
Attached To
rPH Phabricator
DifferentialHunkModern.php
View Options
<?php
final
class
DifferentialHunkModern
extends
DifferentialHunk
{
const
DATATYPE_TEXT
=
'text'
;
const
DATATYPE_FILE
=
'file'
;
const
DATAFORMAT_RAW
=
'byte'
;
const
DATAFORMAT_DEFLATE
=
'gzde'
;
protected
$dataType
;
protected
$dataEncoding
;
protected
$dataFormat
;
protected
$data
;
public
function
getTableName
()
{
return
'differential_hunk_modern'
;
}
public
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_BINARY
=>
array
(
'data'
=>
true
,
),
)
+
parent
::
getConfiguration
();
}
public
function
setChanges
(
$text
)
{
$this
->
dataEncoding
=
$this
->
detectEncodingForStorage
(
$text
);
$this
->
dataType
=
self
::
DATATYPE_TEXT
;
$this
->
dataFormat
=
self
::
DATAFORMAT_RAW
;
$this
->
data
=
$text
;
return
$this
;
}
public
function
getChanges
()
{
return
$this
->
getUTF8StringFromStorage
(
$this
->
getRawData
(),
$this
->
getDataEncoding
());
}
private
function
getRawData
()
{
$type
=
$this
->
getDataType
();
$data
=
$this
->
getData
();
switch
(
$type
)
{
case
self
::
DATATYPE_TEXT
:
// In this storage type, the changes are stored on the object.
$data
=
$data
;
break
;
case
self
::
DATATYPE_FILE
:
default
:
throw
new
Exception
(
pht
(
'Hunk has unsupported data type "%s"!'
,
$type
));
}
$format
=
$this
->
getDataFormat
();
switch
(
$format
)
{
case
self
::
DATAFORMAT_RAW
:
// In this format, the changes are stored as-is.
$data
=
$data
;
break
;
case
self
::
DATAFORMAT_DEFLATE
:
default
:
throw
new
Exception
(
pht
(
'Hunk has unsupported data encoding "%s"!'
,
$type
));
}
return
$data
;
}
}
Event Timeline
Log In to Comment