本文整理汇总了PHP中InstallerModel::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP InstallerModel::getTable方法的具体用法?PHP InstallerModel::getTable怎么用?PHP InstallerModel::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InstallerModel
的用法示例。
在下文中一共展示了InstallerModel::getTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(InputInterface $input, OutputInterface $output)
{
$app = Bootstrapper::getApplication($this->target_dir);
ob_start();
// build the record.
$data = new \JObject();
$data->name = $this->extension;
$data->type = $this->type;
$data->element = $this->extension;
$data->client_id = $input->getOption('client_id');
$data->enabled = $input->getOption('enabled');
$data->position = $input->getOption('position');
$element = $input->getOption('element');
if (strlen($element)) {
$data->element = $element;
}
// special case for plugin, naming and folder.
if ($this->type == 'plugin') {
// set the default folder for plugins only.
$data->folder = $input->getOption('folder') ? $input->getOption('folder') : 'system';
// special case for the plugins only.
if (substr($data->element, 0, 4) == 'plg_') {
$data->element = substr($data->element, 4);
}
}
if ($this->type == 'template') {
if (substr($data->name, 0, 4) == 'tpl_') {
$data->name = substr($data->name, 4);
$data->element = substr($data->element, 4);
}
}
//need to be sure that a prefix is provided for components and modules
if (($this->type == "component" || $this->type == "module") && strpos($data->element, '_') === false) {
$prefix = array_search($this->type, $this->typeMap);
$data->element = $prefix . $this->extension;
}
// get the #__extensions model and table
require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/extension.php';
$model = new \InstallerModel();
$table = $model->getTable('extension', 'JTable');
// restrict on same name and type
$unique = array('name' => $data->name, 'type' => $data->type);
// does the extension exist?
if (!$table->load($unique)) {
if ($table->save($data->getProperties())) {
if (array_key_exists($this->type, $this->exceptions)) {
$this->handleExceptions($output, $app, $data, $this->type);
}
$output->writeln("<info>Your extension registered as a '{$this->type}', with extension_id: {$table->extension_id}</info>");
} else {
$output->writeln("<info>" . $table->getError() . "</info>");
}
} else {
$output->writeln("<error>{$this->extension} {$this->type}: That extension already exists.</error>");
}
ob_end_clean();
}