本文整理汇总了PHP中eZScript::shutdown方法的典型用法代码示例。如果您正苦于以下问题:PHP eZScript::shutdown方法的具体用法?PHP eZScript::shutdown怎么用?PHP eZScript::shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZScript
的用法示例。
在下文中一共展示了eZScript::shutdown方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runCallback
/**
* Runs a callback function in the legacy kernel environment.
* This is useful to run eZ Publish 4.x code from a non-related context (like eZ Publish 5)
*
* @param \Closure $callback
* @param boolean $postReinitialize Default is true.
* If set to false, the kernel environment will not be reinitialized.
* This can be useful to optimize several calls to the kernel within the same context.
* @return mixed The result of the callback
*/
public function runCallback(\Closure $callback, $postReinitialize = true)
{
if (!$this->script->isInitialized()) {
$this->script->initialize();
}
$return = $callback();
$this->script->shutdown();
if (!$postReinitialize) {
$this->script->setIsInitialized(true);
}
return $return;
}
示例2: __destruct
public function __destruct()
{
if (self::$script instanceof eZScript) {
self::$script->shutdown(0);
}
}
示例3: internalClear
private function internalClear($purge, $cacheEntries, $name, $purgeSleep = null, $purgeMax = null, $purgeExpiry = null)
{
$this->cli->output(($purge ? 'Purging ' : 'Clearing ') . $this->cli->stylize('emphasize', $name ? $name : 'All cache') . ': ');
$warnPaths = array();
foreach ($cacheEntries as $cacheEntry) {
$absPath = realpath(eZSys::cacheDirectory() . DIRECTORY_SEPARATOR . $cacheEntry['path']);
$absPathElementCount = count(explode(DIRECTORY_SEPARATOR, rtrim($absPath, DIRECTORY_SEPARATOR)));
// Refuse to delete root directory ('/' or 'C:\')
// 2 => since one path element ('/foo') produces two exploded elements
if ($absPath && $absPathElementCount < 2) {
$this->cli->error('Refusing to delete root directory! Please check your cache settings. Path: ' . $absPath);
$this->script->shutdown(1);
exit;
}
// Warn if the cache entry is not function based, and the path is outside ezp root, and the path has less than 2 elements
if ($absPath && (!$purge || !isset($cacheEntry['purge-function'])) && !isset($cacheEntry['function']) && $absPathElementCount < 3 && strpos(dirname($absPath) . DIRECTORY_SEPARATOR, realpath(eZSys::rootDir()) . DIRECTORY_SEPARATOR) === false) {
$warnPaths[] = $absPath;
}
}
if (!empty($warnPaths)) {
$this->cli->warning('The following cache paths are outside of the eZ Publish root directory, and have less than 2 path elements. ' . 'Are you sure you want to ' . ($purge ? 'purge' : 'clear') . ' them?');
foreach ($warnPaths as $warnPath) {
$this->cli->output($warnPath);
}
if (function_exists("getUserInput")) {
$input = getUserInput(($purge ? 'Purge' : 'Clear') . '? yes/no:', array('yes', 'no'));
} else {
$validInput = false;
$readlineExists = function_exists("readline");
while (!$validInput) {
if ($readlineExists) {
$input = readline($query);
} else {
echo $prompt . ' ';
$input = trim(fgets(STDIN));
}
if ($acceptValues === false || in_array($input, $acceptValues)) {
$validInput = true;
}
}
}
if ($input === 'no') {
$this->script->shutdown();
exit;
}
}
$firstItem = true;
foreach ($cacheEntries as $cacheEntry) {
if ($firstItem) {
$firstItem = false;
} else {
$this->cli->output(', ', false);
}
$this->cli->output($this->cli->stylize('emphasize', $cacheEntry['name']), false);
if ($purge) {
eZCache::clearItem($cacheEntry, true, array($this, 'reportProgress'), $purgeSleep, $purgeMax, $purgeExpiry);
} else {
eZCache::clearItem($cacheEntry);
}
}
$this->cli->output();
}
示例4: uploadXMLtoFTP
/**
* @param string $xmlFileName
* @param string $type
*/
protected function uploadXMLtoFTP( $xmlFileName, $type )
{
if( !extension_loaded( 'ftp' ) )
{
$this->cli->output( 'PHP FTP extension is not loaded' );
}
else
{
$localFile = $this->articlesLocalPath . '/' . $xmlFileName . '_' . $this->articlesLocale . '.xml';
$localTmpFile = $this->articlesLocalPath . '/' . $xmlFileName . '_' . time() . '_' . $this->articlesLocale . '.xml';
if( !file_exists( $localFile ) )
{
$this->script->shutdown( 0, "$localFile doesn't exist" );
return;
}
try
{
$resource = ftp_connect( $this->host[$this->env], $this->port );
}
catch( \Exception $e )
{
$this->script->shutdown( 0, 'Failed to connect on FTP server' );
return;
}
if( !ftp_login( $resource, $this->username, $this->password ) )
{
$this->script->shutdown( 0, 'Failed to authenticate on FTP server' );
return;
}
else
{
if( !is_resource( $resource ) )
{
$this->script->shutdown( 0, 'Not connected to FTP server' );
return;
}
else
{
try
{
ftp_pasv($resource, true);
$dom = new DOMDocument();
$dom->load( $localFile );
$xpath = new DomXpath( $dom );
$dateCreation = $xpath->query( '//field[@name="date_creation"]' );
$dateCreation->item( 0 )->nodeValue = '';
$dateCreation->item( 0 )->appendChild($dom->createTextNode( date('Y-m-d H:i', time() - 7200 ) ) );
$datePublish = $xpath->query( '//field[@name="date_publish"]' );
$datePublish->item( 0 )->nodeValue = '';
$datePublish->item( 0 )->appendChild($dom->createTextNode( date('Y-m-d H:i', time() - 7200) ) );
$title = $xpath->query( '//field[@name="title"]' );
$title->item( 0 )->nodeValue = '';
$title->item( 0 )->appendChild( $dom->createCDATASection( 'Article_' . time() . " $type article" ) );
file_put_contents( $localTmpFile, $dom->saveXML() );
$stream = fopen( $localTmpFile, 'r' );
if( !ftp_fput( $resource, $this->articleRemotePath[$type] . '/' . $xmlFileName . '_' . time() . '_' . $this->articlesLocale . '.xml', $stream, FTP_ASCII ) )
{
unlink( $localTmpFile );
$this->script->shutdown( 0, 'Failed to put a file on FTP server' );
}
unlink( $localTmpFile );
fclose( $stream );
$importMonitor = new NewRelicImportMonitoring();
$importMonitor->setAttribute( 'article_title', 'Article_' . time() . " $type article" );
$importMonitor->setAttribute( 'date_insert', time() );
$importMonitor->setAttribute( 'new_relic_report', 0 );
$importMonitor->store();
}
catch( \Exception $e )
{
$this->script->shutdown( 0, 'An error occured while uploading the XML to the FTP' );
return;
}
}
}
ftp_pasv( $resource, true );
ftp_close( $resource );
}
}
示例5: fetchTopNode
/**
* Fetches and returns a eZContentObjectTreeNode
*
* If the node id does not exists an error message is outputted and the script
* is halted.
*
* @param int $topNodeId
* @param eZCLI $cli
* @param eZScript $script
* @return eZContentObjectTreeNode
**/
function fetchTopNode( $topNodeId, $cli, $script )
{
$topNode = eZContentObjectTreeNode::fetch( $topNodeId );
if ( !$topNode )
{
$cli->error( "The specified top-node-id ({$topNodeId}) was not valid\n" );
$script->shutdown( 1 );
}
else
{
$cli->output( "Will export from node `{$topNode->Name}` ({$topNodeId})\n" );
}
return $topNode;
}