コード例 #1
0
ファイル: testcase.php プロジェクト: abbra/midcom
 protected function setUp()
 {
     if (MIDCOM_TESTS_ENABLE_OUTPUT) {
         echo "\nsetUp\n\n";
     }
     if (!extension_loaded('midgard') && !extension_loaded('midgard2')) {
         $this->markTestSkipped('Midgard extension is not available');
     }
     if (!isset($_MIDGARD)) {
         // Start up a Midgard connection
         $cnc = new midgard_connection();
         $cnc->open(MIDGARD_CONFIG);
         $cnc->set_debuglevel(MIDCOM_TESTS_LOGLEVEL);
         if (is_int(MIDCOM_TESTS_SITEGROUP)) {
             $sg = mgd_get_sitegroup(MIDCOM_TESTS_SITEGROUP);
             $cnc->set_sitegroup($sg->name);
         } else {
             $cnc->set_sitegroup(MIDCOM_TESTS_SITEGROUP);
         }
     }
     if (!isset($_MIDCOM)) {
         // Load MidCOM with the manual dispatcher
         $_MIDCOM = new midcom_core_midcom('manual');
     }
 }
コード例 #2
0
ファイル: dispatch_routes.php プロジェクト: abbra/midcom
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
 */
/**
 * Test that loads all components and dispatches each of their routes
 */
// Argument checks
if (count($argv) != 2) {
    die("Usage: php find_orphans.php midgardconffile\n");
}
$conffile = $argv[1];
if (!extension_loaded('midgard') && !extension_loaded('midgard2')) {
    die("Midgard extension is not available\n");
}
// Start up a Midgard connection
$midgard = new midgard_connection();
$midgard->open($conffile);
// Load MidCOM with the manual dispatcher
require 'midcom_core/framework.php';
$_MIDCOM = new midcom_core_midcom('manual');
echo "Loading all components and their routes\n\n";
// Go through the installed components
foreach ($_MIDCOM->componentloader->manifests as $component_name => $manifest) {
    // Enter new context
    $_MIDCOM->context->create();
    try {
        $_MIDCOM->dispatcher->initialize($component_name);
    } catch (Exception $e) {
        echo "Skipping {$component_name}: component failed to load\n\n";
        $_MIDCOM->context->delete();
        continue;
    }
コード例 #3
0
<?php

$midgard = new midgard_connection();
$midgard->open('midgard');
@ini_set('max_execution_time', 0);
// Figure out when sequence was updated last time
$qb = new midgard_query_builder('midgard_sequence');
$qb->set_limit(1);
$qb->add_order('id', 'DESC');
$transactions = $qb->execute();
if (count($transactions) == 0) {
    $latest_sequence = new midgard_datetime('0000-00-00');
} else {
    foreach ($transactions as $transaction) {
        $latest_sequence = $transaction->metadata->created;
    }
}
$sequence = array();
foreach ($_MIDGARD['schema']['types'] as $type => $val) {
    if (substr($type, 0, 2) == '__') {
        continue;
    }
    // Updated objects
    $qb = new midgard_query_builder($type);
    $qb->add_constraint('metadata_revised', '>', $latest_sequence);
    $qb->add_order('metadata_revised', 'ASC');
    $objects = $qb->execute();
    foreach ($objects as $object) {
        $revised = $object->metadata->revised->format(DATE_ATOM);
        $sequence["{$revised}_{$object->guid}"] = array('objectguid' => $object->guid, 'type' => $type, 'revision' => $object->metadata->revision);
    }
コード例 #4
0
ファイル: sync.php プロジェクト: bergie/net_nemein_avaudu
<?php

/**
 * @package net_nemein_avaudu
 * @author The Midgard Project, http://www.midgard-project.org
 * @copyright The Midgard Project, http://www.midgard-project.org
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
 */
// Open connection
$midgard = new midgard_connection();
if (!$midgard->open('midgard')) {
    die('Could not connect to Midgard database');
}
// Instantiate synchronizer
$sync = new net_nemein_avaudu_sync();
// Run synchronization in a loop that is initialized by App Builder instance launch
while (true) {
    $sync->fetch_qaiku();
    sleep(60);
}
コード例 #5
0
<?php

$config_name = 'midgard';
$midgard = new midgard_connection();
if (!$midgard->open($config_name)) {
    throw new Exception("Can not connect to database with given configuration " . $config_name);
}
$midgard->set_sitegroup('sg0');
$_MIDGARD['host'] = 0;