本文整理汇总了PHP中eZSolr::hasMetaAttributeType方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSolr::hasMetaAttributeType方法的具体用法?PHP eZSolr::hasMetaAttributeType怎么用?PHP eZSolr::hasMetaAttributeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSolr
的用法示例。
在下文中一共展示了eZSolr::hasMetaAttributeType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFieldName
/**
* Get solr field name, from base name. The base name may either be a
* meta-data name, or an eZ Publish content class attribute, specified by
* <class identifier>/<attribute identifier>[/<option>]
*
* @param string $baseName Base field name.
* @param boolean $includingClassID conditions the structure of the answer. See return value explanation.
* @param $context is introduced in ez find 2.2 to allow for more optimal sorting, faceting, filtering
*
* @return mixed Internal base name. Returns null if no valid base name was provided.
* If $includingClassID is true, an associative array will be returned, as shown below :
* <code>
* array( 'fieldName' => 'attr_title_t',
* 'contentClassId' => 16 );
* </code>
*/
static function getFieldName( $baseName, $includingClassID = false, $context = 'search' )
{
// If the base name is a meta field, get the correct field name.
if ( eZSolr::hasMetaAttributeType( $baseName, $context ) )
{
return eZSolr::getMetaFieldName( $baseName, $context );
}
else
{
// Get class and attribute identifiers + optional option.
$subattribute = null;
$fieldDef = explode( '/', $baseName );
// Check if content class attribute ID is provided.
if ( is_numeric( $fieldDef[0] ) )
{
if ( count( $fieldDef ) == 1 )
{
$contentClassAttributeID = $fieldDef[0];
}
else if ( count( $fieldDef ) == 2 )
{
list( $contentClassAttributeID, $subattribute ) = $fieldDef;
}
}
else
{
switch( count( $fieldDef ) )
{
case 1:
{
// Return fieldname as is.
return $baseName;
} break;
case 2:
{
// Field def contains class indentifier and class attribute identifier.
list( $classIdentifier, $attributeIdentifier ) = $fieldDef;
} break;
case 3:
{
// Field def contains class indentifier, class attribute identifier and optional specification.
list( $classIdentifier, $attributeIdentifier, $subattribute ) = $fieldDef;
} break;
}
$contentClassAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier( $classIdentifier . '/' . $attributeIdentifier );
}
if ( !$contentClassAttributeID )
{
eZDebug::writeNotice( 'Could not get content class from base name: ' . $baseName, __METHOD__ );
return null;
}
$contentClassAttribute = eZContentClassAttribute::fetch( $contentClassAttributeID );
$fieldName = ezfSolrDocumentFieldBase::getFieldName( $contentClassAttribute, $subattribute, $context );
if ( $includingClassID )
{
return array( 'fieldName' => $fieldName,
'contentClassId' => $contentClassAttribute->attribute( 'contentclass_id' ) );
}
else
return $fieldName;
}
}