We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9648 ☆ A M B ☆
    • 91 Posts
    Questions posted in listing

    public function addExtensionPackage($name,$path,array $options = array()) {
            // What is it for?
            // $extPackages
            // It`s not using
            
            $extPackages = $this->getOption('extension_packages');
            $extPackages = !empty($extPackages) ? $extPackages : array();
            $extPackages = is_array($extPackages) ? $extPackages : $this->fromJSON($extPackages);
            $extPackages[$name] = $options;
            $extPackages['path'] = $path;
    
            /** @var modSystemSetting $setting */
            $setting = $this->getObject('modSystemSetting',array(
                'key' => 'extension_packages',
            ));
            if (empty($setting)) {
                $setting = $this->newObject('modSystemSetting');
                $setting->set('key','extension_packages');
                $setting->set('namespace','core');
                $setting->set('xtype','textfield');
                $setting->set('area','system');
            }
            $value = $setting->get('value');
            $value = is_array($value) ? $value : $this->fromJSON($value);
            if (empty($value)) {
                $value = array();
                $value[$name] = $options;
                $value[$name]['path'] = $path;
                $value = '['.$this->toJSON($value).']';
            } else {
                $found = false;
                foreach ($value as $k => $v) {
                    foreach ($v as $kk => $vv) {
                        if ($kk == $name) {
                            $found = true;
                        }
                    }
                }
                if (!$found) {
    
                   // And this? $extPack
                   // It`s not defined
    
                    $extPack[$name] = $options;
                    $extPack[$name]['path'] = $path;
                    $value[] = $extPack;
                }
                $value = $this->toJSON($value);
            }
            $value = str_replace('\\','',$value);
            $setting->set('value',$value);
            return $setting->save();
        }
      MODX Revolution expert
      Follow ME on Twitter | Feel free ask any question on MODX-club
      • 22303 MODX Staff
      • 10,725 Posts
      This could be better commented on using github's inline code comments. Any chance you want to take the conversation there?
        • 9648 ☆ A M B ☆
        • 91 Posts
        Quote from: opengeek at Jan 05, 2013, 07:44 AM
        This could be better commented on using github's inline code comments. Any chance you want to take the conversation there?
        https://gist.github.com/4461649/revisions
          MODX Revolution expert
          Follow ME on Twitter | Feel free ask any question on MODX-club