setCompleted() публичный Метод

Mark this upgrade as completed
public setCompleted ( ) : boolean
Результат boolean
Пример #1
0
 /**
  * Register an upgrade class to move the blog icons
  *
  * @param string $event  the name of the event
  * @param string $type   the type of the event
  * @param mixed  $object supplied object/params
  *
  * @return void
  */
 public static function moveBlogIcons($event, $type, $object)
 {
     $ia = elgg_set_ignore_access(true);
     $path = 'admin/upgrades/blog_tools_move_icons';
     $upgrade = new \ElggUpgrade();
     if (!$upgrade->getUpgradeFromPath($path)) {
         $upgrade->setPath($path);
         $upgrade->title = elgg_echo('admin:upgrades:blog_tools_move_icons');
         $upgrade->description = elgg_echo('admin:upgrades:blog_tools_move_icons:description');
         $upgrade->save();
         // check for blog with icons
         // eg. if non found, no upgrade needed
         $count = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => 'blog', 'metadata_name' => 'icontime', 'count' => true]);
         if (empty($count)) {
             $upgrade->setCompleted();
         }
     }
     // restore access
     elgg_set_ignore_access($ia);
 }
Пример #2
0
<?php

run_function_once('scraper_upgrade_20161410b');
function scraper_upgrade_20161410b()
{
    // Setup MySQL databases
    run_sql_script(dirname(dirname(__FILE__)) . '/install/mysql.sql');
}
// Register upgrade scripts
$path = 'admin/upgrades/scraper/move_to_db';
$upgrade = new \ElggUpgrade();
if (!$upgrade->getUpgradeFromPath($path)) {
    $upgrade->setPath($path);
    $upgrade->title = elgg_echo('admin:upgrades:scraper:move_to_db');
    $upgrade->description = elgg_echo('admin:upgrades:scraper:move_to_db:description');
    $upgrade->save();
    $site = elgg_get_site_entity();
    $dataroot = elgg_get_config('dataroot');
    $dir = new \Elgg\EntityDirLocator($site->guid);
    $paths = elgg_get_file_list($dataroot . $dir . 'scraper_cache/resources/');
    $count = count($paths);
    if (!$count) {
        $upgrade->setCompleted();
    }
}