예제 #1
0
파일: bootstrap.php 프로젝트: Joal01/fof
    }
    @date_default_timezone_set($serverTimezone);
}
//Am I in Travis CI?
if (getenv('TRAVIS')) {
    require_once __DIR__ . '/config_travis.php';
    $siteroot = $fofTestConfig[getenv('JVERSION_TEST')];
} else {
    require_once __DIR__ . '/config.php';
    $siteroot = $fofTestConfig['site_root'];
}
// Set up the Joomla! environment
if (file_exists($siteroot . '/defines.php')) {
    include_once $siteroot . '/defines.php';
}
if (!defined('_JDEFINES')) {
    define('JPATH_BASE', $siteroot);
    require_once JPATH_BASE . '/includes/defines.php';
}
if (!defined('JPATH_TESTS')) {
    define('JPATH_TESTS', __DIR__);
}
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
// This is required to force Joomla! to read the correct configuration.php file...
$config = JFactory::getConfig(JPATH_SITE . '/configuration.php');
// Let's use our class to create the schema
$importer = new \FOF30\Database\Installer(JFactory::getDbo(), JPATH_TESTS . '/Stubs/schema');
$importer->updateSchema();
unset($importer);
예제 #2
0
파일: script.fof.php 프로젝트: akeeba/fof
 /**
  * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing
  * or updating your component. This is the last chance you've got to perform any additional installations, clean-up,
  * database updates and similar housekeeping functions.
  *
  * @param   string                $type   install, update or discover_update
  * @param   JInstallerAdapterLibrary $parent Parent object
  */
 public function postflight($type, JInstallerAdapterLibrary $parent)
 {
     $this->loadFOF30();
     if (!defined('FOF30_INCLUDED')) {
         return;
     }
     // Install or update database
     $db = JFactory::getDbo();
     /** @var JInstaller $grandpa */
     $grandpa = $parent->getParent();
     $src = $grandpa->getPath('source');
     $sqlSource = $src . '/fof/sql';
     // If we have an uppercase db prefix we can expect the database update to fail because we cannot detect reliably
     // the existence of database tables. See https://github.com/joomla/joomla-cms/issues/10928#issuecomment-228549658
     $prefix = $db->getPrefix();
     $canFail = preg_match('/[A-Z]/', $prefix);
     try {
         $dbInstaller = new FOF30\Database\Installer($db, $sqlSource);
         $dbInstaller->updateSchema();
     } catch (\Exception $e) {
         if (!$canFail) {
             throw $e;
         }
     }
     // Since we're adding common table, I have to nuke the installer cache, otherwise checks on their existence would fail
     $dbInstaller->nukeCache();
     // Clear the FOF cache
     $fakeController = \FOF30\Container\Container::getInstance('com_FOOBAR');
     $fakeController->platform->clearCache();
 }
예제 #3
0
파일: script.fof.php 프로젝트: Joal01/fof
 /**
  * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing
  * or updating your component. This is the last chance you've got to perform any additional installations, clean-up,
  * database updates and similar housekeeping functions.
  *
  * @param   string                $type   install, update or discover_update
  * @param   JInstallerAdapterLibrary $parent Parent object
  */
 public function postflight($type, JInstallerAdapterLibrary $parent)
 {
     $this->loadFOF30();
     if (!defined('FOF30_INCLUDED')) {
         return;
     }
     // Install or update database
     $db = JFactory::getDbo();
     /** @var JInstaller $grandpa */
     $grandpa = $parent->getParent();
     $src = $grandpa->getPath('source');
     $sqlSource = $src . '/fof/sql';
     $dbInstaller = new FOF30\Database\Installer($db, $sqlSource);
     $dbInstaller->updateSchema();
     // Clear the FOF cache
     $fakeController = \FOF30\Container\Container::getInstance('com_FOOBAR');
     $fakeController->platform->clearCache();
 }