Backend\Core\Installer\ModuleInstaller::insertExtra PHP Метод

insertExtra() защищенный Метод

Insert an extra
protected insertExtra ( string $module, ModuleExtraType | string $type, string $label, string $action = null, string $data = null, boolean $hidden = false, integer $sequence = null ) : integer
$module string The module for the extra.
$type common\ModuleExtraType | string The type, possible values are: homepage, widget, block.
$label string The label for the extra.
$action string The action.
$data string Optional data, will be passed in the extra.
$hidden boolean Is this extra hidden?
$sequence integer The sequence for the extra.
Результат integer
    protected function insertExtra($module, $type, $label, $action = null, $data = null, $hidden = false, $sequence = null)
    {
        // no sequence set
        if (is_null($sequence)) {
            // set next sequence number for this module
            $sequence = $this->getDB()->getVar('SELECT MAX(sequence) + 1 FROM modules_extras WHERE module = ?', array((string) $module));
            // this is the first extra for this module: generate new 1000-series
            if (is_null($sequence)) {
                $sequence = $sequence = $this->getDB()->getVar('SELECT CEILING(MAX(sequence) / 1000) * 1000 FROM modules_extras');
            }
        }
        $module = (string) $module;
        $type = (string) $type;
        $label = (string) $label;
        $action = !is_null($action) ? (string) $action : null;
        $data = !is_null($data) ? (string) $data : null;
        $hidden = $hidden && $hidden !== 'N' ? 'Y' : 'N';
        $sequence = (int) $sequence;
        // build item
        $item = array('module' => $module, 'type' => $type, 'label' => $label, 'action' => $action, 'data' => $data, 'hidden' => $hidden, 'sequence' => $sequence);
        // build query
        $query = 'SELECT id FROM modules_extras WHERE module = ? AND type = ? AND label = ?';
        $parameters = array($item['module'], $item['type'], $item['label']);
        if ($data !== null) {
            $query .= ' AND data = ?';
            $parameters[] = $data;
        } else {
            $query .= ' AND data IS NULL';
        }
        // get id (if it already exists)
        $extraId = (int) $this->getDB()->getVar($query, $parameters);
        // doesn't already exist
        if ($extraId === 0) {
            // insert extra and return id
            return (int) $this->getDB()->insert('modules_extras', $item);
        }
        // exists so return id
        return $extraId;
    }