FOF30\Update\Update::__construct PHP Метод

__construct() публичный Метод

Public constructor. Initialises the protected members as well. Useful $config keys: update_component The component name, e.g. com_foobar update_version The default version if the manifest cache is unreadable update_site The URL to the component's update XML stream update_extraquery The extra query to append to (commercial) components' download URLs update_sitename The update site's name (description)
public __construct ( array $config = [] )
$config array
    public function __construct($config = array())
    {
        $container = Container::getInstance('com_FOOBAR');
        parent::__construct($container);
        // Get an instance of the updater class
        $this->updater = JUpdater::getInstance();
        // Get the component name
        if (isset($config['update_component'])) {
            $this->component = $config['update_component'];
        } else {
            $this->component = $this->input->getCmd('option', '');
        }
        // Get the component version
        if (isset($config['update_version'])) {
            $this->version = $config['update_version'];
        }
        // Get the update site
        if (isset($config['update_site'])) {
            $this->updateSite = $config['update_site'];
        }
        // Get the extra query
        if (isset($config['update_extraquery'])) {
            $this->extraQuery = $config['update_extraquery'];
        }
        // Get the extra query
        if (isset($config['update_sitename'])) {
            $this->updateSiteName = $config['update_sitename'];
        }
        // Get the extension type
        list($extensionPrefix, $extensionName) = explode('_', $this->component);
        switch ($extensionPrefix) {
            default:
            case 'com':
                $type = 'component';
                $name = $this->component;
                break;
            case 'pkg':
                $type = 'package';
                $name = $this->component;
                break;
        }
        // Find the extension ID
        $db = $this->container->db;
        $query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q($type))->where($db->qn('element') . ' = ' . $db->q($name));
        $db->setQuery($query);
        $extension = $db->loadObject();
        if (is_object($extension)) {
            $this->extension_id = $extension->extension_id;
            $data = json_decode($extension->manifest_cache, true);
            if (isset($data['version'])) {
                $this->version = $data['version'];
            }
        }
    }

Usage Example

Пример #1
0
 /**
  * Public constructor. Initialises the protected members as well.
  *
  * @param array $config
  */
 public function __construct($config = array())
 {
     $config['update_component'] = 'pkg_ars';
     $config['update_sitename'] = 'Akeeba Release System';
     $config['update_site'] = 'http://cdn.akeebabackup.com/updates/ars.xml';
     parent::__construct($config);
 }
All Usage Examples Of FOF30\Update\Update::__construct