-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom class-attributes indexing #222
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,6 +233,23 @@ public static function getFieldNameList( eZContentClassAttribute $classAttribute | |
} | ||
} | ||
|
||
$customAttributeMap = $eZFindIni->variable('SolrFieldMapSettings', 'CustomAttributeMap'); | ||
if ($customAttributeMap) { | ||
$identifier = $classAttribute->attribute('identifier'); | ||
$contentClass = eZContentClass::fetch($classAttribute->attribute('contentclass_id')); | ||
$identifierComposite = sprintf( | ||
'%s/%s', | ||
$contentClass->attribute('identifier'), | ||
$identifier | ||
); | ||
if (array_key_exists($identifierComposite, $customAttributeMap)) { | ||
$returnValue = call_user_func_array([$customAttributeMap[$identifierComposite], 'getFieldNameList'], [$classAttribute, $exclusiveTypeFilter]); | ||
if ($returnValue) { | ||
return $returnValue; | ||
} | ||
} | ||
} | ||
|
||
// fallback behaviour : | ||
if ( empty( $exclusiveTypeFilter ) or !in_array( self::getClassAttributeType( $classAttribute ), $exclusiveTypeFilter ) ) | ||
return array( self::getFieldName( $classAttribute ) ); | ||
|
@@ -303,7 +320,22 @@ public static function getFieldName( eZContentClassAttribute $classAttribute, $s | |
static function getInstance( eZContentObjectAttribute $objectAttribute ) | ||
{ | ||
$eZFindIni = eZINI::instance( 'ezfind.ini' ); | ||
|
||
|
||
$attributeMapList = $eZFindIni->variable('SolrFieldMapSettings', 'CustomAttributeMap'); | ||
if (!empty($attributeMapList)) { | ||
$contentClassId = $objectAttribute->attribute('contentclass_attribute')->attribute('contentclass_id'); | ||
$contentClass = eZContentClass::fetch($contentClassId); | ||
$identifierComposite = sprintf( | ||
'%s/%s', | ||
$contentClass->attribute('identifier'), | ||
$objectAttribute->attribute('contentclass_attribute_identifier') | ||
); | ||
if (array_key_exists($identifierComposite, $attributeMapList)) { | ||
return self::$singletons[$objectAttribute->attribute('id')] = new $attributeMapList[$identifierComposite]($objectAttribute); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe check if the class really exists. Not sure but trying to get an instance of a non-existing class is probably throwing a fatal error? |
||
} | ||
unset($identifierComposite, $contentClass); | ||
} | ||
|
||
$datatypeString = $objectAttribute->attribute( 'data_type_string' ); | ||
|
||
// Check if using custom handler. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1654,11 +1654,14 @@ protected function buildResultObjects( $resultArray, &$searchCount, $asObjects = | |
{ | ||
$tmpNodeRowList = array( $tmpNodeRowList ); | ||
} | ||
if ( $tmpNodeRowList ) | ||
{ | ||
foreach ( $tmpNodeRowList as $nodeRow ) | ||
{ | ||
$nodeRowList[$nodeRow['node_id']] = $nodeRow; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why it that code required? Also, it has nothing to do with what the pull request describes, right? |
||
if ($tmpNodeRowList) { | ||
if (isset($tmpNodeRowList[0])) { | ||
foreach ($tmpNodeRowList as $nodeRow) { | ||
$nodeRowList[$nodeRow['node_id']] = $nodeRow; | ||
} | ||
} else { | ||
$nodeRowList[$tmpNodeRowList['node_id']] = $tmpNodeRowList; | ||
} | ||
} | ||
unset( $tmpNodeRowList ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style is a bit off.