id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
44,800 | ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.purge | public static function purge( $queryString = '' , $objectID = null, $languageCode = null )
{
// check that some conditions were passed
if ( $queryString === '' and $objectID === null and $languageCode === null )
return false;
if ( $queryString !== '' )
$conds['search_query'] = $queryString;
if ( $objectID !== null )
$conds['contentobject_id'] = $objectID;
if ( $languageCode !== null )
$conds['language_code'] = $languageCode;
return parent::removeObject( self::definition(), $conds );
} | php | public static function purge( $queryString = '' , $objectID = null, $languageCode = null )
{
// check that some conditions were passed
if ( $queryString === '' and $objectID === null and $languageCode === null )
return false;
if ( $queryString !== '' )
$conds['search_query'] = $queryString;
if ( $objectID !== null )
$conds['contentobject_id'] = $objectID;
if ( $languageCode !== null )
$conds['language_code'] = $languageCode;
return parent::removeObject( self::definition(), $conds );
} | [
"public",
"static",
"function",
"purge",
"(",
"$",
"queryString",
"=",
"''",
",",
"$",
"objectID",
"=",
"null",
",",
"$",
"languageCode",
"=",
"null",
")",
"{",
"// check that some conditions were passed",
"if",
"(",
"$",
"queryString",
"===",
"''",
"and",
"... | Purges the configuration rows for a given query string, a given object, or both.
@param string $queryString Query string for which elevate configuration is removed
@param int $objectID Content object for which the elevate configuration is removed
@param string $languageCode Language code for which the elevate configuration is removed. Defaults to 'all languages' | [
"Purges",
"the",
"configuration",
"rows",
"for",
"a",
"given",
"query",
"string",
"a",
"given",
"object",
"or",
"both",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L301-L317 |
44,801 | ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.synchronizeWithSolr | public static function synchronizeWithSolr( $shard = null )
{
if ( self::generateConfiguration() )
{
try
{
self::pushConfigurationToSolr( $shard );
}
catch ( Exception $e )
{
self::$lastSynchronizationError = $e->getMessage();
eZDebug::writeError( self::$lastSynchronizationError, __METHOD__ );
return false;
}
}
else
{
$message = ezpI18n::tr( 'extension/ezfind/elevate', "Error while generating the configuration XML" );
self::$lastSynchronizationError = $message;
eZDebug::writeError( $message, __METHOD__ );
return false;
}
return true;
} | php | public static function synchronizeWithSolr( $shard = null )
{
if ( self::generateConfiguration() )
{
try
{
self::pushConfigurationToSolr( $shard );
}
catch ( Exception $e )
{
self::$lastSynchronizationError = $e->getMessage();
eZDebug::writeError( self::$lastSynchronizationError, __METHOD__ );
return false;
}
}
else
{
$message = ezpI18n::tr( 'extension/ezfind/elevate', "Error while generating the configuration XML" );
self::$lastSynchronizationError = $message;
eZDebug::writeError( $message, __METHOD__ );
return false;
}
return true;
} | [
"public",
"static",
"function",
"synchronizeWithSolr",
"(",
"$",
"shard",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"generateConfiguration",
"(",
")",
")",
"{",
"try",
"{",
"self",
"::",
"pushConfigurationToSolr",
"(",
"$",
"shard",
")",
";",
"}",
... | Synchronizes the elevate configuration stored in the DB
with the one actually used by Solr.
@return boolean true if the whole operation passed, false otherwise. | [
"Synchronizes",
"the",
"elevate",
"configuration",
"stored",
"in",
"the",
"DB",
"with",
"the",
"one",
"actually",
"used",
"by",
"Solr",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L325-L348 |
44,802 | ezsystems/ezfind | classes/ezfindelevateconfiguration.php | eZFindElevateConfiguration.getRuntimeQueryParameters | public static function getRuntimeQueryParameters( $forceElevation = false, $enableElevation = true, $searchText = '' )
{
$retArray = array( 'forceElevation' => 'false',
'enableElevation' => 'true' );
if ( $enableElevation === false or $searchText == '' )
{
$retArray['enableElevation'] = 'false';
return $retArray;
}
if ( $forceElevation === true )
{
$retArray['forceElevation'] = 'true';
}
return $retArray;
} | php | public static function getRuntimeQueryParameters( $forceElevation = false, $enableElevation = true, $searchText = '' )
{
$retArray = array( 'forceElevation' => 'false',
'enableElevation' => 'true' );
if ( $enableElevation === false or $searchText == '' )
{
$retArray['enableElevation'] = 'false';
return $retArray;
}
if ( $forceElevation === true )
{
$retArray['forceElevation'] = 'true';
}
return $retArray;
} | [
"public",
"static",
"function",
"getRuntimeQueryParameters",
"(",
"$",
"forceElevation",
"=",
"false",
",",
"$",
"enableElevation",
"=",
"true",
",",
"$",
"searchText",
"=",
"''",
")",
"{",
"$",
"retArray",
"=",
"array",
"(",
"'forceElevation'",
"=>",
"'false'... | Generates a well-formed array of elevate-related query parameters.
@param boolean $forceElevation Whether elevation should be forced or not. Parameter supported at runtime from Solr@rev:735117
Should be used when a sort array other than the default one ( 'score desc' ) is passed in the query parameters,
if one wants the elevate configuration to be actually taken into account.
@param boolean $enableElevation Whether the Elevate functionnality should be used or not. Defaults to 'true'.
@param string $searchText Workaround for an issue in Solr's QueryElevationComponent : when the search string is empty, Solr throws
an Exception and stops the request.
@return array The well-formed query parameter regarding the elevate functionnality. Example :
<code>
array( 'forceElevation' => 'true',
'enableElevation' => 'true' )
</code> | [
"Generates",
"a",
"well",
"-",
"formed",
"array",
"of",
"elevate",
"-",
"related",
"query",
"parameters",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindelevateconfiguration.php#L488-L505 |
44,803 | ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.quoteIfNeeded | static function quoteIfNeeded( $value )
{
$quote = '';
if ( strpos( $value, ' ' ) !== false )
{
$quote = '"';
if ( strpos( trim( $value ), '(' ) === 0 )
{
$quote = '';
}
}
return $quote . $value . $quote;
} | php | static function quoteIfNeeded( $value )
{
$quote = '';
if ( strpos( $value, ' ' ) !== false )
{
$quote = '"';
if ( strpos( trim( $value ), '(' ) === 0 )
{
$quote = '';
}
}
return $quote . $value . $quote;
} | [
"static",
"function",
"quoteIfNeeded",
"(",
"$",
"value",
")",
"{",
"$",
"quote",
"=",
"''",
";",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"$",
"quote",
"=",
"'\"'",
";",
"if",
"(",
"strpos",
"(",
"trim",... | Analyze the string, and decide if quotes should be added or not.
@param string String
@return string String with quotes added if needed.
@deprecated | [
"Analyze",
"the",
"string",
"and",
"decide",
"if",
"quotes",
"should",
"be",
"added",
"or",
"not",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1084-L1096 |
44,804 | ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.fieldTypeExludeList | protected function fieldTypeExludeList( $searchText )
{
if ( is_null( $searchText ) )
{
return array( 'date', 'boolean', 'int', 'long', 'float', 'double', 'sint', 'slong', 'sfloat', 'sdouble' );
}
$excludeFieldList = array();
// Check if search text is a date.
if ( strtotime( $searchText ) === false )
{
$excludeFieldList[] = 'date';
}
if ( strtolower( $searchText ) !== 'true' &&
strtolower( $searchText ) !== 'false' )
{
$excludeFieldList[] = 'boolean';
}
if ( !is_numeric( $searchText ) )
{
$excludeFieldList[] = 'int';
$excludeFieldList[] = 'long';
$excludeFieldList[] = 'float';
$excludeFieldList[] = 'double';
$excludeFieldList[] = 'sint';
$excludeFieldList[] = 'slong';
$excludeFieldList[] = 'sfloat';
$excludeFieldList[] = 'sdouble';
}
return $excludeFieldList;
} | php | protected function fieldTypeExludeList( $searchText )
{
if ( is_null( $searchText ) )
{
return array( 'date', 'boolean', 'int', 'long', 'float', 'double', 'sint', 'slong', 'sfloat', 'sdouble' );
}
$excludeFieldList = array();
// Check if search text is a date.
if ( strtotime( $searchText ) === false )
{
$excludeFieldList[] = 'date';
}
if ( strtolower( $searchText ) !== 'true' &&
strtolower( $searchText ) !== 'false' )
{
$excludeFieldList[] = 'boolean';
}
if ( !is_numeric( $searchText ) )
{
$excludeFieldList[] = 'int';
$excludeFieldList[] = 'long';
$excludeFieldList[] = 'float';
$excludeFieldList[] = 'double';
$excludeFieldList[] = 'sint';
$excludeFieldList[] = 'slong';
$excludeFieldList[] = 'sfloat';
$excludeFieldList[] = 'sdouble';
}
return $excludeFieldList;
} | [
"protected",
"function",
"fieldTypeExludeList",
"(",
"$",
"searchText",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"searchText",
")",
")",
"{",
"return",
"array",
"(",
"'date'",
",",
"'boolean'",
",",
"'int'",
",",
"'long'",
",",
"'float'",
",",
"'double'",... | Check if search string requires certain field types to be excluded from the search
@param string Search string
If null, exclude all non text fields
@todo make sure this function is in sync with schema.xml
@todo decide wether or not to drop this, pure numeric and date values are
most likely to go into filters, not the main query
@return array List of field types to exclude from the search | [
"Check",
"if",
"search",
"string",
"requires",
"certain",
"field",
"types",
"to",
"be",
"excluded",
"from",
"the",
"search"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1411-L1442 |
44,805 | ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.getContentClassFilterQuery | protected function getContentClassFilterQuery( $contentClassIdent )
{
if ( empty( $contentClassIdent ) )
{
return null;
}
if ( is_array( $contentClassIdent ) )
{
$classQueryParts = array();
foreach ( $contentClassIdent as $classID )
{
$classID = trim( $classID );
if ( empty( $classID ) )
{
continue;
}
if ( (int)$classID . '' == $classID . '' )
{
$classQueryParts[] = eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $classID;
}
elseif ( is_string( $classID ) )
{
if ( $class = eZContentClass::fetchByIdentifier( $classID ) )
{
$classQueryParts[] = eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $class->attribute( 'id' );
}
}
else
{
eZDebug::writeError( "Unknown class_id filtering parameter: $classID", __METHOD__ );
}
}
return implode( ' OR ', $classQueryParts );
}
elseif ( (int)$contentClassIdent . '' == $contentClassIdent . '' )
{
return eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $contentClassIdent;
}
elseif ( is_string( $contentClassIdent ) )
{
if ( $class = eZContentClass::fetchByIdentifier( $contentClassIdent ) )
{
return eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $class->attribute( 'id' );
}
}
eZDebug::writeError( 'No valid content class', __METHOD__ );
return null;
} | php | protected function getContentClassFilterQuery( $contentClassIdent )
{
if ( empty( $contentClassIdent ) )
{
return null;
}
if ( is_array( $contentClassIdent ) )
{
$classQueryParts = array();
foreach ( $contentClassIdent as $classID )
{
$classID = trim( $classID );
if ( empty( $classID ) )
{
continue;
}
if ( (int)$classID . '' == $classID . '' )
{
$classQueryParts[] = eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $classID;
}
elseif ( is_string( $classID ) )
{
if ( $class = eZContentClass::fetchByIdentifier( $classID ) )
{
$classQueryParts[] = eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $class->attribute( 'id' );
}
}
else
{
eZDebug::writeError( "Unknown class_id filtering parameter: $classID", __METHOD__ );
}
}
return implode( ' OR ', $classQueryParts );
}
elseif ( (int)$contentClassIdent . '' == $contentClassIdent . '' )
{
return eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $contentClassIdent;
}
elseif ( is_string( $contentClassIdent ) )
{
if ( $class = eZContentClass::fetchByIdentifier( $contentClassIdent ) )
{
return eZSolr::getMetaFieldName( 'contentclass_id' ) . ':' . $class->attribute( 'id' );
}
}
eZDebug::writeError( 'No valid content class', __METHOD__ );
return null;
} | [
"protected",
"function",
"getContentClassFilterQuery",
"(",
"$",
"contentClassIdent",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"contentClassIdent",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"contentClassIdent",
")",
")",
"{",... | Generate class query filter.
@param mixed $contentClassIdent eZContentClass id, identifier or list of ids.
@return string Content class query filter. Returns null if invalid
$contentClassIdent is provided. | [
"Generate",
"class",
"query",
"filter",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1480-L1531 |
44,806 | ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.getSectionFilterQuery | protected function getSectionFilterQuery( $sectionIdent )
{
if ( empty( $sectionIdent ) )
{
return null;
}
if ( is_array( $sectionIdent ) )
{
$sectionQueryParts = array();
foreach ( $sectionIdent as $sectionID )
{
$sectionID = trim( $sectionID );
if ( ctype_digit( $sectionID ) )
{
$sectionQueryParts[] = eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionID;
}
else
{
eZDebug::writeError( "Unknown section_id filtering parameter: $sectionID", __METHOD__ );
}
}
return implode( ' OR ', $sectionQueryParts );
}
$sectionIdent = trim( $sectionIdent );
if ( ctype_digit( $sectionIdent ) )
{
return eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionIdent;
}
eZDebug::writeError( 'No valid section id', __METHOD__ );
return null;
} | php | protected function getSectionFilterQuery( $sectionIdent )
{
if ( empty( $sectionIdent ) )
{
return null;
}
if ( is_array( $sectionIdent ) )
{
$sectionQueryParts = array();
foreach ( $sectionIdent as $sectionID )
{
$sectionID = trim( $sectionID );
if ( ctype_digit( $sectionID ) )
{
$sectionQueryParts[] = eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionID;
}
else
{
eZDebug::writeError( "Unknown section_id filtering parameter: $sectionID", __METHOD__ );
}
}
return implode( ' OR ', $sectionQueryParts );
}
$sectionIdent = trim( $sectionIdent );
if ( ctype_digit( $sectionIdent ) )
{
return eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionIdent;
}
eZDebug::writeError( 'No valid section id', __METHOD__ );
return null;
} | [
"protected",
"function",
"getSectionFilterQuery",
"(",
"$",
"sectionIdent",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"sectionIdent",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"sectionIdent",
")",
")",
"{",
"$",
"sectionQu... | Generate section query filter.
@param mixed $sectionIdent eZSection id or list of ids.
@return string Section query filter. Returns null if invalid
$sectionIdent is provided. | [
"Generate",
"section",
"query",
"filter",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1541-L1576 |
44,807 | ezsystems/ezfind | classes/ezfezpsolrquerybuilder.php | ezfeZPSolrQueryBuilder.getClassAttributes | protected function getClassAttributes( $classIDArray = false,
$classAttributeIDArray = false,
$fieldTypeExcludeList = null )
{
eZDebug::createAccumulator( 'Class attribute list', 'eZ Find' );
eZDebug::accumulatorStart( 'Class attribute list' );
$fieldArray = array();
$classAttributeArray = array();
// classAttributeIDArray = simple integer (content class attribute ID)
if ( is_numeric( $classAttributeIDArray ) and $classAttributeIDArray > 0 )
{
$classAttributeArray[] = eZContentClassAttribute::fetch( $classAttributeIDArray );
}
// classAttributeIDArray = array of integers (content class attribute IDs)
else if ( is_array( $classAttributeIDArray ) )
{
foreach ( $classAttributeIDArray as $classAttributeID )
{
$classAttributeArray[] = eZContentClassAttribute::fetch( $classAttributeID );
}
}
// no class attribute list given, we need a class list
// this block will create the class attribute array based on $classIDArray
if ( empty( $classAttributeArray ) )
{
// Fetch class list.
$condArray = array( "is_searchable" => 1,
"version" => eZContentClass::VERSION_STATUS_DEFINED );
if ( !$classIDArray )
{
$classIDArray = array();
}
else if ( !is_array( $classIDArray ) )
{
$classIDArray = array( $classIDArray );
}
// literal class identifiers are converted to numerical ones
$tmpClassIDArray = $classIDArray;
$classIDArray = array();
foreach ( $tmpClassIDArray as $key => $classIdentifier )
{
if ( !is_numeric( $classIdentifier ) )
{
if ( !$contentClass = eZContentClass::fetchByIdentifier( $classIdentifier, false ) )
{
eZDebug::writeWarning( "Unknown content class identifier '$classIdentifier'", __METHOD__ );
}
else
{
$classIDArray[] = $contentClass['id'];
}
}
else
{
$classIDArray[] = $classIdentifier;
}
}
if ( !empty( $classIDArray ) )
{
$condArray['contentclass_id'] = array( $classIDArray );
}
$classAttributeArray = eZContentClassAttribute::fetchFilteredList( $condArray );
}
// $classAttributeArray now contains a list of eZContentClassAttribute
// we can use to construct the list of fields solr should search in
// @TODO : retrieve sub attributes here. Mind the types !
foreach ( $classAttributeArray as $classAttribute )
{
$fieldArray = array_merge( ezfSolrDocumentFieldBase::getFieldNameList( $classAttribute, $fieldTypeExcludeList ), $fieldArray );
}
// the array is unified + sorted in order to make it consistent
$fieldArray = array_unique( $fieldArray );
sort( $fieldArray );
eZDebug::accumulatorStop( 'Class attribute list' );
return $fieldArray;
} | php | protected function getClassAttributes( $classIDArray = false,
$classAttributeIDArray = false,
$fieldTypeExcludeList = null )
{
eZDebug::createAccumulator( 'Class attribute list', 'eZ Find' );
eZDebug::accumulatorStart( 'Class attribute list' );
$fieldArray = array();
$classAttributeArray = array();
// classAttributeIDArray = simple integer (content class attribute ID)
if ( is_numeric( $classAttributeIDArray ) and $classAttributeIDArray > 0 )
{
$classAttributeArray[] = eZContentClassAttribute::fetch( $classAttributeIDArray );
}
// classAttributeIDArray = array of integers (content class attribute IDs)
else if ( is_array( $classAttributeIDArray ) )
{
foreach ( $classAttributeIDArray as $classAttributeID )
{
$classAttributeArray[] = eZContentClassAttribute::fetch( $classAttributeID );
}
}
// no class attribute list given, we need a class list
// this block will create the class attribute array based on $classIDArray
if ( empty( $classAttributeArray ) )
{
// Fetch class list.
$condArray = array( "is_searchable" => 1,
"version" => eZContentClass::VERSION_STATUS_DEFINED );
if ( !$classIDArray )
{
$classIDArray = array();
}
else if ( !is_array( $classIDArray ) )
{
$classIDArray = array( $classIDArray );
}
// literal class identifiers are converted to numerical ones
$tmpClassIDArray = $classIDArray;
$classIDArray = array();
foreach ( $tmpClassIDArray as $key => $classIdentifier )
{
if ( !is_numeric( $classIdentifier ) )
{
if ( !$contentClass = eZContentClass::fetchByIdentifier( $classIdentifier, false ) )
{
eZDebug::writeWarning( "Unknown content class identifier '$classIdentifier'", __METHOD__ );
}
else
{
$classIDArray[] = $contentClass['id'];
}
}
else
{
$classIDArray[] = $classIdentifier;
}
}
if ( !empty( $classIDArray ) )
{
$condArray['contentclass_id'] = array( $classIDArray );
}
$classAttributeArray = eZContentClassAttribute::fetchFilteredList( $condArray );
}
// $classAttributeArray now contains a list of eZContentClassAttribute
// we can use to construct the list of fields solr should search in
// @TODO : retrieve sub attributes here. Mind the types !
foreach ( $classAttributeArray as $classAttribute )
{
$fieldArray = array_merge( ezfSolrDocumentFieldBase::getFieldNameList( $classAttribute, $fieldTypeExcludeList ), $fieldArray );
}
// the array is unified + sorted in order to make it consistent
$fieldArray = array_unique( $fieldArray );
sort( $fieldArray );
eZDebug::accumulatorStop( 'Class attribute list' );
return $fieldArray;
} | [
"protected",
"function",
"getClassAttributes",
"(",
"$",
"classIDArray",
"=",
"false",
",",
"$",
"classAttributeIDArray",
"=",
"false",
",",
"$",
"fieldTypeExcludeList",
"=",
"null",
")",
"{",
"eZDebug",
"::",
"createAccumulator",
"(",
"'Class attribute list'",
",",... | Get an array of class attribute identifiers based on either a class attribute
list, or a content classes list
@param array $classIDArray
Classes to search in. Either an array of class ID, class identifiers,
a class ID or a class identifier.
Using numerical attribute/class identifiers for $classIDArray is more efficient.
@param array $classAttributeID
Class attributes to search in. Either an array of class attribute id,
or a single class attribute. Literal identifiers are not allowed.
@param array $fieldTypeExcludeList
filter list. List of field types to exclude. ( set to empty array by default ).
@return array List of solr field names. | [
"Get",
"an",
"array",
"of",
"class",
"attribute",
"identifiers",
"based",
"on",
"either",
"a",
"class",
"attribute",
"list",
"or",
"a",
"content",
"classes",
"list"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfezpsolrquerybuilder.php#L1801-L1884 |
44,808 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.getData | public function getData()
{
$contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$fieldNameArray = array();
foreach ( array_keys( eZSolr::$fieldTypeContexts ) as $context )
{
$fieldNameArray[] = self::getFieldName( $contentClassAttribute, null, $context );
}
$fieldNameArray = array_unique( $fieldNameArray );
$metaData = $this->ContentObjectAttribute->metaData();
$processedMetaDataArray = array();
if ( is_array( $metaData ) )
{
$processedMetaDataArray = array();
foreach ( $metaData as $value )
{
$processedMetaDataArray[] = $this->preProcessValue( $value,
self::getClassAttributeType( $contentClassAttribute ) );
}
}
else
{
$processedMetaDataArray[] = $this->preProcessValue( $metaData,
self::getClassAttributeType( $contentClassAttribute ) );
}
$fields = array();
foreach ( $fieldNameArray as $fieldName )
{
$fields[$fieldName] = $processedMetaDataArray ;
}
return $fields;
} | php | public function getData()
{
$contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$fieldNameArray = array();
foreach ( array_keys( eZSolr::$fieldTypeContexts ) as $context )
{
$fieldNameArray[] = self::getFieldName( $contentClassAttribute, null, $context );
}
$fieldNameArray = array_unique( $fieldNameArray );
$metaData = $this->ContentObjectAttribute->metaData();
$processedMetaDataArray = array();
if ( is_array( $metaData ) )
{
$processedMetaDataArray = array();
foreach ( $metaData as $value )
{
$processedMetaDataArray[] = $this->preProcessValue( $value,
self::getClassAttributeType( $contentClassAttribute ) );
}
}
else
{
$processedMetaDataArray[] = $this->preProcessValue( $metaData,
self::getClassAttributeType( $contentClassAttribute ) );
}
$fields = array();
foreach ( $fieldNameArray as $fieldName )
{
$fields[$fieldName] = $processedMetaDataArray ;
}
return $fields;
} | [
"public",
"function",
"getData",
"(",
")",
"{",
"$",
"contentClassAttribute",
"=",
"$",
"this",
"->",
"ContentObjectAttribute",
"->",
"attribute",
"(",
"'contentclass_attribute'",
")",
";",
"$",
"fieldNameArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"a... | Get data to index, and field name to use.
@since ez find 2.2: indexed values to be context aware
different fields may be used for searching, sorting and faceting
@return array Associative array with field name and field value.
Field value can be an array.
Example 1:
<code>
array( 'field_name_i' => 123 );
</code>
Example 2:
<code>
array( 'field_name_i' => array( "1", 2, '3' ) );
</code> | [
"Get",
"data",
"to",
"index",
"and",
"field",
"name",
"to",
"use",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L54-L90 |
44,809 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.getClassAttributeType | static function getClassAttributeType( eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search' )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
// Subattribute-related behaviour here.
$datatypeString = $classAttribute->attribute( 'data_type_string' );
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( array_key_exists( $datatypeString, $customMapList ) )
{
if ( self::isStaticDelegationAllowed( $customMapList[$datatypeString], 'getClassAttributeType' ) and
( $returnValue = call_user_func_array( array( $customMapList[$datatypeString], 'getClassAttributeType' ),
array( $classAttribute, $subAttribute, $context ) ) )
)
{
return $returnValue;
}
}
// Fallback #1: single-fielded datatype behaviour here.
$datatypeMapList = $eZFindIni->variable( 'SolrFieldMapSettings', eZSolr::$fieldTypeContexts[$context] );
if ( !empty( $datatypeMapList[$classAttribute->attribute( 'data_type_string' )] ) )
{
return $datatypeMapList[$classAttribute->attribute( 'data_type_string' )];
}
// Fallback #2: search field datatypemap (pre ezfind 2.2 behaviour)
$datatypeMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'DatatypeMap' );
if ( !empty( $datatypeMapList[$classAttribute->attribute( 'data_type_string' )] ) )
{
return $datatypeMapList[$classAttribute->attribute( 'data_type_string' )];
}
// Fallback #3: return default field.
return $eZFindIni->variable( 'SolrFieldMapSettings', 'Default' );
} | php | static function getClassAttributeType( eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search' )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
// Subattribute-related behaviour here.
$datatypeString = $classAttribute->attribute( 'data_type_string' );
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( array_key_exists( $datatypeString, $customMapList ) )
{
if ( self::isStaticDelegationAllowed( $customMapList[$datatypeString], 'getClassAttributeType' ) and
( $returnValue = call_user_func_array( array( $customMapList[$datatypeString], 'getClassAttributeType' ),
array( $classAttribute, $subAttribute, $context ) ) )
)
{
return $returnValue;
}
}
// Fallback #1: single-fielded datatype behaviour here.
$datatypeMapList = $eZFindIni->variable( 'SolrFieldMapSettings', eZSolr::$fieldTypeContexts[$context] );
if ( !empty( $datatypeMapList[$classAttribute->attribute( 'data_type_string' )] ) )
{
return $datatypeMapList[$classAttribute->attribute( 'data_type_string' )];
}
// Fallback #2: search field datatypemap (pre ezfind 2.2 behaviour)
$datatypeMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'DatatypeMap' );
if ( !empty( $datatypeMapList[$classAttribute->attribute( 'data_type_string' )] ) )
{
return $datatypeMapList[$classAttribute->attribute( 'data_type_string' )];
}
// Fallback #3: return default field.
return $eZFindIni->variable( 'SolrFieldMapSettings', 'Default' );
} | [
"static",
"function",
"getClassAttributeType",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"subAttribute",
"=",
"null",
",",
"$",
"context",
"=",
"'search'",
")",
"{",
"$",
"eZFindIni",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezfind.ini'",
")... | Get Solr schema field type from eZContentClassAttribute.
Available field types are:
- string - Unprocessed text
- boolean - Boolean
- int - Integer, not sortable
- long - Long, not sortable
- float - Float, not sortable
- double - Double, not sortable
- sint - Integer, sortable
- slong - Long, sortable
- sfloat - Float, sortable
- sdouble - Double, sortable
- date - Date, see also: http://www.w3.org/TR/xmlschema-2/#dateTime
- text - Text, processed and allows fuzzy matches.
- textTight - Text, less filters are applied than for the text datatype.
@see ezfSolrDocumentFieldName::$FieldTypeMap
@param eZContentClassAttribute Instance of eZContentClassAttribute.
@param $subAttribute string In case the type of a datatype's sub-attribute is requested,
the subattribute's name is passed here.
@return string Field type. Null if no field type is defined. | [
"Get",
"Solr",
"schema",
"field",
"type",
"from",
"eZContentClassAttribute",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L172-L204 |
44,810 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.getFieldNameList | public static function getFieldNameList( eZContentClassAttribute $classAttribute, $exclusiveTypeFilter = array() )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
$datatypeString = $classAttribute->attribute( 'data_type_string' );
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( array_key_exists( $datatypeString, $customMapList ) )
{
if ( self::isStaticDelegationAllowed( $customMapList[$datatypeString], 'getFieldNameList' ) and
( $returnValue = call_user_func_array( array( $customMapList[$datatypeString], 'getFieldNameList' ),
array( $classAttribute, $exclusiveTypeFilter ) ) )
)
{
return $returnValue;
}
}
// fallback behaviour :
if ( empty( $exclusiveTypeFilter ) or !in_array( self::getClassAttributeType( $classAttribute ), $exclusiveTypeFilter ) )
return array( self::getFieldName( $classAttribute ) );
else
return array();
} | php | public static function getFieldNameList( eZContentClassAttribute $classAttribute, $exclusiveTypeFilter = array() )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
$datatypeString = $classAttribute->attribute( 'data_type_string' );
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( array_key_exists( $datatypeString, $customMapList ) )
{
if ( self::isStaticDelegationAllowed( $customMapList[$datatypeString], 'getFieldNameList' ) and
( $returnValue = call_user_func_array( array( $customMapList[$datatypeString], 'getFieldNameList' ),
array( $classAttribute, $exclusiveTypeFilter ) ) )
)
{
return $returnValue;
}
}
// fallback behaviour :
if ( empty( $exclusiveTypeFilter ) or !in_array( self::getClassAttributeType( $classAttribute ), $exclusiveTypeFilter ) )
return array( self::getFieldName( $classAttribute ) );
else
return array();
} | [
"public",
"static",
"function",
"getFieldNameList",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"exclusiveTypeFilter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"eZFindIni",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezfind.ini'",
")",
";",
"$",
... | Gets the list of solr fields for the given content class attribute. Delegates
the action to the datatype-specific handler, if any. If none, the datatype has one
field only, hence the delegation to the local getFieldName.
@param eZContentClassAttribute $classAttribute
@param array $exclusiveTypeFilter Array of types ( strings ) which should be excluded
from the result.
@return array Array of applicable solr field names
@see ezfSolrDocumentFieldBase::getFieldName() | [
"Gets",
"the",
"list",
"of",
"solr",
"fields",
"for",
"the",
"given",
"content",
"class",
"attribute",
".",
"Delegates",
"the",
"action",
"to",
"the",
"datatype",
"-",
"specific",
"handler",
"if",
"any",
".",
"If",
"none",
"the",
"datatype",
"has",
"one",
... | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L218-L241 |
44,811 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.getInstance | static function getInstance( eZContentObjectAttribute $objectAttribute )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
$datatypeString = $objectAttribute->attribute( 'data_type_string' );
// Check if using custom handler.
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( isset( $customMapList[$datatypeString] ) )
{
$fieldBaseClass = $customMapList[$datatypeString];
if ( class_exists( $fieldBaseClass ) )
{
return new $fieldBaseClass( $objectAttribute );
}
else
{
eZDebug::writeError( "Unknown document field base class '$fieldBaseClass' for datatype '$datatypeString', check your ezfind.ini configuration", __METHOD__ );
}
}
// Return standard handler.
return new ezfSolrDocumentFieldBase( $objectAttribute );
} | php | static function getInstance( eZContentObjectAttribute $objectAttribute )
{
$eZFindIni = eZINI::instance( 'ezfind.ini' );
$datatypeString = $objectAttribute->attribute( 'data_type_string' );
// Check if using custom handler.
$customMapList = $eZFindIni->variable( 'SolrFieldMapSettings', 'CustomMap' );
if ( isset( $customMapList[$datatypeString] ) )
{
$fieldBaseClass = $customMapList[$datatypeString];
if ( class_exists( $fieldBaseClass ) )
{
return new $fieldBaseClass( $objectAttribute );
}
else
{
eZDebug::writeError( "Unknown document field base class '$fieldBaseClass' for datatype '$datatypeString', check your ezfind.ini configuration", __METHOD__ );
}
}
// Return standard handler.
return new ezfSolrDocumentFieldBase( $objectAttribute );
} | [
"static",
"function",
"getInstance",
"(",
"eZContentObjectAttribute",
"$",
"objectAttribute",
")",
"{",
"$",
"eZFindIni",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezfind.ini'",
")",
";",
"$",
"datatypeString",
"=",
"$",
"objectAttribute",
"->",
"attribute",
"(",
"... | Returns instance of ezfSolrDocumentFieldBase based on the eZContentObjectAttribute
provided.
To override the standard class ezfSolrDocumentFieldBase, specify in the configuration
files which sub-class which should be used.
@param eZContentObjectAttribute Instance of eZContentObjectAttribute.
@return ezfSolrDocumentFieldBase Instance of ezfSolrDocumentFieldBase. | [
"Returns",
"instance",
"of",
"ezfSolrDocumentFieldBase",
"based",
"on",
"the",
"eZContentObjectAttribute",
"provided",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L303-L326 |
44,812 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.preProcessValue | static function preProcessValue( $value, $fieldType )
{
switch( $fieldType )
{
case 'date':
{
if ( is_numeric( $value ) )
{
$value = self::convertTimestampToDate( $value );
}
// Flag this as not to index
else
{
$value = null;
}
} break;
case 'boolean':
{
if ( is_numeric( $value ) )
{
$value = $value ? 'true' : 'false';
}
} break;
default:
{
// Do nothing yet.
} break;
}
return $value;
} | php | static function preProcessValue( $value, $fieldType )
{
switch( $fieldType )
{
case 'date':
{
if ( is_numeric( $value ) )
{
$value = self::convertTimestampToDate( $value );
}
// Flag this as not to index
else
{
$value = null;
}
} break;
case 'boolean':
{
if ( is_numeric( $value ) )
{
$value = $value ? 'true' : 'false';
}
} break;
default:
{
// Do nothing yet.
} break;
}
return $value;
} | [
"static",
"function",
"preProcessValue",
"(",
"$",
"value",
",",
"$",
"fieldType",
")",
"{",
"switch",
"(",
"$",
"fieldType",
")",
"{",
"case",
"'date'",
":",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"self",
... | Preprocess value to make sure it complies to the
requirements Solr has to the different field types.
@param mixed Value
@param string Fielt type
@return moxed Processed value | [
"Preprocess",
"value",
"to",
"make",
"sure",
"it",
"complies",
"to",
"the",
"requirements",
"Solr",
"has",
"to",
"the",
"different",
"field",
"types",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L337-L370 |
44,813 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.generateSubattributeFieldName | public static function generateSubattributeFieldName( eZContentClassAttribute $classAttribute, $subfieldName, $type )
{
// base name of subfields ends with self::SUBATTR_FIELD_PREFIX so
// that it's possible to differentiate those fields in schema.xml
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::SUBATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' )
. self::SUBATTR_FIELD_SEPARATOR . $subfieldName . self::SUBATTR_FIELD_SEPARATOR,
$type );
} | php | public static function generateSubattributeFieldName( eZContentClassAttribute $classAttribute, $subfieldName, $type )
{
// base name of subfields ends with self::SUBATTR_FIELD_PREFIX so
// that it's possible to differentiate those fields in schema.xml
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::SUBATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' )
. self::SUBATTR_FIELD_SEPARATOR . $subfieldName . self::SUBATTR_FIELD_SEPARATOR,
$type );
} | [
"public",
"static",
"function",
"generateSubattributeFieldName",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"subfieldName",
",",
"$",
"type",
")",
"{",
"// base name of subfields ends with self::SUBATTR_FIELD_PREFIX so",
"// that it's possible to differentiate... | Generates the full Solr field name for a datatype's subattribute.
Helper method to be used, if needed, by datatype-specific handlers.
@see ezfSolrDocumentFieldDummyExample
@param eZContentClassAttribute $classAttribute
@param string $subfieldName
@param string $type The fully qualified type. It must be picked amongst
the keys of the ezfSolrDocumentFieldName::$FieldTypeMap array.
@return string | [
"Generates",
"the",
"full",
"Solr",
"field",
"name",
"for",
"a",
"datatype",
"s",
"subattribute",
".",
"Helper",
"method",
"to",
"be",
"used",
"if",
"needed",
"by",
"datatype",
"-",
"specific",
"handlers",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L399-L408 |
44,814 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.generateAttributeFieldName | public static function generateAttributeFieldName( eZContentClassAttribute $classAttribute, $type )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::ATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ),
$type );
} | php | public static function generateAttributeFieldName( eZContentClassAttribute $classAttribute, $type )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::ATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ),
$type );
} | [
"public",
"static",
"function",
"generateAttributeFieldName",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"type",
")",
"{",
"$",
"documentFieldName",
"=",
"self",
"::",
"getDocumentFieldName",
"(",
")",
";",
"return",
"$",
"documentFieldName",
"... | Generates the full Solr field name for an attribute.
Helper method to be used, if needed, by datatype-specific handlers.
@see ezfSolrDocumentFieldDummyExample
@param eZContentClassAttribute $classAttribute
@param string $type The fully qualified type. It must be picked amongst
the keys of the ezfSolrDocumentFieldName::$FieldTypeMap array.
@return string | [
"Generates",
"the",
"full",
"Solr",
"field",
"name",
"for",
"an",
"attribute",
".",
"Helper",
"method",
"to",
"be",
"used",
"if",
"needed",
"by",
"datatype",
"-",
"specific",
"handlers",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L422-L428 |
44,815 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.generateMetaFieldName | public static function generateMetaFieldName( $baseName, $context = 'search' )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::META_FIELD_PREFIX . $baseName,
eZSolr::getMetaAttributeType( $baseName, $context ) );
} | php | public static function generateMetaFieldName( $baseName, $context = 'search' )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::META_FIELD_PREFIX . $baseName,
eZSolr::getMetaAttributeType( $baseName, $context ) );
} | [
"public",
"static",
"function",
"generateMetaFieldName",
"(",
"$",
"baseName",
",",
"$",
"context",
"=",
"'search'",
")",
"{",
"$",
"documentFieldName",
"=",
"self",
"::",
"getDocumentFieldName",
"(",
")",
";",
"return",
"$",
"documentFieldName",
"->",
"lookupSc... | Generates the full Solr field name for a metadata attribute.
Helper method to be used, if needed, by datatype-specific handlers.
It is used in the search plugin eZSolr.
@param string $baseName
@return string
@example
If $baseName equals 'main_url_alias',
the return value will be : 'meta_main_url_alias_s' | [
"Generates",
"the",
"full",
"Solr",
"field",
"name",
"for",
"a",
"metadata",
"attribute",
".",
"Helper",
"method",
"to",
"be",
"used",
"if",
"needed",
"by",
"datatype",
"-",
"specific",
"handlers",
".",
"It",
"is",
"used",
"in",
"the",
"search",
"plugin",
... | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L442-L448 |
44,816 | ezsystems/ezfind | classes/ezfsolrdocumentfieldbase.php | ezfSolrDocumentFieldBase.generateSubmetaFieldName | public static function generateSubmetaFieldName( $baseName, eZContentClassAttribute $classAttribute )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::SUBMETA_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ) . self::SUBATTR_FIELD_SEPARATOR . $baseName . self::SUBATTR_FIELD_SEPARATOR,
eZSolr::getMetaAttributeType( $baseName ) );
} | php | public static function generateSubmetaFieldName( $baseName, eZContentClassAttribute $classAttribute )
{
$documentFieldName = self::getDocumentFieldName();
return $documentFieldName->lookupSchemaName( self::SUBMETA_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ) . self::SUBATTR_FIELD_SEPARATOR . $baseName . self::SUBATTR_FIELD_SEPARATOR,
eZSolr::getMetaAttributeType( $baseName ) );
} | [
"public",
"static",
"function",
"generateSubmetaFieldName",
"(",
"$",
"baseName",
",",
"eZContentClassAttribute",
"$",
"classAttribute",
")",
"{",
"$",
"documentFieldName",
"=",
"self",
"::",
"getDocumentFieldName",
"(",
")",
";",
"return",
"$",
"documentFieldName",
... | Generates the full Solr field name for a metadata subattribute.
Helper method to be used, if needed, by datatype-specific handlers.
Used particularly when indexing metadata of a related object.
@param string $baseName
@param eZContentClassAttribute $classAttribute
@return string
@example
If $baseName equals 'main_url_alias', and $classAttribute
has as identifier 'dummy', the return value will be :
'submeta_dummy-main_url_alias_s'
@see ezfSolrDocumentFieldObjectRelation | [
"Generates",
"the",
"full",
"Solr",
"field",
"name",
"for",
"a",
"metadata",
"subattribute",
".",
"Helper",
"method",
"to",
"be",
"used",
"if",
"needed",
"by",
"datatype",
"-",
"specific",
"handlers",
".",
"Used",
"particularly",
"when",
"indexing",
"metadata"... | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldbase.php#L466-L472 |
44,817 | ezsystems/ezfind | classes/ezsolrdoc.php | eZSolrDoc.setBoost | public function setBoost ( $boost = null )
{
if ( $boost !== null && is_numeric( $boost ))
{
$this->DocBoost = $boost;
}
} | php | public function setBoost ( $boost = null )
{
if ( $boost !== null && is_numeric( $boost ))
{
$this->DocBoost = $boost;
}
} | [
"public",
"function",
"setBoost",
"(",
"$",
"boost",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"boost",
"!==",
"null",
"&&",
"is_numeric",
"(",
"$",
"boost",
")",
")",
"{",
"$",
"this",
"->",
"DocBoost",
"=",
"$",
"boost",
";",
"}",
"}"
] | Set document boost
@param float Document boost | [
"Set",
"document",
"boost"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrdoc.php#L66-L72 |
44,818 | ezsystems/ezfind | classes/ezsolrdoc.php | eZSolrDoc.addField | public function addField ( $name, $content, $boost = null )
{
if ( !is_array( $content ) )
{
$content = array( $content );
}
if (array_key_exists($name, $this->Doc))
{
$this->Doc[$name]['content'] = array_merge($this->Doc[$name]['content'], $content);
}
else
{
$this->Doc[$name]['content'] = $content;
}
$this->Doc[$name]['boost'] = $boost;
} | php | public function addField ( $name, $content, $boost = null )
{
if ( !is_array( $content ) )
{
$content = array( $content );
}
if (array_key_exists($name, $this->Doc))
{
$this->Doc[$name]['content'] = array_merge($this->Doc[$name]['content'], $content);
}
else
{
$this->Doc[$name]['content'] = $content;
}
$this->Doc[$name]['boost'] = $boost;
} | [
"public",
"function",
"addField",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"boost",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"$",
"content",
"=",
"array",
"(",
"$",
"content",
")",
";",
"}",
... | Add document field
@param string Field name
@param mixed Field content. $content may be a value or an array containing values.
if the the array has more than one element, the schema declaration must be multi-valued too
@param float Field boost ( optional ). | [
"Add",
"document",
"field"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrdoc.php#L82-L98 |
44,819 | ezsystems/ezfind | classes/ezsolrdoc.php | eZSolrDoc.docToXML | function docToXML()
{
$this->DomDoc = new DOMDocument( '1.0', 'utf-8' );
$this->DomRootElement = $this->DomDoc->createElement( 'doc' );
$this->DomDoc->appendChild( $this->DomRootElement );
if ($this->DocBoost !== null && is_numeric( $this->DocBoost ) )
{
// This will force the '.' as decimal separator and not depend on the locale
$docBoost = sprintf('%F',$this->DocBoost);
$this->DomRootElement->setAttribute( 'boost', $docBoost );
}
foreach ($this->Doc as $name => $field) {
foreach( $field['content'] as $value )
{
// $value should never be array. Log the value and the stack trace.
if ( is_array( $value ) )
{
$backtrace = debug_backtrace();
$dump = array( $backtrace[0], $backtrace[1] );
eZDebug::writeError( 'Tried to index array value: ' . $name . "\nValue: " . var_export( $value, 1 ) .
"\nStack trace: " . var_export( $dump, 1 ) );
continue;
}
$fieldElement = $this->DomDoc->createElement( 'field' );
$fieldElement->appendChild( $this->DomDoc->createTextNode( $value ) );
$fieldElement->setAttribute( 'name', $name );
if ( $field['boost'] !== null && is_numeric( $field['boost'] ) )
{
$fieldElement->setAttribute( 'boost', $field['boost'] );
}
$this->DomRootElement->appendChild( $fieldElement );
}
}
$rawXML = $this->DomDoc->saveXML( $this->DomRootElement );
//make sure there are no control characters left that could currupt the XML string
return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $rawXML);
} | php | function docToXML()
{
$this->DomDoc = new DOMDocument( '1.0', 'utf-8' );
$this->DomRootElement = $this->DomDoc->createElement( 'doc' );
$this->DomDoc->appendChild( $this->DomRootElement );
if ($this->DocBoost !== null && is_numeric( $this->DocBoost ) )
{
// This will force the '.' as decimal separator and not depend on the locale
$docBoost = sprintf('%F',$this->DocBoost);
$this->DomRootElement->setAttribute( 'boost', $docBoost );
}
foreach ($this->Doc as $name => $field) {
foreach( $field['content'] as $value )
{
// $value should never be array. Log the value and the stack trace.
if ( is_array( $value ) )
{
$backtrace = debug_backtrace();
$dump = array( $backtrace[0], $backtrace[1] );
eZDebug::writeError( 'Tried to index array value: ' . $name . "\nValue: " . var_export( $value, 1 ) .
"\nStack trace: " . var_export( $dump, 1 ) );
continue;
}
$fieldElement = $this->DomDoc->createElement( 'field' );
$fieldElement->appendChild( $this->DomDoc->createTextNode( $value ) );
$fieldElement->setAttribute( 'name', $name );
if ( $field['boost'] !== null && is_numeric( $field['boost'] ) )
{
$fieldElement->setAttribute( 'boost', $field['boost'] );
}
$this->DomRootElement->appendChild( $fieldElement );
}
}
$rawXML = $this->DomDoc->saveXML( $this->DomRootElement );
//make sure there are no control characters left that could currupt the XML string
return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $rawXML);
} | [
"function",
"docToXML",
"(",
")",
"{",
"$",
"this",
"->",
"DomDoc",
"=",
"new",
"DOMDocument",
"(",
"'1.0'",
",",
"'utf-8'",
")",
";",
"$",
"this",
"->",
"DomRootElement",
"=",
"$",
"this",
"->",
"DomDoc",
"->",
"createElement",
"(",
"'doc'",
")",
";",... | Convert current object to XML string
@return string XML string. | [
"Convert",
"current",
"object",
"to",
"XML",
"string"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezsolrdoc.php#L113-L155 |
44,820 | ezsystems/ezfind | classes/solrstorage/ezmatrixsolrstorage.php | ezmatrixSolrStorage.getAttributeContent | public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
{
$rows = $contentObjectAttribute->content()->attribute( 'rows' );
$target = array(
'has_rendered_content' => false,
'rendered' => null,
'content' => array()
);
foreach( $rows['sequential'] as $elt )
{
$target['content'][] = $elt['columns'];
}
return $target;
} | php | public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
{
$rows = $contentObjectAttribute->content()->attribute( 'rows' );
$target = array(
'has_rendered_content' => false,
'rendered' => null,
'content' => array()
);
foreach( $rows['sequential'] as $elt )
{
$target['content'][] = $elt['columns'];
}
return $target;
} | [
"public",
"static",
"function",
"getAttributeContent",
"(",
"eZContentObjectAttribute",
"$",
"contentObjectAttribute",
",",
"eZContentClassAttribute",
"$",
"contentClassAttribute",
")",
"{",
"$",
"rows",
"=",
"$",
"contentObjectAttribute",
"->",
"content",
"(",
")",
"->... | Returns the content of the matrix to be stored in Solr
@param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
@param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
@return array | [
"Returns",
"the",
"content",
"of",
"the",
"matrix",
"to",
"be",
"stored",
"in",
"Solr"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/solrstorage/ezmatrixsolrstorage.php#L22-L35 |
44,821 | ezsystems/ezfind | classes/ezfindextendedattributefilterfactory.php | eZFindExtendedAttributeFilterFactory.getInstance | public static function getInstance( $filterID )
{
if( !isset( self::$instances[$filterID] ) )
{
try
{
if( !self::$filtersList )
{
$ini = eZINI::instance( 'ezfind.ini' );
self::$filtersList = $ini->variable( 'ExtendedAttributeFilters', 'FiltersList' );
}
if( !isset( self::$filtersList[$filterID] ) )
{
throw new Exception( $filterID . ' extended attribute filter is not defined' );
}
$className = self::$filtersList[$filterID];
if( !class_exists( $className ) )
{
throw new Exception( 'Could not find class ' . $className );
}
$instance = new $className();
if( !$instance instanceof eZFindExtendedAttributeFilterInterface )
{
throw new Exception( $className . ' is not a valid eZFindExtendedAttributeFilterInterface' );
}
self::$instances[$filterID] = $instance;
}
catch( Exception $e)
{
eZDebug::writeWarning( $e->getMessage(), __METHOD__ );
self::$instances[$filterID] = false;
}
}
return self::$instances[$filterID];
} | php | public static function getInstance( $filterID )
{
if( !isset( self::$instances[$filterID] ) )
{
try
{
if( !self::$filtersList )
{
$ini = eZINI::instance( 'ezfind.ini' );
self::$filtersList = $ini->variable( 'ExtendedAttributeFilters', 'FiltersList' );
}
if( !isset( self::$filtersList[$filterID] ) )
{
throw new Exception( $filterID . ' extended attribute filter is not defined' );
}
$className = self::$filtersList[$filterID];
if( !class_exists( $className ) )
{
throw new Exception( 'Could not find class ' . $className );
}
$instance = new $className();
if( !$instance instanceof eZFindExtendedAttributeFilterInterface )
{
throw new Exception( $className . ' is not a valid eZFindExtendedAttributeFilterInterface' );
}
self::$instances[$filterID] = $instance;
}
catch( Exception $e)
{
eZDebug::writeWarning( $e->getMessage(), __METHOD__ );
self::$instances[$filterID] = false;
}
}
return self::$instances[$filterID];
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"filterID",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"filterID",
"]",
")",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"filtersList",
")"... | Get singleton instance for filter
@param string $filterID
@return eZFindExtendedAttributeFilterInterface|false | [
"Get",
"singleton",
"instance",
"for",
"filter"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfindextendedattributefilterfactory.php#L32-L71 |
44,822 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.getMetaAttributesForObject | public static function getMetaAttributesForObject( eZContentObject $object )
{
$metaAttributeValues = array();
foreach ( self::metaAttributes() as $attributeName => $fieldType )
{
$metaAttributeValues[] = array( 'name' => $attributeName,
'value' => $object->attribute( $attributeName ),
'fieldType' => $fieldType );
}
return $metaAttributeValues;
} | php | public static function getMetaAttributesForObject( eZContentObject $object )
{
$metaAttributeValues = array();
foreach ( self::metaAttributes() as $attributeName => $fieldType )
{
$metaAttributeValues[] = array( 'name' => $attributeName,
'value' => $object->attribute( $attributeName ),
'fieldType' => $fieldType );
}
return $metaAttributeValues;
} | [
"public",
"static",
"function",
"getMetaAttributesForObject",
"(",
"eZContentObject",
"$",
"object",
")",
"{",
"$",
"metaAttributeValues",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"metaAttributes",
"(",
")",
"as",
"$",
"attributeName",
"=>",
... | Fetches the meta attributes for a given content object
and fill the structure described below.
@param eZContentObject $object
@return array
<code>
array(
array( 'name' => 'id'
'value' => 82
'fieldType' => 'sint' ),
...
)
</code>
@see eZSolr::metaAttributes() | [
"Fetches",
"the",
"meta",
"attributes",
"for",
"a",
"given",
"content",
"object",
"and",
"fill",
"the",
"structure",
"described",
"below",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L71-L81 |
44,823 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.getMetaAttributeType | static function getMetaAttributeType( $name, $context = 'search' )
{
$attributeList = array( 'search' => array_merge( array( 'guid' => 'mstring',
'installation_id' => 'mstring',
'installation_url' => 'mstring',
'name' => 'text',
'sort_name' => 'mstring',
'anon_access' => 'boolean',
'language_code' => 'mstring',
'available_language_codes' => 'mstring',
'main_url_alias' => 'mstring',
'main_path_string' => 'mstring',
'owner_name' => 'text',
'owner_group_id' => 'sint',
'path' => 'sint',
'object_states' => 'sint',
'visible_path' => 'sint',
'hidden_path' => 'sint',
'visible_path_string' => 'mstring',
'hidden_path_string' => 'mstring' ),
self::metaAttributes(),
self::nodeAttributes() ),
'facet' => array(
'owner_name' => 'string' ),
'filter' => array(),
'sort' => array() );
if ( ! empty( $attributeList[$context][$name] ) )
{
return $attributeList[$context][$name];
}
elseif ( ! empty( $attributeList['search'][$name] ) )
{
return $attributeList['search'][$name];
}
else
{
return null;
}
//return $attributeList[$name];
} | php | static function getMetaAttributeType( $name, $context = 'search' )
{
$attributeList = array( 'search' => array_merge( array( 'guid' => 'mstring',
'installation_id' => 'mstring',
'installation_url' => 'mstring',
'name' => 'text',
'sort_name' => 'mstring',
'anon_access' => 'boolean',
'language_code' => 'mstring',
'available_language_codes' => 'mstring',
'main_url_alias' => 'mstring',
'main_path_string' => 'mstring',
'owner_name' => 'text',
'owner_group_id' => 'sint',
'path' => 'sint',
'object_states' => 'sint',
'visible_path' => 'sint',
'hidden_path' => 'sint',
'visible_path_string' => 'mstring',
'hidden_path_string' => 'mstring' ),
self::metaAttributes(),
self::nodeAttributes() ),
'facet' => array(
'owner_name' => 'string' ),
'filter' => array(),
'sort' => array() );
if ( ! empty( $attributeList[$context][$name] ) )
{
return $attributeList[$context][$name];
}
elseif ( ! empty( $attributeList['search'][$name] ) )
{
return $attributeList['search'][$name];
}
else
{
return null;
}
//return $attributeList[$name];
} | [
"static",
"function",
"getMetaAttributeType",
"(",
"$",
"name",
",",
"$",
"context",
"=",
"'search'",
")",
"{",
"$",
"attributeList",
"=",
"array",
"(",
"'search'",
"=>",
"array_merge",
"(",
"array",
"(",
"'guid'",
"=>",
"'mstring'",
",",
"'installation_id'",
... | Get meta attribute Solr document field type
@param string name Meta attribute name
@param string context search, facet, filter, sort
@return string Solr document field type. Null if meta attribute type does not exists. | [
"Get",
"meta",
"attribute",
"Solr",
"document",
"field",
"type"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L110-L151 |
44,824 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.getNodeID | protected function getNodeID( $doc )
{
$docPathStrings = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'path_string' )];
$docVisibilities = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'is_invisible' )];
if ( count( $docPathStrings ) > 1 )
{
// reordering the path strings and the associated visibilities so
// that the main node path string and the main node visibility are
// in the first position.
$mainNodeIdx = array_search(
$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_path_string' )],
$docPathStrings
);
if ( $mainNodeIdx != 0 )
{
array_unshift( $docVisibilities, $docVisibilities[$mainNodeIdx] );
array_unshift( $docPathStrings, $docPathStrings[$mainNodeIdx] );
// adding +1 to indexing because of array_unshift
unset( $docVisibilities[$mainNodeIdx + 1], $docPathStrings[$mainNodeIdx + 1] );
}
}
$locationFilter = isset( $this->postSearchProcessingData['subtree_array'] ) ? $this->postSearchProcessingData['subtree_array'] : array();
$subtreeLimitations = isset( $this->postSearchProcessingData['subtree_limitations'] ) ? $this->postSearchProcessingData['subtree_limitations'] : array();
$validSubtreeArray = $this->getValidPathStringsByLimitation(
$docPathStrings,
$locationFilter
);
$validSubtreeLimitations = $this->getValidPathStringsByLimitation(
$docPathStrings,
$subtreeLimitations
);
$ignoreVisibility = eZContentObjectTreeNode::showInvisibleNodes();
if ( isset( $this->postSearchProcessingData['ignore_visibility'] ) )
{
$ignoreVisibility = $this->postSearchProcessingData['ignore_visibility'];
}
// Intersect between $validSubtreeArray (search location filter) and $validSubtreeLimitations (user policy limitations)
// indicates valid locations for $doc in current search query
// If this intersect is not empty, we take the first node id that
// matches the visibility requirement
$validSubtrees = array_flip(
array_intersect( $validSubtreeArray, $validSubtreeLimitations )
);
if ( !empty( $validSubtrees ) )
{
foreach ( $docPathStrings as $k => $path )
{
if ( isset( $validSubtrees[$path] ) )
{
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
}
}
}
// Could not find a visible location for content that current user has read access on.
return null;
}
else
{
$contentId = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'id' )];
$content = eZContentObject::fetch( $contentId );
if ( $content instanceof eZContentObject && !$content->canRead() )
{
eZDebug::writeError(
"Could not find valid/granted locations for content #$contentId. Broken sync between eZPublish and Solr ?\n\n" .
"Location filter : " . print_r( $locationFilter, true ) .
"Subtree limitations for user : " . print_r( $subtreeLimitations, true ),
__METHOD__
);
}
foreach ( $docPathStrings as $k => $path )
{
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
}
}
}
return (int)$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_node_id' )];
} | php | protected function getNodeID( $doc )
{
$docPathStrings = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'path_string' )];
$docVisibilities = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'is_invisible' )];
if ( count( $docPathStrings ) > 1 )
{
// reordering the path strings and the associated visibilities so
// that the main node path string and the main node visibility are
// in the first position.
$mainNodeIdx = array_search(
$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_path_string' )],
$docPathStrings
);
if ( $mainNodeIdx != 0 )
{
array_unshift( $docVisibilities, $docVisibilities[$mainNodeIdx] );
array_unshift( $docPathStrings, $docPathStrings[$mainNodeIdx] );
// adding +1 to indexing because of array_unshift
unset( $docVisibilities[$mainNodeIdx + 1], $docPathStrings[$mainNodeIdx + 1] );
}
}
$locationFilter = isset( $this->postSearchProcessingData['subtree_array'] ) ? $this->postSearchProcessingData['subtree_array'] : array();
$subtreeLimitations = isset( $this->postSearchProcessingData['subtree_limitations'] ) ? $this->postSearchProcessingData['subtree_limitations'] : array();
$validSubtreeArray = $this->getValidPathStringsByLimitation(
$docPathStrings,
$locationFilter
);
$validSubtreeLimitations = $this->getValidPathStringsByLimitation(
$docPathStrings,
$subtreeLimitations
);
$ignoreVisibility = eZContentObjectTreeNode::showInvisibleNodes();
if ( isset( $this->postSearchProcessingData['ignore_visibility'] ) )
{
$ignoreVisibility = $this->postSearchProcessingData['ignore_visibility'];
}
// Intersect between $validSubtreeArray (search location filter) and $validSubtreeLimitations (user policy limitations)
// indicates valid locations for $doc in current search query
// If this intersect is not empty, we take the first node id that
// matches the visibility requirement
$validSubtrees = array_flip(
array_intersect( $validSubtreeArray, $validSubtreeLimitations )
);
if ( !empty( $validSubtrees ) )
{
foreach ( $docPathStrings as $k => $path )
{
if ( isset( $validSubtrees[$path] ) )
{
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
}
}
}
// Could not find a visible location for content that current user has read access on.
return null;
}
else
{
$contentId = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'id' )];
$content = eZContentObject::fetch( $contentId );
if ( $content instanceof eZContentObject && !$content->canRead() )
{
eZDebug::writeError(
"Could not find valid/granted locations for content #$contentId. Broken sync between eZPublish and Solr ?\n\n" .
"Location filter : " . print_r( $locationFilter, true ) .
"Subtree limitations for user : " . print_r( $subtreeLimitations, true ),
__METHOD__
);
}
foreach ( $docPathStrings as $k => $path )
{
if ( $ignoreVisibility || !$docVisibilities[$k] )
{
$nodeArray = explode( '/', rtrim( $path, '/' ) );
return (int)array_pop( $nodeArray );
}
}
}
return (int)$doc[ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_node_id' )];
} | [
"protected",
"function",
"getNodeID",
"(",
"$",
"doc",
")",
"{",
"$",
"docPathStrings",
"=",
"$",
"doc",
"[",
"ezfSolrDocumentFieldBase",
"::",
"generateMetaFieldName",
"(",
"'path_string'",
")",
"]",
";",
"$",
"docVisibilities",
"=",
"$",
"doc",
"[",
"ezfSolr... | Returns the relative NodeID for a given search result,
depending on whether a subtree filter was applied or not and limitations by user policy limitations.
Policy limitations (subtree/node) are aggregated by a logic OR (same for subtree filters).
Subtree filters and policy limitations are aggregated together with a logic AND,
so that valid locations must comply subtree filters (if any) AND subtree/node policy limitations (if any)
@param array $doc The search result, directly received from Solr.
@return int The NodeID corresponding the search result | [
"Returns",
"the",
"relative",
"NodeID",
"for",
"a",
"given",
"search",
"result",
"depending",
"on",
"whether",
"a",
"subtree",
"filter",
"was",
"applied",
"or",
"not",
"and",
"limitations",
"by",
"user",
"policy",
"limitations",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L318-L403 |
44,825 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.addFieldBaseToDoc | function addFieldBaseToDoc( ezfSolrDocumentFieldBase $fieldBase, eZSolrDoc $doc, $boost = false )
{
$fieldBaseData = $fieldBase->getData();
if ( empty( $fieldBaseData ) )
{
if ( is_object( $fieldBase ) )
{
$contentClassAttribute = $fieldBase->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$fieldName = $fieldBase->getFieldName( $contentClassAttribute );
$errorMessage = 'empty array for ' . $fieldName;
}
else
{
$errorMessage = '$fieldBase not an object';
}
eZDebug::writeNotice( $errorMessage , __METHOD__ );
return false;
}
else
{
foreach ( $fieldBaseData as $key => $value )
{
// since ezfind 2.3, a NULL value returned from $fieldBase in the $value elements is used as a flag not to index
if ( !is_null( $value ) )
{
$doc->addField( $key, $value, $boost );
}
}
return true;
}
} | php | function addFieldBaseToDoc( ezfSolrDocumentFieldBase $fieldBase, eZSolrDoc $doc, $boost = false )
{
$fieldBaseData = $fieldBase->getData();
if ( empty( $fieldBaseData ) )
{
if ( is_object( $fieldBase ) )
{
$contentClassAttribute = $fieldBase->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$fieldName = $fieldBase->getFieldName( $contentClassAttribute );
$errorMessage = 'empty array for ' . $fieldName;
}
else
{
$errorMessage = '$fieldBase not an object';
}
eZDebug::writeNotice( $errorMessage , __METHOD__ );
return false;
}
else
{
foreach ( $fieldBaseData as $key => $value )
{
// since ezfind 2.3, a NULL value returned from $fieldBase in the $value elements is used as a flag not to index
if ( !is_null( $value ) )
{
$doc->addField( $key, $value, $boost );
}
}
return true;
}
} | [
"function",
"addFieldBaseToDoc",
"(",
"ezfSolrDocumentFieldBase",
"$",
"fieldBase",
",",
"eZSolrDoc",
"$",
"doc",
",",
"$",
"boost",
"=",
"false",
")",
"{",
"$",
"fieldBaseData",
"=",
"$",
"fieldBase",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"empty",
"(... | Add instance of ezfSolrDocumentFieldBase to Solr document.
@param ezfSolrDocumentFieldBase Instance of ezfSolrDocumentFieldBase
@param eZSolrDoc Solr document | [
"Add",
"instance",
"of",
"ezfSolrDocumentFieldBase",
"to",
"Solr",
"document",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L789-L820 |
44,826 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.commit | function commit( $softCommit = false )
{
if ( $this->UseMultiLanguageCores === true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->commit( $softCommit );
}
}
else
{
$this->Solr->commit( $softCommit );
}
} | php | function commit( $softCommit = false )
{
if ( $this->UseMultiLanguageCores === true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->commit( $softCommit );
}
}
else
{
$this->Solr->commit( $softCommit );
}
} | [
"function",
"commit",
"(",
"$",
"softCommit",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"UseMultiLanguageCores",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"SolrLanguageShards",
"as",
"$",
"shard",
")",
"{",
"$",
"shard",
"... | Performs a solr COMMIT | [
"Performs",
"a",
"solr",
"COMMIT"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L825-L840 |
44,827 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.optimize | function optimize( $withCommit = false )
{
if ( $this->UseMultiLanguageCores === true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->optimize( $withCommit );
}
}
else
{
$this->Solr->optimize( $withCommit );
}
} | php | function optimize( $withCommit = false )
{
if ( $this->UseMultiLanguageCores === true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->optimize( $withCommit );
}
}
else
{
$this->Solr->optimize( $withCommit );
}
} | [
"function",
"optimize",
"(",
"$",
"withCommit",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"UseMultiLanguageCores",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"SolrLanguageShards",
"as",
"$",
"shard",
")",
"{",
"$",
"shard",
... | Performs a solr OPTIMIZE call | [
"Performs",
"a",
"solr",
"OPTIMIZE",
"call"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L845-L859 |
44,828 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.moreLikeThis | function moreLikeThis( $queryType, $queryValue, $params = array() )
{
eZDebug::createAccumulator( 'MoreLikeThis', 'eZ Find' );
eZDebug::accumulatorStart( 'MoreLikeThis' );
$error = 'Server not running';
$asObjects = isset( $params['AsObjects'] ) ? $params['AsObjects'] : true;
//mlt does not support distributed search yet, so find out which is
//the language core to use and qyery only this one
//search across languages does not make sense here
$coreToUse = null;
if ( $this->UseMultiLanguageCores == true )
{
$languages = $this->SiteINI->variable( 'RegionalSettings', 'SiteLanguageList' );
if ( array_key_exists ( $languages[0], $this->SolrLanguageShards ) )
{
$coreToUse = $this->SolrLanguageShards[$languages[0]];
}
}
else
{
$coreToUse = $this->Solr;
}
if ( trim( $queryType ) == '' || trim( $queryValue ) == '' )
{
$error = 'Missing query arguments for More Like This: ' . 'querytype = ' . $queryType . ', Query Value = ' . $queryValue;
eZDebug::writeNotice( $error, __METHOD__ );
$resultArray = null;
}
else
{
eZDebug::createAccumulator( 'Query build', 'eZ Find' );
eZDebug::accumulatorStart( 'Query build' );
$queryBuilder = new ezfeZPSolrQueryBuilder( $this );
$queryParams = $queryBuilder->buildMoreLikeThis( $queryType, $queryValue, $params );
eZDebug::accumulatorStop( 'Query build' );
eZDebug::createAccumulator( 'Engine time', 'eZ Find' );
eZDebug::accumulatorStart( 'Engine time' );
$resultArray = $coreToUse->rawSolrRequest( '/mlt', $queryParams );
eZDebug::accumulatorStop( 'Engine time' );
}
if ( $resultArray )
{
$searchCount = $resultArray[ 'response' ][ 'numFound' ];
$objectRes = $this->buildResultObjects(
$resultArray, $searchCount, $asObjects, $params
);
$stopWordArray = array();
eZDebugSetting::writeDebug( 'extension-ezfind-query-mlt', $resultArray['interestingTerms'], 'MoreLikeThis terms' );
return array(
'SearchResult' => $objectRes,
'SearchCount' => $searchCount,
'StopWordArray' => $stopWordArray,
'SearchExtras' => new ezfSearchResultInfo( $resultArray )
);
}
else
{
return array(
'SearchResult' => false,
'SearchCount' => 0,
'StopWordArray' => array(),
'SearchExtras' => new ezfSearchResultInfo( array( 'error' => ezpI18n::tr( 'ezfind', $error ) ) ) );
}
} | php | function moreLikeThis( $queryType, $queryValue, $params = array() )
{
eZDebug::createAccumulator( 'MoreLikeThis', 'eZ Find' );
eZDebug::accumulatorStart( 'MoreLikeThis' );
$error = 'Server not running';
$asObjects = isset( $params['AsObjects'] ) ? $params['AsObjects'] : true;
//mlt does not support distributed search yet, so find out which is
//the language core to use and qyery only this one
//search across languages does not make sense here
$coreToUse = null;
if ( $this->UseMultiLanguageCores == true )
{
$languages = $this->SiteINI->variable( 'RegionalSettings', 'SiteLanguageList' );
if ( array_key_exists ( $languages[0], $this->SolrLanguageShards ) )
{
$coreToUse = $this->SolrLanguageShards[$languages[0]];
}
}
else
{
$coreToUse = $this->Solr;
}
if ( trim( $queryType ) == '' || trim( $queryValue ) == '' )
{
$error = 'Missing query arguments for More Like This: ' . 'querytype = ' . $queryType . ', Query Value = ' . $queryValue;
eZDebug::writeNotice( $error, __METHOD__ );
$resultArray = null;
}
else
{
eZDebug::createAccumulator( 'Query build', 'eZ Find' );
eZDebug::accumulatorStart( 'Query build' );
$queryBuilder = new ezfeZPSolrQueryBuilder( $this );
$queryParams = $queryBuilder->buildMoreLikeThis( $queryType, $queryValue, $params );
eZDebug::accumulatorStop( 'Query build' );
eZDebug::createAccumulator( 'Engine time', 'eZ Find' );
eZDebug::accumulatorStart( 'Engine time' );
$resultArray = $coreToUse->rawSolrRequest( '/mlt', $queryParams );
eZDebug::accumulatorStop( 'Engine time' );
}
if ( $resultArray )
{
$searchCount = $resultArray[ 'response' ][ 'numFound' ];
$objectRes = $this->buildResultObjects(
$resultArray, $searchCount, $asObjects, $params
);
$stopWordArray = array();
eZDebugSetting::writeDebug( 'extension-ezfind-query-mlt', $resultArray['interestingTerms'], 'MoreLikeThis terms' );
return array(
'SearchResult' => $objectRes,
'SearchCount' => $searchCount,
'StopWordArray' => $stopWordArray,
'SearchExtras' => new ezfSearchResultInfo( $resultArray )
);
}
else
{
return array(
'SearchResult' => false,
'SearchCount' => 0,
'StopWordArray' => array(),
'SearchExtras' => new ezfSearchResultInfo( array( 'error' => ezpI18n::tr( 'ezfind', $error ) ) ) );
}
} | [
"function",
"moreLikeThis",
"(",
"$",
"queryType",
",",
"$",
"queryValue",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"eZDebug",
"::",
"createAccumulator",
"(",
"'MoreLikeThis'",
",",
"'eZ Find'",
")",
";",
"eZDebug",
"::",
"accumulatorStart",
"("... | More like this is pretty similar to normal search, but usually only the object or node id are sent to Solr
However, streams or a search text body can also be passed .. Solr will extract the important terms and build a
query for us
@param string $queryType is one of 'noid', 'oid', 'url', 'text'
@param $queryValue the node id, object id, url or text body to use
@param array parameters. @see ezfeZPSolrQueryBuilder::buildMoreLikeThis()
@return array List of eZFindResultNode objects.
@todo: add functionality not to call the DB to recreate objects : $asObjects == false | [
"More",
"like",
"this",
"is",
"pretty",
"similar",
"to",
"normal",
"search",
"but",
"usually",
"only",
"the",
"object",
"or",
"node",
"id",
"are",
"sent",
"to",
"Solr",
"However",
"streams",
"or",
"a",
"search",
"text",
"body",
"can",
"also",
"be",
"pass... | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1068-L1138 |
44,829 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.installationID | static function installationID()
{
if ( !empty( self::$InstallationID ) )
{
return self::$InstallationID;
}
$db = eZDB::instance();
$resultSet = $db->arrayQuery( 'SELECT value FROM ezsite_data WHERE name=\'ezfind_site_id\'' );
if ( count( $resultSet ) >= 1 )
{
self::$InstallationID = $resultSet[0]['value'];
}
else
{
self::$InstallationID = md5( time() . '-' . mt_rand() );
$db->query( 'INSERT INTO ezsite_data ( name, value ) values( \'ezfind_site_id\', \'' . self::$InstallationID . '\' )' );
}
return self::$InstallationID;
} | php | static function installationID()
{
if ( !empty( self::$InstallationID ) )
{
return self::$InstallationID;
}
$db = eZDB::instance();
$resultSet = $db->arrayQuery( 'SELECT value FROM ezsite_data WHERE name=\'ezfind_site_id\'' );
if ( count( $resultSet ) >= 1 )
{
self::$InstallationID = $resultSet[0]['value'];
}
else
{
self::$InstallationID = md5( time() . '-' . mt_rand() );
$db->query( 'INSERT INTO ezsite_data ( name, value ) values( \'ezfind_site_id\', \'' . self::$InstallationID . '\' )' );
}
return self::$InstallationID;
} | [
"static",
"function",
"installationID",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"self",
"::",
"$",
"InstallationID",
")",
")",
"{",
"return",
"self",
"::",
"$",
"InstallationID",
";",
"}",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",... | Returns the eZ publish installation ID, used by eZ find to identify sites
@return string installaiton ID. | [
"Returns",
"the",
"eZ",
"publish",
"installation",
"ID",
"used",
"by",
"eZ",
"find",
"to",
"identify",
"sites"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1193-L1214 |
44,830 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.guid | function guid( $contentObject, $languageCode = '' )
{
if ( !$contentObject instanceof eZContentObject )
return md5( self::installationID() . '-' . $contentObject . '-' . $languageCode );
return md5( self::installationID() . '-' . $contentObject->attribute( 'id' ) . '-' . $languageCode );
} | php | function guid( $contentObject, $languageCode = '' )
{
if ( !$contentObject instanceof eZContentObject )
return md5( self::installationID() . '-' . $contentObject . '-' . $languageCode );
return md5( self::installationID() . '-' . $contentObject->attribute( 'id' ) . '-' . $languageCode );
} | [
"function",
"guid",
"(",
"$",
"contentObject",
",",
"$",
"languageCode",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"contentObject",
"instanceof",
"eZContentObject",
")",
"return",
"md5",
"(",
"self",
"::",
"installationID",
"(",
")",
".",
"'-'",
".",
"$"... | Computes the unique ID of a content object language version
@param eZContentObject|int $contentObject The content object OR content object Id
@param string $languageCode
@return string guid | [
"Computes",
"the",
"unique",
"ID",
"of",
"a",
"content",
"object",
"language",
"version"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1223-L1229 |
44,831 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.extractLanguageCodesFromSolrResult | private function extractLanguageCodesFromSolrResult( $solrResults )
{
$languages = array();
if ( isset( $solrResults['response']['docs'] ) )
{
foreach ( $solrResults['response']['docs'] as $doc )
{
if ( isset( $doc['meta_language_code_ms'] ) )
{
$languages[] = $doc['meta_language_code_ms'];
}
}
}
return $languages;
} | php | private function extractLanguageCodesFromSolrResult( $solrResults )
{
$languages = array();
if ( isset( $solrResults['response']['docs'] ) )
{
foreach ( $solrResults['response']['docs'] as $doc )
{
if ( isset( $doc['meta_language_code_ms'] ) )
{
$languages[] = $doc['meta_language_code_ms'];
}
}
}
return $languages;
} | [
"private",
"function",
"extractLanguageCodesFromSolrResult",
"(",
"$",
"solrResults",
")",
"{",
"$",
"languages",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"solrResults",
"[",
"'response'",
"]",
"[",
"'docs'",
"]",
")",
")",
"{",
"foreach"... | Extracts the list of 'meta_language_code_ms' from a solrResult array.
@param $solrResults
@return array of languages (as strings) | [
"Extracts",
"the",
"list",
"of",
"meta_language_code_ms",
"from",
"a",
"solrResult",
"array",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1275-L1291 |
44,832 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.cleanup | function cleanup( $allInstallations = false, $optimize = false )
{
if ( $allInstallations === true )
{
$optimize = true;
$deleteQuery = '*:*';
}
else
{
$deleteQuery = ezfSolrDocumentFieldBase::generateMetaFieldName( 'installation_id' ) . ':' . self::installationID();
}
if ( $this->UseMultiLanguageCores == true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->deleteDocs( array(), $deleteQuery, true, $optimize );
}
return true;
}
else
{
return $this->Solr->deleteDocs( array(), $deleteQuery, true );
}
} | php | function cleanup( $allInstallations = false, $optimize = false )
{
if ( $allInstallations === true )
{
$optimize = true;
$deleteQuery = '*:*';
}
else
{
$deleteQuery = ezfSolrDocumentFieldBase::generateMetaFieldName( 'installation_id' ) . ':' . self::installationID();
}
if ( $this->UseMultiLanguageCores == true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
$shard->deleteDocs( array(), $deleteQuery, true, $optimize );
}
return true;
}
else
{
return $this->Solr->deleteDocs( array(), $deleteQuery, true );
}
} | [
"function",
"cleanup",
"(",
"$",
"allInstallations",
"=",
"false",
",",
"$",
"optimize",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"allInstallations",
"===",
"true",
")",
"{",
"$",
"optimize",
"=",
"true",
";",
"$",
"deleteQuery",
"=",
"'*:*'",
";",
"}",... | Clean up search index for current installation.
@return bool true if cleanup was successful
@todo: handle multicore configs (need a parameter for it) for return values | [
"Clean",
"up",
"search",
"index",
"for",
"current",
"installation",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1298-L1322 |
44,833 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.addNodeAssignment | public function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved )
{
eZContentOperationCollection::registerSearchObject( $objectID, null, $isMoved );
} | php | public function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved )
{
eZContentOperationCollection::registerSearchObject( $objectID, null, $isMoved );
} | [
"public",
"function",
"addNodeAssignment",
"(",
"$",
"mainNodeID",
",",
"$",
"objectID",
",",
"$",
"nodeAssignmentIDList",
",",
"$",
"isMoved",
")",
"{",
"eZContentOperationCollection",
"::",
"registerSearchObject",
"(",
"$",
"objectID",
",",
"null",
",",
"$",
"... | Called when a node assignement is added to an object.
Simply re-index for now.
@todo: defer to cron if there are children involved and re-index these too
@todo when Solr supports it: update fields only
@param $mainNodeID
@param $objectID
@param $nodeAssignmentIDList
@param bool $isMoved true if node is being moved
@return unknown_type
@see eZSearch::addNodeAssignment() | [
"Called",
"when",
"a",
"node",
"assignement",
"is",
"added",
"to",
"an",
"object",
".",
"Simply",
"re",
"-",
"index",
"for",
"now",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1494-L1497 |
44,834 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.swapNode | public function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() )
{
$contentObject1 = eZContentObject::fetchByNodeID( $nodeID );
$contentObject2 = eZContentObject::fetchByNodeID( $selectedNodeID );
$this->addObject( $contentObject1 );
$this->addObject( $contentObject2 );
} | php | public function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() )
{
$contentObject1 = eZContentObject::fetchByNodeID( $nodeID );
$contentObject2 = eZContentObject::fetchByNodeID( $selectedNodeID );
$this->addObject( $contentObject1 );
$this->addObject( $contentObject2 );
} | [
"public",
"function",
"swapNode",
"(",
"$",
"nodeID",
",",
"$",
"selectedNodeID",
",",
"$",
"nodeIdList",
"=",
"array",
"(",
")",
")",
"{",
"$",
"contentObject1",
"=",
"eZContentObject",
"::",
"fetchByNodeID",
"(",
"$",
"nodeID",
")",
";",
"$",
"contentObj... | Called when two nodes are swapped.
Simply re-index for now.
@todo when Solr supports it: update fields only
@param $nodeID
@param $selectedNodeID
@param $nodeIdList
@return void | [
"Called",
"when",
"two",
"nodes",
"are",
"swapped",
".",
"Simply",
"re",
"-",
"index",
"for",
"now",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1528-L1534 |
44,835 | ezsystems/ezfind | search/plugins/ezsolr/ezsolr.php | eZSolr.pushElevateConfiguration | public function pushElevateConfiguration()
{
if ( $this->UseMultiLanguageCores == true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
eZFindElevateConfiguration::synchronizeWithSolr( $shard );
}
return true;
}
else
{
return eZFindElevateConfiguration::synchronizeWithSolr( $this->Solr );
}
} | php | public function pushElevateConfiguration()
{
if ( $this->UseMultiLanguageCores == true )
{
foreach ( $this->SolrLanguageShards as $shard )
{
eZFindElevateConfiguration::synchronizeWithSolr( $shard );
}
return true;
}
else
{
return eZFindElevateConfiguration::synchronizeWithSolr( $this->Solr );
}
} | [
"public",
"function",
"pushElevateConfiguration",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"UseMultiLanguageCores",
"==",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"SolrLanguageShards",
"as",
"$",
"shard",
")",
"{",
"eZFindElevateConfiguration",
... | synchronises elevate configuration across language shards in case of
multiple lnguage indexes, or the default one
@TODO: handle exceptions properly | [
"synchronises",
"elevate",
"configuration",
"across",
"language",
"shards",
"in",
"case",
"of",
"multiple",
"lnguage",
"indexes",
"or",
"the",
"default",
"one"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/search/plugins/ezsolr/ezsolr.php#L1580-L1595 |
44,836 | ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.run | public function run()
{
$this->Script->startup();
$this->Options = $this->Script->getOptions(
"[db-host:][db-user:][db-password:][db-database:][db-type:|db-driver:][sql][clean][clean-all][conc:][php-exec:][commit-within:]",
"",
array(
'db-host' => "Database host",
'db-user' => "Database user",
'db-password' => "Database password",
'db-database' => "Database name",
'db-driver' => "Database driver",
'db-type' => "Database driver, alias for --db-driver",
'sql' => "Display sql queries",
'clean' => "Remove all search data of the current installation id before beginning indexing",
'clean-all' => "Remove all search data for all installations",
'conc' => 'Parallelization, number of concurent processes to use',
'php-exec' => 'Full path to PHP executable',
'commit-within' => 'Commit to Solr within this time in seconds (default '
. self::DEFAULT_COMMIT_WITHIN . ' seconds)',
)
);
$this->Script->initialize();
// check if ezfind is enabled and exit if not
if ( ! in_array( 'ezfind', eZExtension::activeExtensions() ) )
{
$this->CLI->error( 'eZ Find extension is not enabled and because of that index process will fail. Please enable it and run this script again.' );
$this->Script->shutdown( 0 );
}
// Fix siteaccess
$siteAccess = $this->Options['siteaccess'] ? $this->Options['siteaccess'] : false;
if ( $siteAccess )
{
$this->changeSiteAccessSetting( $siteAccess );
}
else
{
$this->CLI->warning( 'You did not specify a siteaccess. The admin siteaccess is a required option in most cases.' );
$input = readline( 'Are you sure the default siteaccess has all available languages defined? ([y] or [q] to quit )' );
if ( $input === 'q' )
{
$this->Script->shutdown( 0 );
}
}
// Check that Solr server is up and running
if ( !$this->checkSolrRunning() )
{
$this->Script->shutdown( 1 );
exit();
}
$this->initializeDB();
// call clean up routines which will deal with the CLI arguments themselves
$this->cleanUp();
$this->cleanUpAll();
if ( isset( $this->Options['commit-within'] )
&& is_numeric( $this->Options['commit-within'] ) )
{
$this->commitWithin = (int)$this->Options['commit-within'];
}
$this->CLI->output( 'Starting object re-indexing' );
// Get PHP executable from user.
$this->getPHPExecutable();
$this->runMain();
} | php | public function run()
{
$this->Script->startup();
$this->Options = $this->Script->getOptions(
"[db-host:][db-user:][db-password:][db-database:][db-type:|db-driver:][sql][clean][clean-all][conc:][php-exec:][commit-within:]",
"",
array(
'db-host' => "Database host",
'db-user' => "Database user",
'db-password' => "Database password",
'db-database' => "Database name",
'db-driver' => "Database driver",
'db-type' => "Database driver, alias for --db-driver",
'sql' => "Display sql queries",
'clean' => "Remove all search data of the current installation id before beginning indexing",
'clean-all' => "Remove all search data for all installations",
'conc' => 'Parallelization, number of concurent processes to use',
'php-exec' => 'Full path to PHP executable',
'commit-within' => 'Commit to Solr within this time in seconds (default '
. self::DEFAULT_COMMIT_WITHIN . ' seconds)',
)
);
$this->Script->initialize();
// check if ezfind is enabled and exit if not
if ( ! in_array( 'ezfind', eZExtension::activeExtensions() ) )
{
$this->CLI->error( 'eZ Find extension is not enabled and because of that index process will fail. Please enable it and run this script again.' );
$this->Script->shutdown( 0 );
}
// Fix siteaccess
$siteAccess = $this->Options['siteaccess'] ? $this->Options['siteaccess'] : false;
if ( $siteAccess )
{
$this->changeSiteAccessSetting( $siteAccess );
}
else
{
$this->CLI->warning( 'You did not specify a siteaccess. The admin siteaccess is a required option in most cases.' );
$input = readline( 'Are you sure the default siteaccess has all available languages defined? ([y] or [q] to quit )' );
if ( $input === 'q' )
{
$this->Script->shutdown( 0 );
}
}
// Check that Solr server is up and running
if ( !$this->checkSolrRunning() )
{
$this->Script->shutdown( 1 );
exit();
}
$this->initializeDB();
// call clean up routines which will deal with the CLI arguments themselves
$this->cleanUp();
$this->cleanUpAll();
if ( isset( $this->Options['commit-within'] )
&& is_numeric( $this->Options['commit-within'] ) )
{
$this->commitWithin = (int)$this->Options['commit-within'];
}
$this->CLI->output( 'Starting object re-indexing' );
// Get PHP executable from user.
$this->getPHPExecutable();
$this->runMain();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"Script",
"->",
"startup",
"(",
")",
";",
"$",
"this",
"->",
"Options",
"=",
"$",
"this",
"->",
"Script",
"->",
"getOptions",
"(",
"\"[db-host:][db-user:][db-password:][db-database:][db-type:|db-driv... | Startup and run script. | [
"Startup",
"and",
"run",
"script",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L75-L149 |
44,837 | ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.getPHPExecutable | protected function getPHPExecutable()
{
$validExecutable = false;
$output = array();
$exec = 'php';
if ( !empty( $this->Options['php-exec'] ) )
{
$exec = $this->Options['php-exec'];
}
exec( $exec . ' -v', $output );
if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
{
$validExecutable = true;
$this->Executable = $exec;
}
while( !$validExecutable )
{
$input = readline( 'Enter path to PHP-CLI executable ( or [q] to quit )' );
if ( $input === 'q' )
{
$this->Script->shutdown( 0 );
}
exec( $input . ' -v', $output );
if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
{
$validExecutable = true;
$this->Executable = $input;
}
}
} | php | protected function getPHPExecutable()
{
$validExecutable = false;
$output = array();
$exec = 'php';
if ( !empty( $this->Options['php-exec'] ) )
{
$exec = $this->Options['php-exec'];
}
exec( $exec . ' -v', $output );
if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
{
$validExecutable = true;
$this->Executable = $exec;
}
while( !$validExecutable )
{
$input = readline( 'Enter path to PHP-CLI executable ( or [q] to quit )' );
if ( $input === 'q' )
{
$this->Script->shutdown( 0 );
}
exec( $input . ' -v', $output );
if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
{
$validExecutable = true;
$this->Executable = $input;
}
}
} | [
"protected",
"function",
"getPHPExecutable",
"(",
")",
"{",
"$",
"validExecutable",
"=",
"false",
";",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"exec",
"=",
"'php'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"Options",
"[",
"'php-... | Get PHP executable from user input. Exit if php executable cannot be
found and if no executable is entered. | [
"Get",
"PHP",
"executable",
"from",
"user",
"input",
".",
"Exit",
"if",
"php",
"executable",
"cannot",
"be",
"found",
"and",
"if",
"no",
"executable",
"is",
"entered",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L156-L189 |
44,838 | ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.iterate | protected function iterate( $count = false )
{
if ( !$count )
{
$count = $this->Limit;
}
for ( $iterateCount = 0; $iterateCount < $count; ++$iterateCount )
{
if ( ++$this->IterateCount > $this->ObjectCount )
{
break;
}
$this->Script->iterate( $this->CLI, true );
}
} | php | protected function iterate( $count = false )
{
if ( !$count )
{
$count = $this->Limit;
}
for ( $iterateCount = 0; $iterateCount < $count; ++$iterateCount )
{
if ( ++$this->IterateCount > $this->ObjectCount )
{
break;
}
$this->Script->iterate( $this->CLI, true );
}
} | [
"protected",
"function",
"iterate",
"(",
"$",
"count",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"count",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"Limit",
";",
"}",
"for",
"(",
"$",
"iterateCount",
"=",
"0",
";",
"$",
"iterateCount",
"... | Iterate index counter
@param int $count | [
"Iterate",
"index",
"counter"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L335-L350 |
44,839 | ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.forkAndExecute | protected function forkAndExecute( $nodeID, $offset, $limit )
{
eZDB::setInstance( null );
// Prepare DB-based cluster handler for fork (it will re-connect DB automatically).
eZClusterFileHandler::preFork();
$pid = pcntl_fork();
// reinitialize DB after fork
$this->initializeDB();
if ( $pid == -1 )
{
die( 'could not fork' );
}
else if ( $pid )
{
// Main process
return $pid;
}
else
{
// We are the child process
if ( $this->execute( $nodeID, $offset, $limit ) > 0 )
{
$this->Script->shutdown( 0 );
}
else
{
$this->Script->shutdown( 3 );
}
}
} | php | protected function forkAndExecute( $nodeID, $offset, $limit )
{
eZDB::setInstance( null );
// Prepare DB-based cluster handler for fork (it will re-connect DB automatically).
eZClusterFileHandler::preFork();
$pid = pcntl_fork();
// reinitialize DB after fork
$this->initializeDB();
if ( $pid == -1 )
{
die( 'could not fork' );
}
else if ( $pid )
{
// Main process
return $pid;
}
else
{
// We are the child process
if ( $this->execute( $nodeID, $offset, $limit ) > 0 )
{
$this->Script->shutdown( 0 );
}
else
{
$this->Script->shutdown( 3 );
}
}
} | [
"protected",
"function",
"forkAndExecute",
"(",
"$",
"nodeID",
",",
"$",
"offset",
",",
"$",
"limit",
")",
"{",
"eZDB",
"::",
"setInstance",
"(",
"null",
")",
";",
"// Prepare DB-based cluster handler for fork (it will re-connect DB automatically).",
"eZClusterFileHandler... | Fork and execute
@param int $nodeid
@param int $offset
@param int $limit | [
"Fork",
"and",
"execute"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L359-L392 |
44,840 | ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.execute | protected function execute( $nodeID, $offset, $limit )
{
$count = 0;
$node = eZContentObjectTreeNode::fetch( $nodeID );
if ( !( $node instanceof eZContentObjectTreeNode ) )
{
$this->CLI->error( "An error occured while trying fetching node $nodeID" );
return 0;
}
$searchEngine = new eZSolr();
if (
$subTree = $node->subTree(
array(
'Offset' => $offset,
'Limit' => $limit,
'SortBy' => array(),
'Limitation' => array(),
'MainNodeOnly' => true
)
)
)
{
foreach ( $subTree as $innerNode )
{
$object = $innerNode->attribute( 'object' );
if ( !$object )
{
continue;
}
//pass false as we are going to do a commit at the end
$result = $searchEngine->addObject( $object, false, $this->commitWithin * 1000 );
if ( !$result )
{
$this->CLI->error( ' Failed indexing ' . $object->attribute('class_identifier') . ' object with ID ' . $object->attribute( 'id' ) );
}
++$count;
}
}
return $count;
} | php | protected function execute( $nodeID, $offset, $limit )
{
$count = 0;
$node = eZContentObjectTreeNode::fetch( $nodeID );
if ( !( $node instanceof eZContentObjectTreeNode ) )
{
$this->CLI->error( "An error occured while trying fetching node $nodeID" );
return 0;
}
$searchEngine = new eZSolr();
if (
$subTree = $node->subTree(
array(
'Offset' => $offset,
'Limit' => $limit,
'SortBy' => array(),
'Limitation' => array(),
'MainNodeOnly' => true
)
)
)
{
foreach ( $subTree as $innerNode )
{
$object = $innerNode->attribute( 'object' );
if ( !$object )
{
continue;
}
//pass false as we are going to do a commit at the end
$result = $searchEngine->addObject( $object, false, $this->commitWithin * 1000 );
if ( !$result )
{
$this->CLI->error( ' Failed indexing ' . $object->attribute('class_identifier') . ' object with ID ' . $object->attribute( 'id' ) );
}
++$count;
}
}
return $count;
} | [
"protected",
"function",
"execute",
"(",
"$",
"nodeID",
",",
"$",
"offset",
",",
"$",
"limit",
")",
"{",
"$",
"count",
"=",
"0",
";",
"$",
"node",
"=",
"eZContentObjectTreeNode",
"::",
"fetch",
"(",
"$",
"nodeID",
")",
";",
"if",
"(",
"!",
"(",
"$"... | Execute indexing of subtree
@param int $nodeID
@param int $offset
@param int $limit
@return int Number of objects indexed. | [
"Execute",
"indexing",
"of",
"subtree"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L403-L445 |
44,841 | ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.objectCount | protected function objectCount()
{
$topNodeArray = eZPersistentObject::fetchObjectList(
eZContentObjectTreeNode::definition(),
null,
array( 'parent_node_id' => 1, 'depth' => 1 )
);
$subTreeCount = 0;
foreach ( array_keys ( $topNodeArray ) as $key )
{
$subTreeCount += $topNodeArray[$key]->subTreeCount( array( 'Limitation' => array(), 'MainNodeOnly' => true ) );
}
return $subTreeCount;
} | php | protected function objectCount()
{
$topNodeArray = eZPersistentObject::fetchObjectList(
eZContentObjectTreeNode::definition(),
null,
array( 'parent_node_id' => 1, 'depth' => 1 )
);
$subTreeCount = 0;
foreach ( array_keys ( $topNodeArray ) as $key )
{
$subTreeCount += $topNodeArray[$key]->subTreeCount( array( 'Limitation' => array(), 'MainNodeOnly' => true ) );
}
return $subTreeCount;
} | [
"protected",
"function",
"objectCount",
"(",
")",
"{",
"$",
"topNodeArray",
"=",
"eZPersistentObject",
"::",
"fetchObjectList",
"(",
"eZContentObjectTreeNode",
"::",
"definition",
"(",
")",
",",
"null",
",",
"array",
"(",
"'parent_node_id'",
"=>",
"1",
",",
"'de... | Get total number of objects
@return int Total object count | [
"Get",
"total",
"number",
"of",
"objects"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L452-L466 |
44,842 | ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.initializeDB | protected function initializeDB()
{
$dbUser = $this->Options['db-user'] ? $this->Options['db-user'] : false;
$dbPassword = $this->Options['db-password'] ? $this->Options['db-password'] : false;
$dbHost = $this->Options['db-host'] ? $this->Options['db-host'] : false;
$dbName = $this->Options['db-database'] ? $this->Options['db-database'] : false;
$dbImpl = $this->Options['db-driver'] ? $this->Options['db-driver'] : false;
$showSQL = $this->Options['sql'] ? true : false;
// Forcing creation of new instance to avoid mysql wait_timeout to kill
// the connection before it's done
$db = eZDB::instance( false, false, true );
if ( $dbHost or $dbName or $dbUser or $dbImpl )
{
$params = array();
if ( $dbHost !== false )
$params['server'] = $dbHost;
if ( $dbUser !== false )
{
$params['user'] = $dbUser;
$params['password'] = '';
}
if ( $dbPassword !== false )
$params['password'] = $dbPassword;
if ( $dbName !== false )
$params['database'] = $dbName;
$db = eZDB::instance( $dbImpl, $params, true );
eZDB::setInstance( $db );
}
$db->setIsSQLOutputEnabled( $showSQL );
} | php | protected function initializeDB()
{
$dbUser = $this->Options['db-user'] ? $this->Options['db-user'] : false;
$dbPassword = $this->Options['db-password'] ? $this->Options['db-password'] : false;
$dbHost = $this->Options['db-host'] ? $this->Options['db-host'] : false;
$dbName = $this->Options['db-database'] ? $this->Options['db-database'] : false;
$dbImpl = $this->Options['db-driver'] ? $this->Options['db-driver'] : false;
$showSQL = $this->Options['sql'] ? true : false;
// Forcing creation of new instance to avoid mysql wait_timeout to kill
// the connection before it's done
$db = eZDB::instance( false, false, true );
if ( $dbHost or $dbName or $dbUser or $dbImpl )
{
$params = array();
if ( $dbHost !== false )
$params['server'] = $dbHost;
if ( $dbUser !== false )
{
$params['user'] = $dbUser;
$params['password'] = '';
}
if ( $dbPassword !== false )
$params['password'] = $dbPassword;
if ( $dbName !== false )
$params['database'] = $dbName;
$db = eZDB::instance( $dbImpl, $params, true );
eZDB::setInstance( $db );
}
$db->setIsSQLOutputEnabled( $showSQL );
} | [
"protected",
"function",
"initializeDB",
"(",
")",
"{",
"$",
"dbUser",
"=",
"$",
"this",
"->",
"Options",
"[",
"'db-user'",
"]",
"?",
"$",
"this",
"->",
"Options",
"[",
"'db-user'",
"]",
":",
"false",
";",
"$",
"dbPassword",
"=",
"$",
"this",
"->",
"... | Create custom DB connection if DB options provided | [
"Create",
"custom",
"DB",
"connection",
"if",
"DB",
"options",
"provided"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L505-L537 |
44,843 | ezsystems/ezfind | bin/php/updatesearchindexsolr.php | ezfUpdateSearchIndexSolr.checkSolrRunning | protected function checkSolrRunning()
{
$eZFindINI = eZINI::instance( 'ezfind.ini' );
if ( $eZFindINI->variable( 'LanguageSearch', 'MultiCore' ) === 'enabled' )
{
$shards = eZINI::instance( 'solr.ini' )->variable( 'SolrBase', 'Shards' );
foreach ( $eZFindINI->variable( 'LanguageSearch', 'LanguagesCoresMap' ) as $locale => $coreName )
{
if ( isset( $shards[$coreName] ) )
{
if ( !$this->isSolrRunning( $shards[$coreName] ) )
{
$this->CLI->error( "The '$coreName' Solr core is not running." );
$this->CLI->error( 'Please, ensure the server is started and the configurations of eZ Find and Solr are correct.' );
return false;
}
}
else
{
$this->CLI->error( "Locale '$locale' is mapped to a core that is not listed in solr.ini/[SolrBase]/Shards." );
return false;
}
}
return true;
}
else
{
$ret = $this->isSolrRunning();
if ( !$ret )
{
$this->CLI->error( "The Solr server couldn't be reached." );
$this->CLI->error( 'Please, ensure the server is started and the configuration of eZ Find is correct.' );
}
return $ret;
}
} | php | protected function checkSolrRunning()
{
$eZFindINI = eZINI::instance( 'ezfind.ini' );
if ( $eZFindINI->variable( 'LanguageSearch', 'MultiCore' ) === 'enabled' )
{
$shards = eZINI::instance( 'solr.ini' )->variable( 'SolrBase', 'Shards' );
foreach ( $eZFindINI->variable( 'LanguageSearch', 'LanguagesCoresMap' ) as $locale => $coreName )
{
if ( isset( $shards[$coreName] ) )
{
if ( !$this->isSolrRunning( $shards[$coreName] ) )
{
$this->CLI->error( "The '$coreName' Solr core is not running." );
$this->CLI->error( 'Please, ensure the server is started and the configurations of eZ Find and Solr are correct.' );
return false;
}
}
else
{
$this->CLI->error( "Locale '$locale' is mapped to a core that is not listed in solr.ini/[SolrBase]/Shards." );
return false;
}
}
return true;
}
else
{
$ret = $this->isSolrRunning();
if ( !$ret )
{
$this->CLI->error( "The Solr server couldn't be reached." );
$this->CLI->error( 'Please, ensure the server is started and the configuration of eZ Find is correct.' );
}
return $ret;
}
} | [
"protected",
"function",
"checkSolrRunning",
"(",
")",
"{",
"$",
"eZFindINI",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezfind.ini'",
")",
";",
"if",
"(",
"$",
"eZFindINI",
"->",
"variable",
"(",
"'LanguageSearch'",
",",
"'MultiCore'",
")",
"===",
"'enabled'",
... | Tells whether Solr is running by replying to ping request.
In a multicore setup, all cores used to index content are checked.
@return bool | [
"Tells",
"whether",
"Solr",
"is",
"running",
"by",
"replying",
"to",
"ping",
"request",
".",
"In",
"a",
"multicore",
"setup",
"all",
"cores",
"used",
"to",
"index",
"content",
"are",
"checked",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/bin/php/updatesearchindexsolr.php#L574-L609 |
44,844 | ezsystems/ezfind | classes/ezfsolrdocumentfieldobjectrelation.php | ezfSolrDocumentFieldObjectRelation.getTypeForSubattribute | protected static function getTypeForSubattribute( eZContentClassAttribute $classAttribute, $subAttribute, $context = 'search' )
{
$q = "SELECT DISTINCT( ezcoa.data_type_string )
FROM ezcontentobject_link AS ezcol,
ezcontentobject_attribute AS ezcoa,
ezcontentclass_attribute AS ezcca,
ezcontentclass_attribute AS ezcca_target
WHERE ezcol.contentclassattribute_id={$classAttribute->attribute( 'id' )}
AND ezcca_target.identifier='{$subAttribute}'
AND ezcca.data_type_string='{$classAttribute->attribute( 'data_type_string' )}'
AND ezcca.id=ezcol.contentclassattribute_id
AND ezcol.to_contentobject_id = ezcoa.contentobject_id
AND ezcoa.contentclassattribute_id = ezcca_target.id;
";
$rows = eZDB::instance()->arrayQuery( $q );
if ( $rows and count( $rows ) > 0 )
{
if ( count( $rows ) > 1 )
{
$msg = "Multiple types were found for subattribute '{$subAttribute}' of
class attribute #{$classAttribute->attribute( 'id' )} [{$classAttribute->attribute( 'data_type_string' )}].
This means that objects of different content classes were related through class attribute #{$classAttribute->attribute( 'id' )}
and had attributes named '{$subAttribute}' of different datatypes : \n"
. print_r( $rows , true ) .
" Picking the first one here : {$rows[0]['data_type_string']}";
eZDebug::writeWarning( $msg, __METHOD__ );
}
return ezfSolrDocumentFieldBase::getClassAttributeType( new eZContentClassAttribute( $rows[0] ), null, $context );
}
return false;
} | php | protected static function getTypeForSubattribute( eZContentClassAttribute $classAttribute, $subAttribute, $context = 'search' )
{
$q = "SELECT DISTINCT( ezcoa.data_type_string )
FROM ezcontentobject_link AS ezcol,
ezcontentobject_attribute AS ezcoa,
ezcontentclass_attribute AS ezcca,
ezcontentclass_attribute AS ezcca_target
WHERE ezcol.contentclassattribute_id={$classAttribute->attribute( 'id' )}
AND ezcca_target.identifier='{$subAttribute}'
AND ezcca.data_type_string='{$classAttribute->attribute( 'data_type_string' )}'
AND ezcca.id=ezcol.contentclassattribute_id
AND ezcol.to_contentobject_id = ezcoa.contentobject_id
AND ezcoa.contentclassattribute_id = ezcca_target.id;
";
$rows = eZDB::instance()->arrayQuery( $q );
if ( $rows and count( $rows ) > 0 )
{
if ( count( $rows ) > 1 )
{
$msg = "Multiple types were found for subattribute '{$subAttribute}' of
class attribute #{$classAttribute->attribute( 'id' )} [{$classAttribute->attribute( 'data_type_string' )}].
This means that objects of different content classes were related through class attribute #{$classAttribute->attribute( 'id' )}
and had attributes named '{$subAttribute}' of different datatypes : \n"
. print_r( $rows , true ) .
" Picking the first one here : {$rows[0]['data_type_string']}";
eZDebug::writeWarning( $msg, __METHOD__ );
}
return ezfSolrDocumentFieldBase::getClassAttributeType( new eZContentClassAttribute( $rows[0] ), null, $context );
}
return false;
} | [
"protected",
"static",
"function",
"getTypeForSubattribute",
"(",
"eZContentClassAttribute",
"$",
"classAttribute",
",",
"$",
"subAttribute",
",",
"$",
"context",
"=",
"'search'",
")",
"{",
"$",
"q",
"=",
"\"SELECT DISTINCT( ezcoa.data_type_string )\n FROM ... | Identifies, based on the existing object relations, the type of the subattribute.
@param eZContentClassAttribute $classAttribute The ezobjectrelation/ezobjectrelationlist attribute
@param $subAttribute The subattribute's name
@return string The type of the subattribute, false otherwise. | [
"Identifies",
"based",
"on",
"the",
"existing",
"object",
"relations",
"the",
"type",
"of",
"the",
"subattribute",
"."
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldobjectrelation.php#L127-L157 |
44,845 | ezsystems/ezfind | classes/ezfsolrdocumentfieldobjectrelation.php | ezfSolrDocumentFieldObjectRelation.getBaseList | function getBaseList( eZContentObjectVersion $objectVersion )
{
$returnList = array();
// Get ezfSolrDocumentFieldBase instance for all attributes in related object
if ( eZContentObject::recursionProtect( $this->ContentObjectAttribute->attribute( 'contentobject_id' ) ) )
{
foreach ( $objectVersion->contentObjectAttributes( $this->ContentObjectAttribute->attribute( 'language_code' ) ) as $attribute )
{
if ( $attribute->attribute( 'contentclass_attribute' )->attribute( 'is_searchable' ) )
{
$returnList[] = ezfSolrDocumentFieldBase::getInstance( $attribute );
}
}
}
return $returnList;
} | php | function getBaseList( eZContentObjectVersion $objectVersion )
{
$returnList = array();
// Get ezfSolrDocumentFieldBase instance for all attributes in related object
if ( eZContentObject::recursionProtect( $this->ContentObjectAttribute->attribute( 'contentobject_id' ) ) )
{
foreach ( $objectVersion->contentObjectAttributes( $this->ContentObjectAttribute->attribute( 'language_code' ) ) as $attribute )
{
if ( $attribute->attribute( 'contentclass_attribute' )->attribute( 'is_searchable' ) )
{
$returnList[] = ezfSolrDocumentFieldBase::getInstance( $attribute );
}
}
}
return $returnList;
} | [
"function",
"getBaseList",
"(",
"eZContentObjectVersion",
"$",
"objectVersion",
")",
"{",
"$",
"returnList",
"=",
"array",
"(",
")",
";",
"// Get ezfSolrDocumentFieldBase instance for all attributes in related object",
"if",
"(",
"eZContentObject",
"::",
"recursionProtect",
... | Get ezfSolrDocumentFieldBase instances for all attributes of specified eZContentObjectVersion
@param eZContentObjectVersion Instance of eZContentObjectVersion to fetch attributes from.
@return array List of ezfSolrDocumentFieldBase instances. | [
"Get",
"ezfSolrDocumentFieldBase",
"instances",
"for",
"all",
"attributes",
"of",
"specified",
"eZContentObjectVersion"
] | b11eac0cee490826d5a55ec9e5642cb156b1a8ec | https://github.com/ezsystems/ezfind/blob/b11eac0cee490826d5a55ec9e5642cb156b1a8ec/classes/ezfsolrdocumentfieldobjectrelation.php#L342-L357 |
44,846 | netgen/query-translator | lib/Languages/Galach/TokenExtractor.php | TokenExtractor.createToken | private function createToken($type, $position, array $data)
{
if ($type === Tokenizer::TOKEN_GROUP_BEGIN) {
return $this->createGroupBeginToken($position, $data);
}
if ($type === Tokenizer::TOKEN_TERM) {
return $this->createTermToken($position, $data);
}
return new Token($type, $data['lexeme'], $position);
} | php | private function createToken($type, $position, array $data)
{
if ($type === Tokenizer::TOKEN_GROUP_BEGIN) {
return $this->createGroupBeginToken($position, $data);
}
if ($type === Tokenizer::TOKEN_TERM) {
return $this->createTermToken($position, $data);
}
return new Token($type, $data['lexeme'], $position);
} | [
"private",
"function",
"createToken",
"(",
"$",
"type",
",",
"$",
"position",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"Tokenizer",
"::",
"TOKEN_GROUP_BEGIN",
")",
"{",
"return",
"$",
"this",
"->",
"createGroupBeginToken",
"(",
... | Create a token object from the given parameters.
@param int $type Token type
@param int $position Position of the token in the input string
@param array $data Regex match data, depends on the type of the token
@return \QueryTranslator\Values\Token | [
"Create",
"a",
"token",
"object",
"from",
"the",
"given",
"parameters",
"."
] | 22710ee4a130eb5f873081fdb465c184d7f29dff | https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/TokenExtractor.php#L84-L95 |
44,847 | netgen/query-translator | lib/Languages/Galach/Parser.php | Parser.reduceLogicalOr | protected function reduceLogicalOr(Node $node, $inGroup = false)
{
if ($this->stack->count() <= 1 || !$this->isTopStackToken(Tokenizer::TOKEN_LOGICAL_OR)) {
return $node;
}
// If inside a group don't look for following logical AND
if (!$inGroup) {
$this->popWhitespace();
// If the next token is logical AND, put the node on stack
// as that has precedence over logical OR
if ($this->isToken(reset($this->tokens), Tokenizer::TOKEN_LOGICAL_AND)) {
$this->stack->push($node);
return null;
}
}
$token = $this->stack->pop();
$leftOperand = $this->stack->pop();
return new LogicalOr($leftOperand, $node, $token);
} | php | protected function reduceLogicalOr(Node $node, $inGroup = false)
{
if ($this->stack->count() <= 1 || !$this->isTopStackToken(Tokenizer::TOKEN_LOGICAL_OR)) {
return $node;
}
// If inside a group don't look for following logical AND
if (!$inGroup) {
$this->popWhitespace();
// If the next token is logical AND, put the node on stack
// as that has precedence over logical OR
if ($this->isToken(reset($this->tokens), Tokenizer::TOKEN_LOGICAL_AND)) {
$this->stack->push($node);
return null;
}
}
$token = $this->stack->pop();
$leftOperand = $this->stack->pop();
return new LogicalOr($leftOperand, $node, $token);
} | [
"protected",
"function",
"reduceLogicalOr",
"(",
"Node",
"$",
"node",
",",
"$",
"inGroup",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stack",
"->",
"count",
"(",
")",
"<=",
"1",
"||",
"!",
"$",
"this",
"->",
"isTopStackToken",
"(",
"Token... | Reduce logical OR.
@param \QueryTranslator\Values\Node $node
@param bool $inGroup Reduce inside a group
@return null|\QueryTranslator\Languages\Galach\Values\Node\LogicalOr|\QueryTranslator\Values\Node | [
"Reduce",
"logical",
"OR",
"."
] | 22710ee4a130eb5f873081fdb465c184d7f29dff | https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L369-L391 |
44,848 | netgen/query-translator | lib/Languages/Galach/Parser.php | Parser.collectTopStackNodes | private function collectTopStackNodes()
{
$nodes = [];
while (!$this->stack->isEmpty() && $this->stack->top() instanceof Node) {
array_unshift($nodes, $this->stack->pop());
}
return $nodes;
} | php | private function collectTopStackNodes()
{
$nodes = [];
while (!$this->stack->isEmpty() && $this->stack->top() instanceof Node) {
array_unshift($nodes, $this->stack->pop());
}
return $nodes;
} | [
"private",
"function",
"collectTopStackNodes",
"(",
")",
"{",
"$",
"nodes",
"=",
"[",
"]",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"stack",
"->",
"isEmpty",
"(",
")",
"&&",
"$",
"this",
"->",
"stack",
"->",
"top",
"(",
")",
"instanceof",
"Node",
... | Collect all Nodes from the top of the stack.
@return \QueryTranslator\Values\Node[] | [
"Collect",
"all",
"Nodes",
"from",
"the",
"top",
"of",
"the",
"stack",
"."
] | 22710ee4a130eb5f873081fdb465c184d7f29dff | https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L422-L431 |
44,849 | netgen/query-translator | lib/Languages/Galach/Parser.php | Parser.popWhitespace | private function popWhitespace()
{
while ($this->isToken(reset($this->tokens), Tokenizer::TOKEN_WHITESPACE)) {
array_shift($this->tokens);
}
} | php | private function popWhitespace()
{
while ($this->isToken(reset($this->tokens), Tokenizer::TOKEN_WHITESPACE)) {
array_shift($this->tokens);
}
} | [
"private",
"function",
"popWhitespace",
"(",
")",
"{",
"while",
"(",
"$",
"this",
"->",
"isToken",
"(",
"reset",
"(",
"$",
"this",
"->",
"tokens",
")",
",",
"Tokenizer",
"::",
"TOKEN_WHITESPACE",
")",
")",
"{",
"array_shift",
"(",
"$",
"this",
"->",
"t... | Remove whitespace Tokens from the beginning of the token array. | [
"Remove",
"whitespace",
"Tokens",
"from",
"the",
"beginning",
"of",
"the",
"token",
"array",
"."
] | 22710ee4a130eb5f873081fdb465c184d7f29dff | https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L516-L521 |
44,850 | netgen/query-translator | lib/Languages/Galach/Parser.php | Parser.popTokens | private function popTokens($typeMask = null)
{
while ($this->isTopStackToken($typeMask)) {
$token = $this->stack->pop();
if ($token->type & self::$tokenShortcuts['operatorUnary']) {
$this->addCorrection(
self::CORRECTION_UNARY_OPERATOR_MISSING_OPERAND_IGNORED,
$token
);
} else {
$this->addCorrection(
self::CORRECTION_BINARY_OPERATOR_MISSING_RIGHT_OPERAND_IGNORED,
$token
);
}
}
} | php | private function popTokens($typeMask = null)
{
while ($this->isTopStackToken($typeMask)) {
$token = $this->stack->pop();
if ($token->type & self::$tokenShortcuts['operatorUnary']) {
$this->addCorrection(
self::CORRECTION_UNARY_OPERATOR_MISSING_OPERAND_IGNORED,
$token
);
} else {
$this->addCorrection(
self::CORRECTION_BINARY_OPERATOR_MISSING_RIGHT_OPERAND_IGNORED,
$token
);
}
}
} | [
"private",
"function",
"popTokens",
"(",
"$",
"typeMask",
"=",
"null",
")",
"{",
"while",
"(",
"$",
"this",
"->",
"isTopStackToken",
"(",
"$",
"typeMask",
")",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"stack",
"->",
"pop",
"(",
")",
";",
"if... | Remove all Tokens from the top of the query stack and log Corrections as necessary.
Optionally also checks that Token matches given $typeMask.
@param int $typeMask | [
"Remove",
"all",
"Tokens",
"from",
"the",
"top",
"of",
"the",
"query",
"stack",
"and",
"log",
"Corrections",
"as",
"necessary",
"."
] | 22710ee4a130eb5f873081fdb465c184d7f29dff | https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L530-L546 |
44,851 | netgen/query-translator | lib/Languages/Galach/Parser.php | Parser.reduceRemainingLogicalOr | private function reduceRemainingLogicalOr($inGroup = false)
{
if (!$this->stack->isEmpty() && !$this->isTopStackToken()) {
$node = $this->reduceLogicalOr($this->stack->pop(), $inGroup);
$this->stack->push($node);
}
} | php | private function reduceRemainingLogicalOr($inGroup = false)
{
if (!$this->stack->isEmpty() && !$this->isTopStackToken()) {
$node = $this->reduceLogicalOr($this->stack->pop(), $inGroup);
$this->stack->push($node);
}
} | [
"private",
"function",
"reduceRemainingLogicalOr",
"(",
"$",
"inGroup",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"stack",
"->",
"isEmpty",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"isTopStackToken",
"(",
")",
")",
"{",
"$",
"node",
"... | Reduce logical OR possibly remaining after reaching end of group or query.
@param bool $inGroup Reduce inside a group | [
"Reduce",
"logical",
"OR",
"possibly",
"remaining",
"after",
"reaching",
"end",
"of",
"group",
"or",
"query",
"."
] | 22710ee4a130eb5f873081fdb465c184d7f29dff | https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L577-L583 |
44,852 | netgen/query-translator | lib/Languages/Galach/Parser.php | Parser.cleanupGroupDelimiters | private function cleanupGroupDelimiters(array &$tokens)
{
$indexes = $this->getUnmatchedGroupDelimiterIndexes($tokens);
while (!empty($indexes)) {
$lastIndex = array_pop($indexes);
$token = $tokens[$lastIndex];
unset($tokens[$lastIndex]);
if ($token->type === Tokenizer::TOKEN_GROUP_BEGIN) {
$this->addCorrection(
self::CORRECTION_UNMATCHED_GROUP_LEFT_DELIMITER_IGNORED,
$token
);
} else {
$this->addCorrection(
self::CORRECTION_UNMATCHED_GROUP_RIGHT_DELIMITER_IGNORED,
$token
);
}
}
} | php | private function cleanupGroupDelimiters(array &$tokens)
{
$indexes = $this->getUnmatchedGroupDelimiterIndexes($tokens);
while (!empty($indexes)) {
$lastIndex = array_pop($indexes);
$token = $tokens[$lastIndex];
unset($tokens[$lastIndex]);
if ($token->type === Tokenizer::TOKEN_GROUP_BEGIN) {
$this->addCorrection(
self::CORRECTION_UNMATCHED_GROUP_LEFT_DELIMITER_IGNORED,
$token
);
} else {
$this->addCorrection(
self::CORRECTION_UNMATCHED_GROUP_RIGHT_DELIMITER_IGNORED,
$token
);
}
}
} | [
"private",
"function",
"cleanupGroupDelimiters",
"(",
"array",
"&",
"$",
"tokens",
")",
"{",
"$",
"indexes",
"=",
"$",
"this",
"->",
"getUnmatchedGroupDelimiterIndexes",
"(",
"$",
"tokens",
")",
";",
"while",
"(",
"!",
"empty",
"(",
"$",
"indexes",
")",
")... | Clean up group delimiter tokens, removing unmatched left and right delimiter.
Closest group delimiters will be matched first, unmatched remainder is removed.
@param \QueryTranslator\Values\Token[] $tokens | [
"Clean",
"up",
"group",
"delimiter",
"tokens",
"removing",
"unmatched",
"left",
"and",
"right",
"delimiter",
"."
] | 22710ee4a130eb5f873081fdb465c184d7f29dff | https://github.com/netgen/query-translator/blob/22710ee4a130eb5f873081fdb465c184d7f29dff/lib/Languages/Galach/Parser.php#L592-L613 |
44,853 | BoltApp/bolt-magento2 | Helper/Session.php | Session.saveSession | public function saveSession($qouoteId, $checkoutSession)
{
// cache the session id by (parent) quote id
$cacheIdentifier = self::BOLT_SESSION_PREFIX . $qouoteId;
$sessionData = [
"sessionType" => $checkoutSession instanceof \Magento\Checkout\Model\Session ? "frontend" : "admin",
"sessionID" => $checkoutSession->getSessionId()
];
$this->cache->save(serialize($sessionData), $cacheIdentifier, [], 86400);
} | php | public function saveSession($qouoteId, $checkoutSession)
{
// cache the session id by (parent) quote id
$cacheIdentifier = self::BOLT_SESSION_PREFIX . $qouoteId;
$sessionData = [
"sessionType" => $checkoutSession instanceof \Magento\Checkout\Model\Session ? "frontend" : "admin",
"sessionID" => $checkoutSession->getSessionId()
];
$this->cache->save(serialize($sessionData), $cacheIdentifier, [], 86400);
} | [
"public",
"function",
"saveSession",
"(",
"$",
"qouoteId",
",",
"$",
"checkoutSession",
")",
"{",
"// cache the session id by (parent) quote id",
"$",
"cacheIdentifier",
"=",
"self",
"::",
"BOLT_SESSION_PREFIX",
".",
"$",
"qouoteId",
";",
"$",
"sessionData",
"=",
"[... | Cache the session id for the quote
@param int|string $qouoteId
@param mixed $checkoutSession | [
"Cache",
"the",
"session",
"id",
"for",
"the",
"quote"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Session.php#L94-L103 |
44,854 | BoltApp/bolt-magento2 | Helper/Session.php | Session.setSession | private function setSession($session, $sessionID)
{
// close current session
$session->writeClose();
// set session id (to value loaded from cache)
$session->setSessionId($sessionID);
// re-start the session
$session->start();
} | php | private function setSession($session, $sessionID)
{
// close current session
$session->writeClose();
// set session id (to value loaded from cache)
$session->setSessionId($sessionID);
// re-start the session
$session->start();
} | [
"private",
"function",
"setSession",
"(",
"$",
"session",
",",
"$",
"sessionID",
")",
"{",
"// close current session",
"$",
"session",
"->",
"writeClose",
"(",
")",
";",
"// set session id (to value loaded from cache)",
"$",
"session",
"->",
"setSessionId",
"(",
"$"... | Emulate session from cached session id
@param mixed $session
@param string $sessionID | [
"Emulate",
"session",
"from",
"cached",
"session",
"id"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Session.php#L111-L119 |
44,855 | BoltApp/bolt-magento2 | Helper/Session.php | Session.loadSession | public function loadSession($quote)
{
// not an API call, no need to emulate session
if ($this->appState->getAreaCode() != \Magento\Framework\App\Area::AREA_WEBAPI_REST) {
$this->replaceQuote($quote);
return;
}
$customerId = $quote->getCustomerId();
$cacheIdentifier = self::BOLT_SESSION_PREFIX . $quote->getBoltParentQuoteId();
if ($serialized = $this->cache->load($cacheIdentifier)) {
$sessionData = unserialize($serialized);
$sessionID = $sessionData["sessionID"];
if ($sessionData["sessionType"] == "frontend") {
// shipping and tax, orphaned transaction
// cart belongs to logged in customer?
if ($customerId) {
$this->setSession($this->checkoutSession, $sessionID);
$this->setSession($this->customerSession, $sessionID);
}
} else {
// orphaned transaction
$this->setSession($this->adminCheckoutSession, $sessionID);
}
}
if ($customerId) {
$this->customerSession->loginById($customerId);
}
$this->replaceQuote($quote);
} | php | public function loadSession($quote)
{
// not an API call, no need to emulate session
if ($this->appState->getAreaCode() != \Magento\Framework\App\Area::AREA_WEBAPI_REST) {
$this->replaceQuote($quote);
return;
}
$customerId = $quote->getCustomerId();
$cacheIdentifier = self::BOLT_SESSION_PREFIX . $quote->getBoltParentQuoteId();
if ($serialized = $this->cache->load($cacheIdentifier)) {
$sessionData = unserialize($serialized);
$sessionID = $sessionData["sessionID"];
if ($sessionData["sessionType"] == "frontend") {
// shipping and tax, orphaned transaction
// cart belongs to logged in customer?
if ($customerId) {
$this->setSession($this->checkoutSession, $sessionID);
$this->setSession($this->customerSession, $sessionID);
}
} else {
// orphaned transaction
$this->setSession($this->adminCheckoutSession, $sessionID);
}
}
if ($customerId) {
$this->customerSession->loginById($customerId);
}
$this->replaceQuote($quote);
} | [
"public",
"function",
"loadSession",
"(",
"$",
"quote",
")",
"{",
"// not an API call, no need to emulate session",
"if",
"(",
"$",
"this",
"->",
"appState",
"->",
"getAreaCode",
"(",
")",
"!=",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"App",
"\\",
"Area",
":... | Load logged in customer checkout and customer sessions from cached session id.
Replace parent quote with immutable quote in checkout session.
@param Quote $quote
@throws \Magento\Framework\Exception\SessionException | [
"Load",
"logged",
"in",
"customer",
"checkout",
"and",
"customer",
"sessions",
"from",
"cached",
"session",
"id",
".",
"Replace",
"parent",
"quote",
"with",
"immutable",
"quote",
"in",
"checkout",
"session",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Session.php#L137-L169 |
44,856 | BoltApp/bolt-magento2 | Helper/Bugsnag.php | Bugsnag.addCommonMetaData | private function addCommonMetaData()
{
$this->bugsnag->registerCallback(function ($report) {
$report->addMetaData([
'META DATA' => [
'store_url' => $this->storeManager->getStore()->getBaseUrl(
\Magento\Framework\UrlInterface::URL_TYPE_WEB
)
]
]);
});
} | php | private function addCommonMetaData()
{
$this->bugsnag->registerCallback(function ($report) {
$report->addMetaData([
'META DATA' => [
'store_url' => $this->storeManager->getStore()->getBaseUrl(
\Magento\Framework\UrlInterface::URL_TYPE_WEB
)
]
]);
});
} | [
"private",
"function",
"addCommonMetaData",
"(",
")",
"{",
"$",
"this",
"->",
"bugsnag",
"->",
"registerCallback",
"(",
"function",
"(",
"$",
"report",
")",
"{",
"$",
"report",
"->",
"addMetaData",
"(",
"[",
"'META DATA'",
"=>",
"[",
"'store_url'",
"=>",
"... | Add metadata to every bugsnag log | [
"Add",
"metadata",
"to",
"every",
"bugsnag",
"log"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Bugsnag.php#L144-L155 |
44,857 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getCdnUrl | public function getCdnUrl($storeId = null)
{
//Check for sandbox mode
if ($this->isSandboxModeSet($storeId)) {
return self::CDN_URL_SANDBOX;
} else {
return self::CDN_URL_PRODUCTION;
}
} | php | public function getCdnUrl($storeId = null)
{
//Check for sandbox mode
if ($this->isSandboxModeSet($storeId)) {
return self::CDN_URL_SANDBOX;
} else {
return self::CDN_URL_PRODUCTION;
}
} | [
"public",
"function",
"getCdnUrl",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"//Check for sandbox mode",
"if",
"(",
"$",
"this",
"->",
"isSandboxModeSet",
"(",
"$",
"storeId",
")",
")",
"{",
"return",
"self",
"::",
"CDN_URL_SANDBOX",
";",
"}",
"else",
"{... | Get Bolt JavaScript base URL
@param int|string $storeId
@return string | [
"Get",
"Bolt",
"JavaScript",
"base",
"URL"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L324-L332 |
44,858 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getEncryptedKey | private function getEncryptedKey($path, $storeId = null)
{
//Get management key
$key = $this->getScopeConfig()->getValue(
$path,
ScopeInterface::SCOPE_STORE,
$storeId
);
//Decrypt management key
$key = $this->encryptor->decrypt($key);
return $key;
} | php | private function getEncryptedKey($path, $storeId = null)
{
//Get management key
$key = $this->getScopeConfig()->getValue(
$path,
ScopeInterface::SCOPE_STORE,
$storeId
);
//Decrypt management key
$key = $this->encryptor->decrypt($key);
return $key;
} | [
"private",
"function",
"getEncryptedKey",
"(",
"$",
"path",
",",
"$",
"storeId",
"=",
"null",
")",
"{",
"//Get management key",
"$",
"key",
"=",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"$",
"path",
",",
"ScopeInterface",
"::",... | Helper method to Get Encrypted Key from config.
Return decrypted.
@param string $path
@param int|string $storeId
@return string | [
"Helper",
"method",
"to",
"Get",
"Encrypted",
"Key",
"from",
"config",
".",
"Return",
"decrypted",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L361-L373 |
44,859 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getTotalsChangeSelectors | public function getTotalsChangeSelectors($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_TOTALS_CHANGE_SELECTORS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | public function getTotalsChangeSelectors($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_TOTALS_CHANGE_SELECTORS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"public",
"function",
"getTotalsChangeSelectors",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_TOTALS_CHANGE_SELECTORS",
",",
"ScopeInterface",
"::",
"SCOPE_STOR... | Get Totals Change Selectors from config
@param int|string $storeId
@return string | [
"Get",
"Totals",
"Change",
"Selectors",
"from",
"config"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L470-L477 |
44,860 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getAdditionalCheckoutButtonClass | public function getAdditionalCheckoutButtonClass($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_ADDITIONAL_CHECKOUT_BUTTON_CLASS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | public function getAdditionalCheckoutButtonClass($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_ADDITIONAL_CHECKOUT_BUTTON_CLASS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"public",
"function",
"getAdditionalCheckoutButtonClass",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_ADDITIONAL_CHECKOUT_BUTTON_CLASS",
",",
"ScopeInterface",
":... | Get additional checkout button class
@param int|string $storeId
@return string | [
"Get",
"additional",
"checkout",
"button",
"class"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L502-L509 |
44,861 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getPrefetchAddressFields | public function getPrefetchAddressFields($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_PREFETCH_ADDRESS_FIELDS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | public function getPrefetchAddressFields($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_PREFETCH_ADDRESS_FIELDS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"public",
"function",
"getPrefetchAddressFields",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_PREFETCH_ADDRESS_FIELDS",
",",
"ScopeInterface",
"::",
"SCOPE_STOR... | Get Custom Prefetch Address Fields
@param int|string $storeId
@return string | [
"Get",
"Custom",
"Prefetch",
"Address",
"Fields"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L518-L525 |
44,862 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getSuccessPageRedirect | public function getSuccessPageRedirect($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_SUCCESS_PAGE_REDIRECT,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | public function getSuccessPageRedirect($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_SUCCESS_PAGE_REDIRECT,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"public",
"function",
"getSuccessPageRedirect",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_SUCCESS_PAGE_REDIRECT",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
... | Get Success Page Redirect from config
@param int|string $storeId
@return string | [
"Get",
"Success",
"Page",
"Redirect",
"from",
"config"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L534-L541 |
44,863 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getJavascriptSuccess | public function getJavascriptSuccess($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_JAVASCRIPT_SUCCESS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | public function getJavascriptSuccess($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_JAVASCRIPT_SUCCESS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"public",
"function",
"getJavascriptSuccess",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_JAVASCRIPT_SUCCESS",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
","... | Get Custom javascript function call on success
@param int|string $storeId
@return string | [
"Get",
"Custom",
"javascript",
"function",
"call",
"on",
"success"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L550-L557 |
44,864 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getAutomaticCaptureMode | public function getAutomaticCaptureMode($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_AUTOMATIC_CAPTURE_MODE,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function getAutomaticCaptureMode($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_AUTOMATIC_CAPTURE_MODE,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"getAutomaticCaptureMode",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_AUTOMATIC_CAPTURE_MODE",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",... | Get Automatic Capture mode from config
@param int|string|Store $store
@return boolean | [
"Get",
"Automatic",
"Capture",
"mode",
"from",
"config"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L566-L573 |
44,865 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getPrefetchShipping | public function getPrefetchShipping($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_PREFETCH_SHIPPING,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function getPrefetchShipping($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_PREFETCH_SHIPPING,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"getPrefetchShipping",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_PREFETCH_SHIPPING",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
",",
... | Get Prefetch Shipping and Tax config
@param int|string|Store $store
@return boolean | [
"Get",
"Prefetch",
"Shipping",
"and",
"Tax",
"config"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L582-L589 |
44,866 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getResetShippingCalculation | public function getResetShippingCalculation($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_RESET_SHIPPING_CALCULATION,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function getResetShippingCalculation($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_RESET_SHIPPING_CALCULATION,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"getResetShippingCalculation",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_RESET_SHIPPING_CALCULATION",
",",
"ScopeInterface",
"::",
"SCOPE... | Get Reset Shipping Calculation config
@param int|string|Store $store
@return boolean | [
"Get",
"Reset",
"Shipping",
"Calculation",
"config"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L598-L605 |
44,867 | BoltApp/bolt-magento2 | Helper/Config.php | Config.isActive | public function isActive($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_ACTIVE,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function isActive($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_ACTIVE,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"isActive",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_ACTIVE",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
",",
"$",
"store",
")"... | Check if module is enabled
@param int|string|Store $store
@return boolean | [
"Check",
"if",
"module",
"is",
"enabled"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L614-L621 |
44,868 | BoltApp/bolt-magento2 | Helper/Config.php | Config.isDebugModeOn | public function isDebugModeOn($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_DEBUG,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function isDebugModeOn($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_DEBUG,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"isDebugModeOn",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_DEBUG",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
",",
"$",
"store",
... | Check if debug mode is on
@param int|string|Store $store
@return boolean | [
"Check",
"if",
"debug",
"mode",
"is",
"on"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L630-L637 |
44,869 | BoltApp/bolt-magento2 | Helper/Config.php | Config.isSandboxModeSet | public function isSandboxModeSet($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_SANDBOX_MODE,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function isSandboxModeSet($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_SANDBOX_MODE,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"isSandboxModeSet",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_SANDBOX_MODE",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
",",
"$",
... | Get sandbox mode config value
@param int|string|Store $store
@return bool
@SuppressWarnings(PHPMD.BooleanGetMethodName)
@codeCoverageIgnore | [
"Get",
"sandbox",
"mode",
"config",
"value"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L648-L655 |
44,870 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getAdditionalJS | public function getAdditionalJS($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_ADDITIONAL_JS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | public function getAdditionalJS($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_ADDITIONAL_JS,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"public",
"function",
"getAdditionalJS",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_ADDITIONAL_JS",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
",",
"$",
... | Get Additional Javascript from config
@param int|string $storeId
@return string | [
"Get",
"Additional",
"Javascript",
"from",
"config"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L684-L691 |
44,871 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getAdditionalConfigString | protected function getAdditionalConfigString($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_ADDITIONAL_CONFIG,
ScopeInterface::SCOPE_STORE,
$storeId
) ?: '{}';
} | php | protected function getAdditionalConfigString($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_ADDITIONAL_CONFIG,
ScopeInterface::SCOPE_STORE,
$storeId
) ?: '{}';
} | [
"protected",
"function",
"getAdditionalConfigString",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_ADDITIONAL_CONFIG",
",",
"ScopeInterface",
"::",
"SCOPE_STORE"... | Get Additional Config string
@param int|string $storeId
@return string | [
"Get",
"Additional",
"Config",
"string"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L795-L802 |
44,872 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getAdditionalConfigProperty | private function getAdditionalConfigProperty($name, $storeId = null)
{
$config = $this->getAdditionalConfigObject($storeId);
return @$config->$name;
// return ($config && property_exists($config, $name)) ? $config->$name: '';
} | php | private function getAdditionalConfigProperty($name, $storeId = null)
{
$config = $this->getAdditionalConfigObject($storeId);
return @$config->$name;
// return ($config && property_exists($config, $name)) ? $config->$name: '';
} | [
"private",
"function",
"getAdditionalConfigProperty",
"(",
"$",
"name",
",",
"$",
"storeId",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getAdditionalConfigObject",
"(",
"$",
"storeId",
")",
";",
"return",
"@",
"$",
"config",
"->",
"$",
... | Get Additional Config property
@param $name
@param int|string $storeId
@return string | [
"Get",
"Additional",
"Config",
"property"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L824-L829 |
44,873 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getMinicartSupport | public function getMinicartSupport($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_MINICART_SUPPORT,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function getMinicartSupport($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_MINICART_SUPPORT,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"getMinicartSupport",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_MINICART_SUPPORT",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
",",
"... | Get MiniCart Support config
@param int|string|Store $store
@return boolean | [
"Get",
"MiniCart",
"Support",
"config"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L892-L899 |
44,874 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getPageFilter | private function getPageFilter($filterName, $storeId = null)
{
$pageFilters = $this->getPageFilters($storeId);
if ($pageFilters && @$pageFilters->$filterName) {
return (array)$pageFilters->$filterName;
}
return [];
} | php | private function getPageFilter($filterName, $storeId = null)
{
$pageFilters = $this->getPageFilters($storeId);
if ($pageFilters && @$pageFilters->$filterName) {
return (array)$pageFilters->$filterName;
}
return [];
} | [
"private",
"function",
"getPageFilter",
"(",
"$",
"filterName",
",",
"$",
"storeId",
"=",
"null",
")",
"{",
"$",
"pageFilters",
"=",
"$",
"this",
"->",
"getPageFilters",
"(",
"$",
"storeId",
")",
";",
"if",
"(",
"$",
"pageFilters",
"&&",
"@",
"$",
"pag... | Get filter specified by name from "pageFilters" additional configuration
@param string $filterName 'whitelist'|'blacklist'
@param int|string $storeId
@return array | [
"Get",
"filter",
"specified",
"by",
"name",
"from",
"pageFilters",
"additional",
"configuration"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L927-L934 |
44,875 | BoltApp/bolt-magento2 | Helper/Config.php | Config.getIPWhitelistConfig | private function getIPWhitelistConfig($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_IP_WHITELIST,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | private function getIPWhitelistConfig($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_IP_WHITELIST,
ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"private",
"function",
"getIPWhitelistConfig",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_IP_WHITELIST",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
",",
"... | Get Client IP Whitelist from config
@param int|string $storeId
@return string | [
"Get",
"Client",
"IP",
"Whitelist",
"from",
"config"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L986-L993 |
44,876 | BoltApp/bolt-magento2 | Helper/Config.php | Config.isIPRestricted | public function isIPRestricted($storeId = null)
{
$clientIP = $this->getClientIp();
$whitelist = $this->getIPWhitelistArray($storeId);
return $whitelist && ! in_array($clientIP, $whitelist);
} | php | public function isIPRestricted($storeId = null)
{
$clientIP = $this->getClientIp();
$whitelist = $this->getIPWhitelistArray($storeId);
return $whitelist && ! in_array($clientIP, $whitelist);
} | [
"public",
"function",
"isIPRestricted",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"$",
"clientIP",
"=",
"$",
"this",
"->",
"getClientIp",
"(",
")",
";",
"$",
"whitelist",
"=",
"$",
"this",
"->",
"getIPWhitelistArray",
"(",
"$",
"storeId",
")",
";",
"... | Check if the client IP is restricted -
there is an IP whitelist and the client IP is not on the list.
@return bool | [
"Check",
"if",
"the",
"client",
"IP",
"is",
"restricted",
"-",
"there",
"is",
"an",
"IP",
"whitelist",
"and",
"the",
"client",
"IP",
"is",
"not",
"on",
"the",
"list",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L1038-L1043 |
44,877 | BoltApp/bolt-magento2 | Helper/Config.php | Config.useStoreCreditConfig | public function useStoreCreditConfig($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_STORE_CREDIT,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function useStoreCreditConfig($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_STORE_CREDIT,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"useStoreCreditConfig",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_STORE_CREDIT",
",",
"ScopeInterface",
"::",
"SCOPE_STORE",
",",
"$"... | Get Use Store Credit on Shopping Cart configuration
@param int|string|Store $store
@return bool | [
"Get",
"Use",
"Store",
"Credit",
"on",
"Shopping",
"Cart",
"configuration"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L1051-L1058 |
44,878 | BoltApp/bolt-magento2 | Helper/Config.php | Config.isPaymentOnlyCheckoutEnabled | public function isPaymentOnlyCheckoutEnabled($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_PAYMENT_ONLY_CHECKOUT,
ScopeInterface::SCOPE_STORE,
$store
);
} | php | public function isPaymentOnlyCheckoutEnabled($store = null)
{
return $this->getScopeConfig()->isSetFlag(
self::XML_PATH_PAYMENT_ONLY_CHECKOUT,
ScopeInterface::SCOPE_STORE,
$store
);
} | [
"public",
"function",
"isPaymentOnlyCheckoutEnabled",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getScopeConfig",
"(",
")",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_PAYMENT_ONLY_CHECKOUT",
",",
"ScopeInterface",
"::",
"SCOPE_STO... | Get Payment Only Checkout Enabled configuration
@param int|string|Store $store
@return bool | [
"Get",
"Payment",
"Only",
"Checkout",
"Enabled",
"configuration"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Config.php#L1066-L1073 |
44,879 | BoltApp/bolt-magento2 | Model/Api/Data/ShippingOptions.php | ShippingOptions.addAmountToShippingOptions | public function addAmountToShippingOptions($amount){
foreach ($this->getShippingOptions() as $option) {
$option->setCost($option->getCost() + $amount);
}
return $this;
} | php | public function addAmountToShippingOptions($amount){
foreach ($this->getShippingOptions() as $option) {
$option->setCost($option->getCost() + $amount);
}
return $this;
} | [
"public",
"function",
"addAmountToShippingOptions",
"(",
"$",
"amount",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getShippingOptions",
"(",
")",
"as",
"$",
"option",
")",
"{",
"$",
"option",
"->",
"setCost",
"(",
"$",
"option",
"->",
"getCost",
"(",
... | Add amount to shipping options.
@api
@param int $amount
@return $this | [
"Add",
"amount",
"to",
"shipping",
"options",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/Data/ShippingOptions.php#L98-L104 |
44,880 | BoltApp/bolt-magento2 | Model/Api/DiscountCodeValidation.php | DiscountCodeValidation.loadGiftCardData | public function loadGiftCardData($code)
{
$result = null;
/** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardAccount */
$giftCardAccountResource = $this->moduleGiftCardAccount->getInstance();
if ($giftCardAccountResource) {
$this->logHelper->addInfoLog('### GiftCard ###');
$this->logHelper->addInfoLog('# Code: ' . $code);
/** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardsCollection */
$giftCardsCollection = $giftCardAccountResource
->addFieldToFilter('code', ['eq' => $code]);
/** @var \Magento\GiftCardAccount\Model\Giftcardaccount $giftCard */
$giftCard = $giftCardsCollection->getFirstItem();
$result = (!$giftCard->isEmpty() && $giftCard->isValid()) ? $giftCard : null;
}
$this->logHelper->addInfoLog('# loadGiftCertData Result is empty: '. ((!$result) ? 'yes' : 'no'));
return $result;
} | php | public function loadGiftCardData($code)
{
$result = null;
/** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardAccount */
$giftCardAccountResource = $this->moduleGiftCardAccount->getInstance();
if ($giftCardAccountResource) {
$this->logHelper->addInfoLog('### GiftCard ###');
$this->logHelper->addInfoLog('# Code: ' . $code);
/** @var \Magento\GiftCardAccount\Model\ResourceModel\Giftcardaccount\Collection $giftCardsCollection */
$giftCardsCollection = $giftCardAccountResource
->addFieldToFilter('code', ['eq' => $code]);
/** @var \Magento\GiftCardAccount\Model\Giftcardaccount $giftCard */
$giftCard = $giftCardsCollection->getFirstItem();
$result = (!$giftCard->isEmpty() && $giftCard->isValid()) ? $giftCard : null;
}
$this->logHelper->addInfoLog('# loadGiftCertData Result is empty: '. ((!$result) ? 'yes' : 'no'));
return $result;
} | [
"public",
"function",
"loadGiftCardData",
"(",
"$",
"code",
")",
"{",
"$",
"result",
"=",
"null",
";",
"/** @var \\Magento\\GiftCardAccount\\Model\\ResourceModel\\Giftcardaccount\\Collection $giftCardAccount */",
"$",
"giftCardAccountResource",
"=",
"$",
"this",
"->",
"module... | Load the gift card data by code
@param $code
@return \Magento\GiftCardAccount\Model\Giftcardaccount|null | [
"Load",
"the",
"gift",
"card",
"data",
"by",
"code"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/DiscountCodeValidation.php#L781-L805 |
44,881 | BoltApp/bolt-magento2 | Block/Form.php | Form.getBillingAddress | public function getBillingAddress($needJsonEncode = true)
{
$quote = $this->getQuoteData();
/** @var \Magento\Quote\Model\Quote\Address $billingAddress */
$billingAddress = $quote->getBillingAddress();
$streetAddressLines = [];
$streetAddressLines[] = $billingAddress->getStreetLine(1);
if ($billingAddress->getStreetLine(2)) {
$streetAddressLines[] = $billingAddress->getStreetLine(2);
}
$result = [
'customerAddressId' => $billingAddress->getId(),
'countryId' => $billingAddress->getCountryId(),
'regionId' => $billingAddress->getRegionId(),
'regionCode' => $billingAddress->getRegionCode(),
'region' => $billingAddress->getRegion(),
'customerId' => $billingAddress->getCustomerId(),
'street' => $streetAddressLines,
'telephone' => $billingAddress->getTelephone(),
'postcode' => $billingAddress->getPostcode(),
'city' => $billingAddress->getCity(),
'firstname' => $billingAddress->getFirstname(),
'lastname' => $billingAddress->getLastname(),
'extensionAttributes' => ['checkoutFields' => []],
'saveInAddressBook' => $billingAddress->getSaveInAddressBook()
];
return ($needJsonEncode) ? json_encode($result) : $result;
} | php | public function getBillingAddress($needJsonEncode = true)
{
$quote = $this->getQuoteData();
/** @var \Magento\Quote\Model\Quote\Address $billingAddress */
$billingAddress = $quote->getBillingAddress();
$streetAddressLines = [];
$streetAddressLines[] = $billingAddress->getStreetLine(1);
if ($billingAddress->getStreetLine(2)) {
$streetAddressLines[] = $billingAddress->getStreetLine(2);
}
$result = [
'customerAddressId' => $billingAddress->getId(),
'countryId' => $billingAddress->getCountryId(),
'regionId' => $billingAddress->getRegionId(),
'regionCode' => $billingAddress->getRegionCode(),
'region' => $billingAddress->getRegion(),
'customerId' => $billingAddress->getCustomerId(),
'street' => $streetAddressLines,
'telephone' => $billingAddress->getTelephone(),
'postcode' => $billingAddress->getPostcode(),
'city' => $billingAddress->getCity(),
'firstname' => $billingAddress->getFirstname(),
'lastname' => $billingAddress->getLastname(),
'extensionAttributes' => ['checkoutFields' => []],
'saveInAddressBook' => $billingAddress->getSaveInAddressBook()
];
return ($needJsonEncode) ? json_encode($result) : $result;
} | [
"public",
"function",
"getBillingAddress",
"(",
"$",
"needJsonEncode",
"=",
"true",
")",
"{",
"$",
"quote",
"=",
"$",
"this",
"->",
"getQuoteData",
"(",
")",
";",
"/** @var \\Magento\\Quote\\Model\\Quote\\Address $billingAddress */",
"$",
"billingAddress",
"=",
"$",
... | Return billing address information formatted to be used for magento order creation.
Example return value:
{"customerAddressId":"404","countryId":"US","regionId":"12","regionCode":"CA","region":"California",
"customerId":"202","street":["adasdasd 1234"],"telephone":"314-123-4125","postcode":"90014",
"city":"Los Angeles","firstname":"YevhenTest","lastname":"BoltDev",
"extensionAttributes":{"checkoutFields":{}},"saveInAddressBook":null}
@param bool $needJsonEncode
@return string | [
"Return",
"billing",
"address",
"information",
"formatted",
"to",
"be",
"used",
"for",
"magento",
"order",
"creation",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Block/Form.php#L81-L111 |
44,882 | BoltApp/bolt-magento2 | Plugin/RequireJs.php | RequireJs.afterGetFiles | public function afterGetFiles(RequireJsCollector $subject, array $files)
{
$magentoVersion = $this->productMetadata->getVersion();
if (version_compare($magentoVersion, '2.2.0', '>=')) {
foreach ($files as $index => $file) {
if ($file->getModule() === 'Bolt_Boltpay') {
unset($files[$index]);
}
}
}
return $files;
} | php | public function afterGetFiles(RequireJsCollector $subject, array $files)
{
$magentoVersion = $this->productMetadata->getVersion();
if (version_compare($magentoVersion, '2.2.0', '>=')) {
foreach ($files as $index => $file) {
if ($file->getModule() === 'Bolt_Boltpay') {
unset($files[$index]);
}
}
}
return $files;
} | [
"public",
"function",
"afterGetFiles",
"(",
"RequireJsCollector",
"$",
"subject",
",",
"array",
"$",
"files",
")",
"{",
"$",
"magentoVersion",
"=",
"$",
"this",
"->",
"productMetadata",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"version_compare",
"(",
"$... | After requireJs files are collected remove the ones added by Bolt
for the store version greater than or equal to 2.2.0.
@param RequireJsCollector $subject
@param array $files
@return array | [
"After",
"requireJs",
"files",
"are",
"collected",
"remove",
"the",
"ones",
"added",
"by",
"Bolt",
"for",
"the",
"store",
"version",
"greater",
"than",
"or",
"equal",
"to",
"2",
".",
"2",
".",
"0",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Plugin/RequireJs.php#L55-L69 |
44,883 | BoltApp/bolt-magento2 | Model/Api/ShippingMethods.php | ShippingMethods.validateEmail | private function validateEmail($email)
{
if (!$this->cartHelper->validateEmail($email)) {
throw new BoltException(
__('Invalid email: %1', $email),
null,
BoltErrorResponse::ERR_UNIQUE_EMAIL_REQUIRED
);
}
} | php | private function validateEmail($email)
{
if (!$this->cartHelper->validateEmail($email)) {
throw new BoltException(
__('Invalid email: %1', $email),
null,
BoltErrorResponse::ERR_UNIQUE_EMAIL_REQUIRED
);
}
} | [
"private",
"function",
"validateEmail",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cartHelper",
"->",
"validateEmail",
"(",
"$",
"email",
")",
")",
"{",
"throw",
"new",
"BoltException",
"(",
"__",
"(",
"'Invalid email: %1'",
",",
"$... | Validate request email
@param $email
@throws BoltException
@throws \Zend_Validate_Exception | [
"Validate",
"request",
"email"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/ShippingMethods.php#L289-L298 |
44,884 | BoltApp/bolt-magento2 | Model/Api/ShippingMethods.php | ShippingMethods.getShippingMethods | public function getShippingMethods($cart, $shipping_address)
{
try {
// $this->logHelper->addInfoLog($this->request->getContent());
$this->preprocessHook();
// get immutable quote id stored with transaction
list(, $quoteId) = explode(' / ', $cart['display_id']);
// Load quote from entity id
$quote = $this->cartHelper->getQuoteById($quoteId);
if (!$quote || !$quote->getId()) {
$this->throwUnknownQuoteIdException($quoteId);
}
$this->checkCartItems($cart, $quote);
// Load logged in customer checkout and customer sessions from cached session id.
// Replace parent quote with immutable quote in checkout session.
$this->sessionHelper->loadSession($quote);
$addressData = $this->cartHelper->handleSpecialAddressCases($shipping_address);
if (isset($addressData['email']) && $addressData['email'] !== null) {
$this->validateAddressData($addressData);
}
$shippingOptionsModel = $this->shippingEstimation($quote, $addressData);
if ($this->taxAdjusted) {
$this->bugsnag->registerCallback(function ($report) use ($shippingOptionsModel) {
$report->setMetaData([
'SHIPPING OPTIONS' => [print_r($shippingOptionsModel, 1)]
]);
});
$this->bugsnag->notifyError('Cart Totals Mismatch', "Totals adjusted.");
}
/** @var \Magento\Quote\Model\Quote $parentQuote */
$parentQuote = $this->cartHelper->getQuoteById($cart['order_reference']);
if ($this->couponInvalidForShippingAddress($parentQuote->getCouponCode(), $quote)){
$address = $parentQuote->isVirtual() ? $parentQuote->getBillingAddress() : $parentQuote->getShippingAddress();
$additionalAmount = abs($this->cartHelper->getRoundAmount($address->getDiscountAmount()));
$shippingOptionsModel->addAmountToShippingOptions($additionalAmount);
}
return $shippingOptionsModel;
} catch (\Magento\Framework\Webapi\Exception $e) {
$this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode(), $e->getHttpCode());
} catch (BoltException $e) {
$this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode());
} catch (\Exception $e) {
$msg = __('Unprocessable Entity') . ': ' . $e->getMessage();
$this->catchExceptionAndSendError($e, $msg, 6009, 422);
}
} | php | public function getShippingMethods($cart, $shipping_address)
{
try {
// $this->logHelper->addInfoLog($this->request->getContent());
$this->preprocessHook();
// get immutable quote id stored with transaction
list(, $quoteId) = explode(' / ', $cart['display_id']);
// Load quote from entity id
$quote = $this->cartHelper->getQuoteById($quoteId);
if (!$quote || !$quote->getId()) {
$this->throwUnknownQuoteIdException($quoteId);
}
$this->checkCartItems($cart, $quote);
// Load logged in customer checkout and customer sessions from cached session id.
// Replace parent quote with immutable quote in checkout session.
$this->sessionHelper->loadSession($quote);
$addressData = $this->cartHelper->handleSpecialAddressCases($shipping_address);
if (isset($addressData['email']) && $addressData['email'] !== null) {
$this->validateAddressData($addressData);
}
$shippingOptionsModel = $this->shippingEstimation($quote, $addressData);
if ($this->taxAdjusted) {
$this->bugsnag->registerCallback(function ($report) use ($shippingOptionsModel) {
$report->setMetaData([
'SHIPPING OPTIONS' => [print_r($shippingOptionsModel, 1)]
]);
});
$this->bugsnag->notifyError('Cart Totals Mismatch', "Totals adjusted.");
}
/** @var \Magento\Quote\Model\Quote $parentQuote */
$parentQuote = $this->cartHelper->getQuoteById($cart['order_reference']);
if ($this->couponInvalidForShippingAddress($parentQuote->getCouponCode(), $quote)){
$address = $parentQuote->isVirtual() ? $parentQuote->getBillingAddress() : $parentQuote->getShippingAddress();
$additionalAmount = abs($this->cartHelper->getRoundAmount($address->getDiscountAmount()));
$shippingOptionsModel->addAmountToShippingOptions($additionalAmount);
}
return $shippingOptionsModel;
} catch (\Magento\Framework\Webapi\Exception $e) {
$this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode(), $e->getHttpCode());
} catch (BoltException $e) {
$this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode());
} catch (\Exception $e) {
$msg = __('Unprocessable Entity') . ': ' . $e->getMessage();
$this->catchExceptionAndSendError($e, $msg, 6009, 422);
}
} | [
"public",
"function",
"getShippingMethods",
"(",
"$",
"cart",
",",
"$",
"shipping_address",
")",
"{",
"try",
"{",
"// $this->logHelper->addInfoLog($this->request->getContent());",
"$",
"this",
"->",
"preprocessHook",
"(",
")",
";",
"// get immutable quote id stor... | Get all available shipping methods and tax data.
@api
@param array $cart cart details
@param array $shipping_address shipping address
@return ShippingOptionsInterface
@throws \Exception | [
"Get",
"all",
"available",
"shipping",
"methods",
"and",
"tax",
"data",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/ShippingMethods.php#L311-L369 |
44,885 | BoltApp/bolt-magento2 | Model/Api/ShippingMethods.php | ShippingMethods.getShippingOptionsData | protected function getShippingOptionsData($shippingMethods)
{
$shippingOptionsModel = $this->shippingOptionsInterfaceFactory->create();
$shippingTaxModel = $this->shippingTaxInterfaceFactory->create();
$shippingTaxModel->setAmount(0);
$shippingOptionsModel->setShippingOptions($shippingMethods);
$shippingOptionsModel->setTaxResult($shippingTaxModel);
return $shippingOptionsModel;
} | php | protected function getShippingOptionsData($shippingMethods)
{
$shippingOptionsModel = $this->shippingOptionsInterfaceFactory->create();
$shippingTaxModel = $this->shippingTaxInterfaceFactory->create();
$shippingTaxModel->setAmount(0);
$shippingOptionsModel->setShippingOptions($shippingMethods);
$shippingOptionsModel->setTaxResult($shippingTaxModel);
return $shippingOptionsModel;
} | [
"protected",
"function",
"getShippingOptionsData",
"(",
"$",
"shippingMethods",
")",
"{",
"$",
"shippingOptionsModel",
"=",
"$",
"this",
"->",
"shippingOptionsInterfaceFactory",
"->",
"create",
"(",
")",
";",
"$",
"shippingTaxModel",
"=",
"$",
"this",
"->",
"shipp... | Set shipping methods to the ShippingOptions object
@param $shippingMethods | [
"Set",
"shipping",
"methods",
"to",
"the",
"ShippingOptions",
"object"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/ShippingMethods.php#L536-L547 |
44,886 | BoltApp/bolt-magento2 | Model/Api/ShippingMethods.php | ShippingMethods.resetShippingCalculationIfNeeded | private function resetShippingCalculationIfNeeded($shippingAddress)
{
if ($this->configHelper->getResetShippingCalculation()) {
$shippingAddress->removeAllShippingRates();
$shippingAddress->setCollectShippingRates(true);
}
} | php | private function resetShippingCalculationIfNeeded($shippingAddress)
{
if ($this->configHelper->getResetShippingCalculation()) {
$shippingAddress->removeAllShippingRates();
$shippingAddress->setCollectShippingRates(true);
}
} | [
"private",
"function",
"resetShippingCalculationIfNeeded",
"(",
"$",
"shippingAddress",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configHelper",
"->",
"getResetShippingCalculation",
"(",
")",
")",
"{",
"$",
"shippingAddress",
"->",
"removeAllShippingRates",
"(",
")",... | Reset shipping calculation
On some store setups shipping prices are conditionally changed
depending on some custom logic. If it is done as a plugin for
some method in the Magento shipping flow, then that method
may be (indirectly) called from our Shipping And Tax flow more
than once, resulting in wrong prices. This function resets
address shipping calculation but can seriously slow down the
process (on a system with many shipping options available).
Use it carefully only when necesarry.
@param \Magento\Quote\Model\Quote\Address $shippingAddress | [
"Reset",
"shipping",
"calculation"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Api/ShippingMethods.php#L563-L569 |
44,887 | BoltApp/bolt-magento2 | Model/Payment.php | Payment.void | public function void(InfoInterface $payment)
{
try {
$transactionId = $payment->getAdditionalInformation('real_transaction_id');
if (empty($transactionId)) {
throw new LocalizedException(
__('Please wait while transaction gets updated from Bolt.')
);
}
//Get transaction data
$transactionData = ['transaction_id' => $transactionId];
$apiKey = $this->configHelper->getApiKey();
//Request Data
$requestData = $this->dataObjectFactory->create();
$requestData->setApiData($transactionData);
$requestData->setDynamicApiUrl(ApiHelper::API_VOID_TRANSACTION);
$requestData->setApiKey($apiKey);
//Build Request
$request = $this->apiHelper->buildRequest($requestData);
$result = $this->apiHelper->sendRequest($request);
$response = $result->getResponse();
if (empty($response)) {
throw new LocalizedException(
__('Bad void response from boltpay')
);
}
if (@$response->status != 'cancelled') {
throw new LocalizedException(__('Payment void error.'));
}
$order = $payment->getOrder();
$this->orderHelper->updateOrderPayment($order, null, $response->reference);
return $this;
} catch (\Exception $e) {
$this->bugsnag->notifyException($e);
throw $e;
}
} | php | public function void(InfoInterface $payment)
{
try {
$transactionId = $payment->getAdditionalInformation('real_transaction_id');
if (empty($transactionId)) {
throw new LocalizedException(
__('Please wait while transaction gets updated from Bolt.')
);
}
//Get transaction data
$transactionData = ['transaction_id' => $transactionId];
$apiKey = $this->configHelper->getApiKey();
//Request Data
$requestData = $this->dataObjectFactory->create();
$requestData->setApiData($transactionData);
$requestData->setDynamicApiUrl(ApiHelper::API_VOID_TRANSACTION);
$requestData->setApiKey($apiKey);
//Build Request
$request = $this->apiHelper->buildRequest($requestData);
$result = $this->apiHelper->sendRequest($request);
$response = $result->getResponse();
if (empty($response)) {
throw new LocalizedException(
__('Bad void response from boltpay')
);
}
if (@$response->status != 'cancelled') {
throw new LocalizedException(__('Payment void error.'));
}
$order = $payment->getOrder();
$this->orderHelper->updateOrderPayment($order, null, $response->reference);
return $this;
} catch (\Exception $e) {
$this->bugsnag->notifyException($e);
throw $e;
}
} | [
"public",
"function",
"void",
"(",
"InfoInterface",
"$",
"payment",
")",
"{",
"try",
"{",
"$",
"transactionId",
"=",
"$",
"payment",
"->",
"getAdditionalInformation",
"(",
"'real_transaction_id'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"transactionId",
")",
... | Void the payment through gateway
@param DataObject|InfoInterface $payment
@return $this
@throws \Exception | [
"Void",
"the",
"payment",
"through",
"gateway"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Payment.php#L240-L284 |
44,888 | BoltApp/bolt-magento2 | Model/Payment.php | Payment.capture | public function capture(InfoInterface $payment, $amount)
{
try {
$order = $payment->getOrder();
if ($amount <= 0) {
throw new LocalizedException(__('Invalid amount for capture.'));
}
$realTransactionId = $payment->getAdditionalInformation('real_transaction_id');
if (empty($realTransactionId)) {
throw new LocalizedException(
__('Please wait while transaction get updated from Bolt.')
);
}
$captureAmount = $amount * 100;
//Get capture data
$capturedData = [
'transaction_id' => $realTransactionId,
'amount' => $captureAmount,
'currency' => $order->getOrderCurrencyCode()
];
$apiKey = $this->configHelper->getApiKey();
//Request Data
$requestData = $this->dataObjectFactory->create();
$requestData->setApiData($capturedData);
$requestData->setDynamicApiUrl(ApiHelper::API_CAPTURE_TRANSACTION);
$requestData->setApiKey($apiKey);
//Build Request
$request = $this->apiHelper->buildRequest($requestData);
$result = $this->apiHelper->sendRequest($request);
$response = $result->getResponse();
if (empty($response)) {
throw new LocalizedException(
__('Bad capture response from boltpay')
);
}
if (!in_array(@$response->status, [self::TRANSACTION_AUTHORIZED, self::TRANSACTION_COMPLETED])) {
throw new LocalizedException(__('Payment capture error.'));
}
$this->orderHelper->updateOrderPayment($order, null, $response->reference);
return $this;
} catch (\Exception $e) {
$this->bugsnag->notifyException($e);
throw $e;
}
} | php | public function capture(InfoInterface $payment, $amount)
{
try {
$order = $payment->getOrder();
if ($amount <= 0) {
throw new LocalizedException(__('Invalid amount for capture.'));
}
$realTransactionId = $payment->getAdditionalInformation('real_transaction_id');
if (empty($realTransactionId)) {
throw new LocalizedException(
__('Please wait while transaction get updated from Bolt.')
);
}
$captureAmount = $amount * 100;
//Get capture data
$capturedData = [
'transaction_id' => $realTransactionId,
'amount' => $captureAmount,
'currency' => $order->getOrderCurrencyCode()
];
$apiKey = $this->configHelper->getApiKey();
//Request Data
$requestData = $this->dataObjectFactory->create();
$requestData->setApiData($capturedData);
$requestData->setDynamicApiUrl(ApiHelper::API_CAPTURE_TRANSACTION);
$requestData->setApiKey($apiKey);
//Build Request
$request = $this->apiHelper->buildRequest($requestData);
$result = $this->apiHelper->sendRequest($request);
$response = $result->getResponse();
if (empty($response)) {
throw new LocalizedException(
__('Bad capture response from boltpay')
);
}
if (!in_array(@$response->status, [self::TRANSACTION_AUTHORIZED, self::TRANSACTION_COMPLETED])) {
throw new LocalizedException(__('Payment capture error.'));
}
$this->orderHelper->updateOrderPayment($order, null, $response->reference);
return $this;
} catch (\Exception $e) {
$this->bugsnag->notifyException($e);
throw $e;
}
} | [
"public",
"function",
"capture",
"(",
"InfoInterface",
"$",
"payment",
",",
"$",
"amount",
")",
"{",
"try",
"{",
"$",
"order",
"=",
"$",
"payment",
"->",
"getOrder",
"(",
")",
";",
"if",
"(",
"$",
"amount",
"<=",
"0",
")",
"{",
"throw",
"new",
"Loc... | Capture the authorized transaction through the gateway
@param InfoInterface $payment
@param float $amount
@return $this
@throws \Exception | [
"Capture",
"the",
"authorized",
"transaction",
"through",
"the",
"gateway"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Payment.php#L331-L387 |
44,889 | BoltApp/bolt-magento2 | Model/Payment.php | Payment.isAvailable | public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
{
// check for product restrictions
if ($this->cartHelper->hasProductRestrictions($quote)) {
return false;
}
return parent::isAvailable();
} | php | public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
{
// check for product restrictions
if ($this->cartHelper->hasProductRestrictions($quote)) {
return false;
}
return parent::isAvailable();
} | [
"public",
"function",
"isAvailable",
"(",
"\\",
"Magento",
"\\",
"Quote",
"\\",
"Api",
"\\",
"Data",
"\\",
"CartInterface",
"$",
"quote",
"=",
"null",
")",
"{",
"// check for product restrictions",
"if",
"(",
"$",
"this",
"->",
"cartHelper",
"->",
"hasProductR... | Check whether payment method can be used
@param \Magento\Quote\Api\Data\CartInterface|null $quote
@return bool | [
"Check",
"whether",
"payment",
"method",
"can",
"be",
"used"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Model/Payment.php#L472-L479 |
44,890 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.isCheckoutAllowed | public function isCheckoutAllowed()
{
return $this->customerSession->isLoggedIn() || $this->checkoutHelper->isAllowedGuestCheckout($this->checkoutSession->getQuote());
} | php | public function isCheckoutAllowed()
{
return $this->customerSession->isLoggedIn() || $this->checkoutHelper->isAllowedGuestCheckout($this->checkoutSession->getQuote());
} | [
"public",
"function",
"isCheckoutAllowed",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"customerSession",
"->",
"isLoggedIn",
"(",
")",
"||",
"$",
"this",
"->",
"checkoutHelper",
"->",
"isAllowedGuestCheckout",
"(",
"$",
"this",
"->",
"checkoutSession",
"->",
... | Check if guest checkout is allowed
@return bool | [
"Check",
"if",
"guest",
"checkout",
"is",
"allowed"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L249-L252 |
44,891 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.getOrderByIncrementId | public function getOrderByIncrementId($incrementId)
{
$searchCriteria = $this->searchCriteriaBuilder
->addFilter('increment_id', $incrementId, 'eq')->create();
$collection = $this->orderRepository->getList($searchCriteria)->getItems();
return reset($collection);
} | php | public function getOrderByIncrementId($incrementId)
{
$searchCriteria = $this->searchCriteriaBuilder
->addFilter('increment_id', $incrementId, 'eq')->create();
$collection = $this->orderRepository->getList($searchCriteria)->getItems();
return reset($collection);
} | [
"public",
"function",
"getOrderByIncrementId",
"(",
"$",
"incrementId",
")",
"{",
"$",
"searchCriteria",
"=",
"$",
"this",
"->",
"searchCriteriaBuilder",
"->",
"addFilter",
"(",
"'increment_id'",
",",
"$",
"incrementId",
",",
"'eq'",
")",
"->",
"create",
"(",
... | Load Order by increment id
@param $incrementId
@return \Magento\Sales\Api\Data\OrderInterface|mixed | [
"Load",
"Order",
"by",
"increment",
"id"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L281-L287 |
44,892 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.getBoltpayOrder | public function getBoltpayOrder($paymentOnly, $placeOrderPayload, $storeId = 0)
{
//Get cart data
$cart = $this->getCartData($paymentOnly, $placeOrderPayload);
if (!$cart) {
return;
}
// cache the session id
$this->sessionHelper->saveSession($cart['order_reference'], $this->checkoutSession);
// If storeId was missed through request, then try to get it from the session quote.
if (!$storeId && $this->checkoutSession->getQuote()) {
$storeId = $this->checkoutSession->getQuote()->getStoreId();
}
$apiKey = $this->configHelper->getApiKey($storeId);
//Request Data
$requestData = $this->dataObjectFactory->create();
$requestData->setApiData(['cart' => $cart]);
$requestData->setDynamicApiUrl(ApiHelper::API_CREATE_ORDER);
$requestData->setApiKey($apiKey);
//Build Request
$request = $this->apiHelper->buildRequest($requestData);
$result = $this->apiHelper->sendRequest($request);
return $result;
} | php | public function getBoltpayOrder($paymentOnly, $placeOrderPayload, $storeId = 0)
{
//Get cart data
$cart = $this->getCartData($paymentOnly, $placeOrderPayload);
if (!$cart) {
return;
}
// cache the session id
$this->sessionHelper->saveSession($cart['order_reference'], $this->checkoutSession);
// If storeId was missed through request, then try to get it from the session quote.
if (!$storeId && $this->checkoutSession->getQuote()) {
$storeId = $this->checkoutSession->getQuote()->getStoreId();
}
$apiKey = $this->configHelper->getApiKey($storeId);
//Request Data
$requestData = $this->dataObjectFactory->create();
$requestData->setApiData(['cart' => $cart]);
$requestData->setDynamicApiUrl(ApiHelper::API_CREATE_ORDER);
$requestData->setApiKey($apiKey);
//Build Request
$request = $this->apiHelper->buildRequest($requestData);
$result = $this->apiHelper->sendRequest($request);
return $result;
} | [
"public",
"function",
"getBoltpayOrder",
"(",
"$",
"paymentOnly",
",",
"$",
"placeOrderPayload",
",",
"$",
"storeId",
"=",
"0",
")",
"{",
"//Get cart data",
"$",
"cart",
"=",
"$",
"this",
"->",
"getCartData",
"(",
"$",
"paymentOnly",
",",
"$",
"placeOrderPay... | Create order on bolt
@param bool $paymentOnly flag that represents the type of checkout
@param string $placeOrderPayload additional data collected from the (one page checkout) page,
i.e. billing address to be saved with the order
@param int $storeId
@return Response|void
@throws LocalizedException
@throws Zend_Http_Client_Exception | [
"Create",
"order",
"on",
"bolt"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L323-L351 |
44,893 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.getSignResponse | private function getSignResponse($signRequest)
{
$apiKey = $this->configHelper->getApiKey();
//Request Data
$requestData = $this->dataObjectFactory->create();
$requestData->setApiData($signRequest);
$requestData->setDynamicApiUrl(ApiHelper::API_SIGN);
$requestData->setApiKey($apiKey);
$request = $this->apiHelper->buildRequest($requestData);
try {
$result = $this->apiHelper->sendRequest($request);
} catch (\Exception $e) {
return null;
}
return $result;
} | php | private function getSignResponse($signRequest)
{
$apiKey = $this->configHelper->getApiKey();
//Request Data
$requestData = $this->dataObjectFactory->create();
$requestData->setApiData($signRequest);
$requestData->setDynamicApiUrl(ApiHelper::API_SIGN);
$requestData->setApiKey($apiKey);
$request = $this->apiHelper->buildRequest($requestData);
try {
$result = $this->apiHelper->sendRequest($request);
} catch (\Exception $e) {
return null;
}
return $result;
} | [
"private",
"function",
"getSignResponse",
"(",
"$",
"signRequest",
")",
"{",
"$",
"apiKey",
"=",
"$",
"this",
"->",
"configHelper",
"->",
"getApiKey",
"(",
")",
";",
"//Request Data",
"$",
"requestData",
"=",
"$",
"this",
"->",
"dataObjectFactory",
"->",
"cr... | Sign a payload using the Bolt endpoint
@param array $signRequest payload to sign
@return Response|int | [
"Sign",
"a",
"payload",
"using",
"the",
"Bolt",
"endpoint"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L360-L377 |
44,894 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.getHints | public function getHints($cartReference = null, $checkoutType = 'admin')
{
/** @var Quote */
$quote = $cartReference ?
$this->getQuoteById($cartReference) :
$this->checkoutSession->getQuote();
$hints = ['prefill' => []];
/**
* Update hints from address data
*
* @param Address $address
*/
$prefillHints = function ($address) use (&$hints, $quote) {
if (!$address) {
return;
}
$prefill = [
'firstName' => $address->getFirstname(),
'lastName' => $address->getLastname(),
'email' => $address->getEmail() ?: $quote->getCustomerEmail(),
'phone' => $address->getTelephone(),
'addressLine1' => $address->getStreetLine(1),
'addressLine2' => $address->getStreetLine(2),
'city' => $address->getCity(),
'state' => $address->getRegion(),
'zip' => $address->getPostcode(),
'country' => $address->getCountryId(),
];
foreach ($prefill as $name => $value) {
if (empty($value)) {
unset($prefill[$name]);
}
}
$hints['prefill'] = array_merge($hints['prefill'], $prefill);
};
// Logged in customes.
// Merchant scope and prefill.
if ($this->customerSession->isLoggedIn()) {
$customer = $this->customerSession->getCustomer();
$signRequest = [
'merchant_user_id' => $customer->getId(),
];
$signResponse = $this->getSignResponse($signRequest)->getResponse();
if ($signResponse) {
$hints['merchant_user_id'] = $signResponse->merchant_user_id;
$hints['signature'] = $signResponse->signature;
$hints['nonce'] = $signResponse->nonce;
}
if ($quote->isVirtual()) {
$prefillHints($customer->getDefaultBillingAddress());
} else {
$prefillHints($customer->getDefaultShippingAddress());
}
$hints['prefill']['email'] = $customer->getEmail();
}
// Quote shipping / billing address.
// If assigned it takes precedence over logged in user default address.
if ($quote->isVirtual()) {
$prefillHints($quote->getBillingAddress());
} else {
$prefillHints($quote->getShippingAddress());
}
if ($checkoutType === 'admin') {
$hints['virtual_terminal_mode'] = true;
}
return $hints;
} | php | public function getHints($cartReference = null, $checkoutType = 'admin')
{
/** @var Quote */
$quote = $cartReference ?
$this->getQuoteById($cartReference) :
$this->checkoutSession->getQuote();
$hints = ['prefill' => []];
/**
* Update hints from address data
*
* @param Address $address
*/
$prefillHints = function ($address) use (&$hints, $quote) {
if (!$address) {
return;
}
$prefill = [
'firstName' => $address->getFirstname(),
'lastName' => $address->getLastname(),
'email' => $address->getEmail() ?: $quote->getCustomerEmail(),
'phone' => $address->getTelephone(),
'addressLine1' => $address->getStreetLine(1),
'addressLine2' => $address->getStreetLine(2),
'city' => $address->getCity(),
'state' => $address->getRegion(),
'zip' => $address->getPostcode(),
'country' => $address->getCountryId(),
];
foreach ($prefill as $name => $value) {
if (empty($value)) {
unset($prefill[$name]);
}
}
$hints['prefill'] = array_merge($hints['prefill'], $prefill);
};
// Logged in customes.
// Merchant scope and prefill.
if ($this->customerSession->isLoggedIn()) {
$customer = $this->customerSession->getCustomer();
$signRequest = [
'merchant_user_id' => $customer->getId(),
];
$signResponse = $this->getSignResponse($signRequest)->getResponse();
if ($signResponse) {
$hints['merchant_user_id'] = $signResponse->merchant_user_id;
$hints['signature'] = $signResponse->signature;
$hints['nonce'] = $signResponse->nonce;
}
if ($quote->isVirtual()) {
$prefillHints($customer->getDefaultBillingAddress());
} else {
$prefillHints($customer->getDefaultShippingAddress());
}
$hints['prefill']['email'] = $customer->getEmail();
}
// Quote shipping / billing address.
// If assigned it takes precedence over logged in user default address.
if ($quote->isVirtual()) {
$prefillHints($quote->getBillingAddress());
} else {
$prefillHints($quote->getShippingAddress());
}
if ($checkoutType === 'admin') {
$hints['virtual_terminal_mode'] = true;
}
return $hints;
} | [
"public",
"function",
"getHints",
"(",
"$",
"cartReference",
"=",
"null",
",",
"$",
"checkoutType",
"=",
"'admin'",
")",
"{",
"/** @var Quote */",
"$",
"quote",
"=",
"$",
"cartReference",
"?",
"$",
"this",
"->",
"getQuoteById",
"(",
"$",
"cartReference",
")"... | Get the hints data for checkout
@param string $cartReference (immutable) quote id
@param string $checkoutType 'cart' | 'admin' Default to `admin`
@return array
@throws NoSuchEntityException | [
"Get",
"the",
"hints",
"data",
"for",
"checkout"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L388-L468 |
44,895 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.transferData | private function transferData(
$parent,
$child,
$save = true,
$emailFields = ['customer_email', 'email'],
$excludeFields = ['entity_id', 'address_id', 'reserved_order_id']
) {
foreach ($parent->getData() as $key => $value) {
if (in_array($key, $excludeFields)) continue;
if (in_array($key, $emailFields) && !$this->validateEmail($value)) continue;
$child->setData($key, $value);
}
if ($save) $child->save();
} | php | private function transferData(
$parent,
$child,
$save = true,
$emailFields = ['customer_email', 'email'],
$excludeFields = ['entity_id', 'address_id', 'reserved_order_id']
) {
foreach ($parent->getData() as $key => $value) {
if (in_array($key, $excludeFields)) continue;
if (in_array($key, $emailFields) && !$this->validateEmail($value)) continue;
$child->setData($key, $value);
}
if ($save) $child->save();
} | [
"private",
"function",
"transferData",
"(",
"$",
"parent",
",",
"$",
"child",
",",
"$",
"save",
"=",
"true",
",",
"$",
"emailFields",
"=",
"[",
"'customer_email'",
",",
"'email'",
"]",
",",
"$",
"excludeFields",
"=",
"[",
"'entity_id'",
",",
"'address_id'"... | Set immutable quote and addresses data from the parent quote
@param Quote|QuoteAddress $parent parent object
@param Quote|QuoteAddress $child child object
@param bool $save if set to true save the $child instance upon the transfer
@param array $emailFields fields that need to pass email validation to be transfered, skipped otherwise
@param array $excludeFields fields to be excluded from the transfer (e.g. unique identifiers)
@throws \Zend_Validate_Exception | [
"Set",
"immutable",
"quote",
"and",
"addresses",
"data",
"from",
"the",
"parent",
"quote"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L480-L495 |
44,896 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.replicateQuoteData | public function replicateQuoteData($source, $destination)
{
// Skip the replication if source and destination point to the same quote
// E.g. delayed Save Order - immutable quote is cleared by cron and we use the parent instead
if ($source->getId() == $destination->getId()) return;
$destinationId = $destination->getId();
$destinationActive = (bool)$destination->getIsActive();
$destination->removeAllItems();
$destination->merge($source);
$destination->getBillingAddress()->setShouldIgnoreValidation(true);
$this->transferData($source->getBillingAddress(), $destination->getBillingAddress());
$destination->getShippingAddress()->setShouldIgnoreValidation(true);
$this->transferData($source->getShippingAddress(), $destination->getShippingAddress());
$this->transferData($source, $destination, false);
$destination->setId($destinationId);
$destination->setIsActive($destinationActive);
$this->quoteResourceSave($destination);
// If Amasty Gif Cart Extension is present clone applied gift cards
$this->discountHelper->cloneAmastyGiftCards($source->getId(), $destination->getId());
} | php | public function replicateQuoteData($source, $destination)
{
// Skip the replication if source and destination point to the same quote
// E.g. delayed Save Order - immutable quote is cleared by cron and we use the parent instead
if ($source->getId() == $destination->getId()) return;
$destinationId = $destination->getId();
$destinationActive = (bool)$destination->getIsActive();
$destination->removeAllItems();
$destination->merge($source);
$destination->getBillingAddress()->setShouldIgnoreValidation(true);
$this->transferData($source->getBillingAddress(), $destination->getBillingAddress());
$destination->getShippingAddress()->setShouldIgnoreValidation(true);
$this->transferData($source->getShippingAddress(), $destination->getShippingAddress());
$this->transferData($source, $destination, false);
$destination->setId($destinationId);
$destination->setIsActive($destinationActive);
$this->quoteResourceSave($destination);
// If Amasty Gif Cart Extension is present clone applied gift cards
$this->discountHelper->cloneAmastyGiftCards($source->getId(), $destination->getId());
} | [
"public",
"function",
"replicateQuoteData",
"(",
"$",
"source",
",",
"$",
"destination",
")",
"{",
"// Skip the replication if source and destination point to the same quote",
"// E.g. delayed Save Order - immutable quote is cleared by cron and we use the parent instead",
"if",
"(",
"$... | Clone quote data from source to destination
@param Quote $source
@param Quote $destination
@throws \Magento\Framework\Exception\AlreadyExistsException
@throws \Zend_Validate_Exception | [
"Clone",
"quote",
"data",
"from",
"source",
"to",
"destination"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L505-L533 |
44,897 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.createImmutableQuote | protected function createImmutableQuote($quote)
{
if (!$quote->getBoltParentQuoteId()) {
$quote->setBoltParentQuoteId($quote->getId());
$this->quoteResourceSave($quote);
}
/** @var Quote $immutableQuote */
$immutableQuote = $this->quoteFactory->create();
$this->replicateQuoteData($quote, $immutableQuote);
return $immutableQuote;
} | php | protected function createImmutableQuote($quote)
{
if (!$quote->getBoltParentQuoteId()) {
$quote->setBoltParentQuoteId($quote->getId());
$this->quoteResourceSave($quote);
}
/** @var Quote $immutableQuote */
$immutableQuote = $this->quoteFactory->create();
$this->replicateQuoteData($quote, $immutableQuote);
return $immutableQuote;
} | [
"protected",
"function",
"createImmutableQuote",
"(",
"$",
"quote",
")",
"{",
"if",
"(",
"!",
"$",
"quote",
"->",
"getBoltParentQuoteId",
"(",
")",
")",
"{",
"$",
"quote",
"->",
"setBoltParentQuoteId",
"(",
"$",
"quote",
"->",
"getId",
"(",
")",
")",
";"... | Create an immutable quote.
Set the BoltParentQuoteId to the parent quote, if not set already,
so it can be replicated to immutable quote in replicateQuoteData.
@param Quote $quote
@throws \Magento\Framework\Exception\AlreadyExistsException
@throws \Zend_Validate_Exception | [
"Create",
"an",
"immutable",
"quote",
".",
"Set",
"the",
"BoltParentQuoteId",
"to",
"the",
"parent",
"quote",
"if",
"not",
"set",
"already",
"so",
"it",
"can",
"be",
"replicated",
"to",
"immutable",
"quote",
"in",
"replicateQuoteData",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L571-L583 |
44,898 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.isAddressComplete | private function isAddressComplete($address)
{
foreach ($this->requiredAddressFields as $field) {
if (empty($address[$field])) {
return false;
}
}
return true;
} | php | private function isAddressComplete($address)
{
foreach ($this->requiredAddressFields as $field) {
if (empty($address[$field])) {
return false;
}
}
return true;
} | [
"private",
"function",
"isAddressComplete",
"(",
"$",
"address",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"requiredAddressFields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"address",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return... | Check if all the required address fields are populated.
@param array $address
@return bool | [
"Check",
"if",
"all",
"the",
"required",
"address",
"fields",
"are",
"populated",
"."
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L591-L599 |
44,899 | BoltApp/bolt-magento2 | Helper/Cart.php | Cart.logAddressData | private function logAddressData($addressData) {
$this->bugsnag->registerCallback(function ($report) use ($addressData) {
$report->setMetaData([
'ADDRESS_DATA' => $addressData
]);
});
} | php | private function logAddressData($addressData) {
$this->bugsnag->registerCallback(function ($report) use ($addressData) {
$report->setMetaData([
'ADDRESS_DATA' => $addressData
]);
});
} | [
"private",
"function",
"logAddressData",
"(",
"$",
"addressData",
")",
"{",
"$",
"this",
"->",
"bugsnag",
"->",
"registerCallback",
"(",
"function",
"(",
"$",
"report",
")",
"use",
"(",
"$",
"addressData",
")",
"{",
"$",
"report",
"->",
"setMetaData",
"(",... | Bugsnag address data
@param array $addressData | [
"Bugsnag",
"address",
"data"
] | 1d91576a88ec3ea4748e5ccc755a580eecf5aff7 | https://github.com/BoltApp/bolt-magento2/blob/1d91576a88ec3ea4748e5ccc755a580eecf5aff7/Helper/Cart.php#L606-L612 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.