Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101865872
PhabricatorNgramsIndexEngineExtension.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, Feb 14, 13:22
Size
762 B
Mime Type
text/x-php
Expires
Sun, Feb 16, 13:22 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24244595
Attached To
rPH Phabricator
PhabricatorNgramsIndexEngineExtension.php
View Options
<?php
final
class
PhabricatorNgramsIndexEngineExtension
extends
PhabricatorIndexEngineExtension
{
const
EXTENSIONKEY
=
'ngrams'
;
public
function
getExtensionName
()
{
return
pht
(
'Ngrams Engine'
);
}
public
function
getIndexVersion
(
$object
)
{
$ngrams
=
$object
->
newNgrams
();
$map
=
mpull
(
$ngrams
,
'getValue'
,
'getNgramKey'
);
ksort
(
$map
);
$serialized
=
serialize
(
$map
);
return
PhabricatorHash
::
digestForIndex
(
$serialized
);
}
public
function
shouldIndexObject
(
$object
)
{
return
(
$object
instanceof
PhabricatorNgramsInterface
);
}
public
function
indexObject
(
PhabricatorIndexEngine
$engine
,
$object
)
{
foreach
(
$object
->
newNgrams
()
as
$ngram
)
{
$ngram
->
writeNgram
(
$object
->
getID
());
}
}
}
Event Timeline
Log In to Comment