當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。