本文整理汇总了PHP中JInstaller::setAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstaller::setAdapter方法的具体用法?PHP JInstaller::setAdapter怎么用?PHP JInstaller::setAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInstaller
的用法示例。
在下文中一共展示了JInstaller::setAdapter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAbortDefault
/**
* @todo Implement testAbort().
*/
public function testAbortDefault()
{
$this->saveFactoryState();
$newDbo = $this->getMock('test');
JFactory::$database = &$newDbo;
$adapterMock = $this->getMock('test', array('_rollback_testtype'));
$adapterMock->expects($this->once())
->method('_rollback_testtype')
->with($this->equalTo(array('type' => 'testtype')))
->will($this->returnValue(true));
//$this->object = JInstaller::getInstance();
$this->object = new JInstaller;
$this->object->setAdapter('testadapter', $adapterMock);
$this->object->pushStep(array('type' => 'testtype'));
$this->assertThat(
$this->object->abort(null, 'testadapter'),
$this->isTrue()
);
$this->restoreFactoryState();
}
示例2: setAdapter
/**
* Set an installer adapter by name
*
* @access public
* @param string $name Adapter name
* @param object $adapter Installer adapter object
* @return boolean True if successful
* @since 1.5
*/
public function setAdapter($name, &$adapter = null, $options = array())
{
if (!is_object($adapter)) {
// Try to load the adapter object
$fullpath = dirname(__FILE__) . DS . 'adapters' . DS . strtolower($name) . '.php';
if (!file_exists($fullpath)) {
return false;
}
// Try to load the adapter object
require_once $fullpath;
$class = "RokInstaller" . ucfirst($name);
if (!class_exists($class)) {
return false;
}
$adapter = new $class($this, $this->_db, $options);
}
if (!is_object($adapter)) {
$ret = parent::setAdapter($name, $adapter);
if (!$ret) {
return $ret;
}
}
$this->_adapters[$name] =& $adapter;
return true;
}
示例3: testAbortDefault
/**
* Test...
*
* @covers JInstaller::abort
*
* @return void
*/
public function testAbortDefault()
{
$adapterMock = $this->getMock('test', array('_rollback_testtype'));
$adapterMock->expects($this->once())->method('_rollback_testtype')->with($this->equalTo(array('type' => 'testtype')))->will($this->returnValue(true));
$this->object->setAdapter('testadapter', $adapterMock);
$this->object->pushStep(array('type' => 'testtype'));
$this->assertThat($this->object->abort(null, 'testadapter'), $this->isTrue());
}
示例4: install
public function install()
{
foreach ($this->manifests as $i => $manifest) {
$installer = new JInstaller();
$installer->setPath('source', $this->parent->getPath('source'));
//This is essentially what method="upgrade" does
$installer->_overwrite = true;
$xml =& JFactory::getXMLParser('Simple');
$xml->loadFile($manifest);
$installer->_manifest = $xml;
$installer->setPath('manifest', $manifest);
$root = $xml->document;
$type = $root->attributes('type');
//Don't install if the type isn't defined
if (!$type) {
unset($this->manifests[$i]);
continue;
}
// Lazy load the adapter
if (!isset($installer->_adapters[$type]) || !is_object($installer->_adapters[$type])) {
$installer->setAdapter($type);
}
$installer->_adapters[$type]->install();
$installer->install($this->parent->getPath('source'));
}
if (JFolder::exists($this->parent->getPath('source') . '/nooku')) {
$this->manifests[] = $manifest = $this->parent->getPath('source') . '/nooku/manifest.xml';
$installer = new JInstaller();
$installer->setPath('source', $this->parent->getPath('source') . '/nooku');
//This is essentially what method="upgrade" does
$installer->_overwrite = true;
$xml =& JFactory::getXMLParser('Simple');
$xml->loadFile($manifest);
$installer->_manifest = $xml;
$installer->setPath('manifest', $manifest);
$root = $xml->document;
$type = $root->attributes('type');
// Lazy load the adapter
if (!isset($installer->_adapters[$type]) || !is_object($installer->_adapters[$type])) {
$installer->setAdapter($type);
}
$installer->_adapters[$type]->install();
$installer->install($this->parent->getPath('source'));
}
return $this;
}
示例5: setAdapter
/**
* Set an installer adapter by name
*
* @access public
* @param string $name Adapter name
* @param object $adapter Installer adapter object
* @return boolean True if successful
* @since 1.5
*/
function setAdapter($name, $adapter = null)
{
$ret = parent::setAdapter($name, $adapter);
if (!$ret) {
return $ret;
}
if (!is_object($adapter)) {
// Try to load the adapter object
$adapter_file = dirname(__FILE__) . DS . 'adapters' . DS . strtolower($name) . '.php';
if (JFile::exists($adapter_file)) {
@(include_once $adapter_file);
$class = 'RokInstaller' . ucfirst($name);
if (!class_exists($class)) {
return false;
}
$adapter = new $class($this);
$adapter->parent =& $this;
$this->_adapters[strtolower($name)] =& $adapter;
}
}
return true;
}
示例6: postflight
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
public function postflight($type, $parent)
{
/* Install redform plugin */
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$db =& JFactory::getDBO();
JFolder::copy(JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_redevent' . DS . 'extras' . DS . 'redform', JPATH_SITE . DS . 'tmp' . DS . 'redform_redevent', '', true);
$installer = new JInstaller();
$installer->setAdapter('plugin');
if (!$installer->install(JPATH_SITE . DS . 'tmp' . DS . 'redform_redevent')) {
echo JText::_('COM_REDEVENT_Plugin_install_failed') . $installer->getError() . '<br />';
} else {
// autopublish the plugin
$query = ' UPDATE #__extensions SET enabled = 1 WHERE folder = ' . $db->Quote('redform_integration') . ' AND element = ' . $db->Quote('redevent');
$db->setQuery($query);
if ($db->query()) {
echo JText::_('COM_REDEVENT_Succesfully_installed_redform_integration_plugin') . '<br />';
} else {
echo JText::_('COM_REDEVENT_Error_publishing_redform_integration_plugin') . '<br />';
}
}
}