当前位置: 首页>>代码示例>>PHP>>正文


PHP InstallerModel::getTable方法代码示例

本文整理汇总了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();
 }
开发者ID:eitamar,项目名称:joomlatools-console,代码行数:57,代码来源:Register.php


注:本文中的InstallerModel::getTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。