-
-
Save bdunogier/b47784a14a9cc946a0c6 to your computer and use it in GitHub Desktop.
Scripts to publish multiple versions in parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
list(, , $contentId, $versionNumber ) = $argv; | |
$behaviour = new ezpContentPublishingBehaviour(); | |
$behaviour->isTemporary = false; | |
$behaviour->disableAsynchronousPublishing = !(bool)getenv( 'EZ_USE_AP' ); | |
print_r( $behaviour ); | |
ezpContentPublishingBehaviour::setBehaviour( $behaviour ); | |
eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentId, 'version' => $versionNumber ) ); | |
echo "Done publishing {$contentId}v{$versionNumber}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | |
* @license For full copyright and license information view LICENSE file distributd with this source code. | |
*/ | |
/** @var eZContentObjectVersion[] $versions */ | |
$versions = array(); | |
echo "# asynchronous-publishing: " . ( getenv( 'EZ_USE_AP' ) ? 'ON' : 'OFF' ) . "\n\n"; | |
echo "Creating content object version 1 in eng-GB... "; | |
$content = createContent(); | |
echo " #" . $content->attribute( 'id' ) . "\n"; | |
echo "Publishing... "; | |
eZOperationHandler::execute( | |
'content', 'publish', array( 'object_id' => $content->attribute( 'id' ), 'version' => 1 ) | |
); | |
echo "done\n"; | |
foreach ( array( 'dut-NL', 'fin-FI', 'fre-FR', 'ger-DE' ) as $locale ) | |
{ | |
echo "Adding version in $locale... "; | |
$versions[] = updateContent( $content, $locale ); | |
echo " v" . $versions[count($versions)-1]->attribute('version'). "\n"; | |
} | |
$pidArray = array(); | |
foreach ( $versions as $version ) | |
{ | |
$contentId = $content->attribute( 'id' ); | |
$versionNumber = $version->attribute( 'version' ); | |
/*eZOperationHandler::execute( | |
'content', 'publish', array( 'object_id' => $contentId, 'version' => $versionNumber ) | |
);*/ | |
/*if ( pcntl_fork() > 0) | |
{ | |
continue; | |
}*/ | |
// echo `php bin/php/ezexec.php publishversion.php $contentId $versionNumber`; | |
echo "Sending v$versionNumber for publishing\n"; | |
passthru( "php bin/php/ezexec.php publishversion.php $contentId $versionNumber >> var/log/publishing/$contentId.$versionNumber.log 2>&1 &" ); | |
// eZExecution::cleanExit(); | |
// exit; | |
} | |
$status = 0; | |
pcntl_waitpid( -1, $status ); | |
/** | |
* @return eZContentObject | |
*/ | |
function createContent() | |
{ | |
$class = eZContentClass::fetchByIdentifier( 'folder' ); | |
$content = $class->instantiate( 14, 1, false, 'eng-GB' ); | |
$dataMap = $content->attribute( 'data_map' ); | |
$dataMap['name']->fromString( __METHOD__ ); | |
$nodeAssignment = eZNodeAssignment::create( | |
array( | |
'contentobject_id' => $content->attribute( 'id' ), | |
'contentobject_version' => 1, | |
'parent_node' => 2, | |
'is_main' => 1 | |
) | |
); | |
$nodeAssignment->store(); | |
return $content; | |
} | |
/** | |
* @param eZContentObject $content | |
* @return eZContentObjectVersion | |
*/ | |
function updateContent( $content, $locale ) | |
{ | |
$version = $content->createNewVersionIn( $locale ); | |
$version->setAttribute( 'modified', time() ); | |
$version->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT ); | |
$version->store(); | |
/** @var eZContentObjectAttribute[] $dataMap */ | |
$dataMap = $version->dataMap(); | |
$dataMap['name']->fromString( __METHOD__ . " [$locale]" ); | |
return $version; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment