本文整理汇总了PHP中eZSearch::getEngine方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSearch::getEngine方法的具体用法?PHP eZSearch::getEngine怎么用?PHP eZSearch::getEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSearch
的用法示例。
在下文中一共展示了eZSearch::getEngine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public static function build(\Closure $legacyKernelClosure)
{
try {
$searchEngine = $legacyKernelClosure()->runCallback(function () {
return \eZSearch::getEngine();
});
} catch (\Exception $e) {
$searchEngine = new NullSearchEngine();
}
return $searchEngine;
}
示例2: swapNode
/**
* Notifies search engine about an swap node operation
*
* @since 4.1
* @param int $nodeID
* @param int $selectedNodeID
* @param array $nodeIdList
* @return false|mixed False in case method is undefined, otherwise return the result of the search engine call
*/
public static function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'swapNode' ) )
{
return $searchEngine->swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() );
}
return false;
}
示例3: updateAlwaysAvailable
/**
* Set the always available flag for a content object
*
* @param int $objectID
* @param int $newAlwaysAvailable
* @return array An array with operation status, always true
*/
public static function updateAlwaysAvailable($objectID, $newAlwaysAvailable)
{
$object = eZContentObject::fetch($objectID);
$change = false;
if ($object->isAlwaysAvailable() & $newAlwaysAvailable == false) {
$object->setAlwaysAvailableLanguageID(false);
$change = true;
} else {
if (!$object->isAlwaysAvailable() & $newAlwaysAvailable == true) {
$object->setAlwaysAvailableLanguageID($object->attribute('initial_language_id'));
$change = true;
}
}
if ($change) {
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
if (!eZSearch::getEngine() instanceof eZSearchEngine) {
eZContentOperationCollection::registerSearchObject($objectID);
}
}
return array('status' => true);
}
示例4: alignArticle
/**
* Aligns articles published under given publisher folder
* @param eZContentObject $publisherObject
*/
function alignArticle( $publisherObject, $checkModified = false, $checkLocations = false, $checkLanguages = false, $checkHidden = false, $timingDelay = 0, $forceLast = 0, $sleepTime = 1 )
{
echo "Starting treatment of publisher folder : " . $publisherObject->name() . "\n";
echo "Fetching solr informations\n";
$eZSolr = eZSearch::getEngine();
$offset = 0;
$forced = 0;
$limit = 200;
$publisherNode = $publisherObject->mainNode();
$doCheck = $checkModified || $checkLocations || $checkLanguages || $checkHidden;
$solrInfos = fetchSolrPublisherFolder ( $publisherNode, $checkModified, $checkLocations, $checkLanguages, $checkHidden, $sleepTime );
echo "Solr count : " . count($solrInfos) . "\n";
while ( true )
{
$params = array(
'Offset' => $offset,
'Limit' => $limit,
'ClassFilterType' => 'include',
'ClassFilterArray' => array( 'article' ),
'LoadDataMap' => false,
'AsObject' => false,
'MainNodeOnly' => true,
);
if ($forceLast > 0)
$params['SortBy'] = array ( array('published', false ) );
$nodeList = $publisherNode->subtree( $params );
echo "\neZ Offset : $offset\n";
if ( count( $nodeList ) == 0 )
{
break;
}
foreach ( $nodeList as $mainNode )
{
$nodeId = $mainNode['node_id'];
$objectId = $mainNode['contentobject_id'];
$toUpdate = false;
if ( $forceLast > 0 && $forced < $forceLast )
$toUpdate = true;
elseif ( isset($solrInfos[$nodeId]) )
{
if ( $doCheck )
{
if ( $checkLanguages )
{
$eZLanguages = eZContentObject::fetch($objectId)->languages();
$toUpdate = compareLanguages( array_keys($eZLanguages), $solrInfos[$nodeId]['languages'] );
showInvalidTranslations(array_keys($eZLanguages), $solrInfos[$nodeId]['languages'], $objectId);
}
if (!$toUpdate && $checkModified)
$toUpdate = compareDates($mainNode['modified'], $solrInfos[$nodeId]['modified'], $timingDelay);
if (!$toUpdate && $checkLocations)
$toUpdate = compareLocations($objectId, $solrInfos[$nodeId]['locations']);
if (!$toUpdate && $checkHidden)
$toUpdate = compareHidden($objectId, $solrInfos[$nodeId]['hiddenCount'], $solrInfos[$nodeId]['notHiddenCount']);
}
unset($solrInfos[$nodeId]);
}
else
$toUpdate = true;
if ( $toUpdate )
{
$return = $eZSolr->addObject( eZContentObject::fetch($objectId), false );
echo ( !$return ? '!' . $objectId . '!' : '+' );
}
else
echo '-';
$forced++;
}
$offset += $limit;
eZContentObject::clearCache();
if ( $sleepTime > 0 )
sleep ($sleepTime);
}
echo "\nArticles in solr but unknown from eZPublish : " . count($solrInfos) . " articles\n";
}
示例5:
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version 2014.07.0
*/
if (!$isQuiet) {
$cli->output("Starting solr index optimization");
}
// check that solr is enabled and used
$eZSolr = eZSearch::getEngine();
if (!$eZSolr instanceof eZSolr) {
$script->shutdown(1, 'The current search engine plugin is not eZSolr');
}
$eZSolr->optimize(false);
if (!$isQuiet) {
$cli->output("Done");
}
示例6: removeNodes
/**
* Removes nodes
*
* This function does not check about permissions, this is the responsibility of the caller!
*
* @param array $removeNodeIdList Array of Node ID to remove
*
* @return array An array with operation status, always true
*/
public static function removeNodes(array $removeNodeIdList)
{
$mainNodeChanged = array();
$nodeAssignmentIdList = array();
$objectIdList = array();
$db = eZDB::instance();
$db->begin();
foreach ($removeNodeIdList as $nodeId) {
$node = eZContentObjectTreeNode::fetch($nodeId);
$objectId = $node->attribute('contentobject_id');
foreach (eZNodeAssignment::fetchForObject($objectId, eZContentObject::fetch($objectId)->attribute('current_version'), 0, false) as $nodeAssignmentKey => $nodeAssignment) {
if ($nodeAssignment['parent_node'] == $node->attribute('parent_node_id')) {
$nodeAssignmentIdList[$nodeAssignment['id']] = 1;
}
}
if ($nodeId == $node->attribute('main_node_id')) {
$mainNodeChanged[$objectId] = 1;
}
$node->removeThis();
if (!isset($objectIdList[$objectId])) {
$objectIdList[$objectId] = eZContentObject::fetch($objectId);
}
}
// Give other search engines that the default one a chance to reindex
// when removing locations.
if (!eZSearch::getEngine() instanceof eZSearchEngine) {
foreach ($objectIdList as $objectId => $object) {
eZContentOperationCollection::registerSearchObject($objectId, $object->attribute('current_version'));
}
}
eZNodeAssignment::purgeByID(array_keys($nodeAssignmentIdList));
foreach (array_keys($mainNodeChanged) as $objectId) {
$allNodes = $objectIdList[$objectId]->assignedNodes();
// Registering node that will be promoted as 'main'
$mainNodeChanged[$objectId] = $allNodes[0];
eZContentObjectTreeNode::updateMainNodeID($allNodes[0]->attribute('node_id'), $objectId, false, $allNodes[0]->attribute('parent_node_id'));
}
$db->commit();
//call appropriate method from search engine
eZSearch::removeNodes($removeNodeIdList);
$userClassIdList = eZUser::contentClassIDs();
foreach ($objectIdList as $objectId => $object) {
eZContentCacheManager::clearObjectViewCacheIfNeeded($objectId);
// clear user policy cache if this was a user object
if (in_array($object->attribute('contentclass_id'), $userClassIdList)) {
eZUser::purgeUserCacheByUserId($object->attribute('id'));
}
}
// we don't clear template block cache here since it's cleared in eZContentObjectTreeNode::removeNode()
return array('status' => true);
}