eZContentOperationCollection::sendToPublishingQueue PHP Method

sendToPublishingQueue() public static method

Sends the published object/version for publishing to the queue Used by the content/publish operation
Since: 4.5
public static sendToPublishingQueue ( integer $objectId, integer $version ) : array(
$objectId integer
$version integer
return array(
    public static function sendToPublishingQueue($objectId, $version)
    {
        $behaviour = ezpContentPublishingBehaviour::getBehaviour();
        if ($behaviour->disableAsynchronousPublishing) {
            $asyncEnabled = false;
        } else {
            $asyncEnabled = eZINI::instance('content.ini')->variable('PublishingSettings', 'AsynchronousPublishing') == 'enabled';
        }
        $accepted = true;
        if ($asyncEnabled === true) {
            // Filter handlers
            $ini = eZINI::instance('content.ini');
            $filterHandlerClasses = $ini->variable('PublishingSettings', 'AsynchronousPublishingFilters');
            if (count($filterHandlerClasses)) {
                $versionObject = eZContentObjectVersion::fetchVersion($version, $objectId);
                foreach ($filterHandlerClasses as $filterHandlerClass) {
                    if (!class_exists($filterHandlerClass)) {
                        eZDebug::writeError("Unknown asynchronous publishing filter handler class '{$filterHandlerClass}'", __METHOD__);
                        continue;
                    }
                    $handler = new $filterHandlerClass($versionObject);
                    if (!$handler instanceof ezpAsynchronousPublishingFilterInterface) {
                        eZDebug::writeError("Asynchronous publishing filter handler class '{$filterHandlerClass}' does not implement ezpAsynchronousPublishingFilterInterface", __METHOD__);
                        continue;
                    }
                    $accepted = $handler->accept();
                    if (!$accepted) {
                        eZDebugSetting::writeDebug("Object #{$objectId}/{$version} was excluded from asynchronous publishing by {$filterHandlerClass}", __METHOD__);
                        break;
                    }
                }
            }
            unset($filterHandlerClasses, $handler);
        }
        if ($asyncEnabled && $accepted) {
            // if the object is already in the process queue, we move ahead
            // this test should NOT be necessary since http://issues.ez.no/17840 was fixed
            if (ezpContentPublishingQueue::isQueued($objectId, $version)) {
                return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
            } else {
                ezpContentPublishingQueue::add($objectId, $version);
                return array('status' => eZModuleOperationInfo::STATUS_HALTED, 'redirect_url' => "content/queued/{$objectId}/{$version}");
            }
        } else {
            return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
        }
    }