Old syntax of class constructor. Deprecated in PHP7.

@deprecated since Moodle 3.1
775407
public function MoodleQuickForm_autocomplete($elementName=null, $elementLabel=null, $options=null, $attributes=null) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($elementName, $elementLabel, $options, $attributes);
    }
25576
function code_body() {
    // Get the class code from the class docblock onwards first, so it can be
    // then processed for qualified class names.
    $class_doc_block = $this->getClassDocBlockLines();
    $class_doc_block = $this->docBlock($class_doc_block);

    $class_code = array_merge(
      $class_doc_block,
      $this->class_declaration(),
      $this->classCodeBody()
    );

    // Replace any fully-qualified classes with short class names, and keep a
    // list of the replacements to make import statements with.
    $imported_classes = [];
    $this->extractFullyQualifiedClasses($class_code, $imported_classes, $this->component_data['namespace']);

    $return = array_merge(
      $this->code_namespace(),
      $this->imports($imported_classes),
      $class_code,
      [
        '}',
      ]);
    return $return;
  }
288267
public function MoodleQuickForm($formName, $method, $action, $target='', $attributes=null) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($formName, $method, $action, $target, $attributes);
    }
427324
function class_declaration() {
    $line = '';
    $line .= "interface {$this->component_data['plain_class_name']}";
    if ($this->component_data['parent_interface_names']) {
      $line .= ' extends ';
      $line .= implode(', ', $this->component_data['parent_interface_names']);
    }
    $line .= ' {';

    return [
      $line,
    ];
  }
220261
public function question_category_object($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts);
    }
93306
public function MoodleQuickForm_warning($elementName=null, $elementClass='notifyproblem', $text=null) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($elementName, $elementClass, $text);
    }
358831
function db_init() {
        if ($this->is_configured() === false) {
            throw new moodle_exception('auth_dbcantconnect', 'auth_db');
        }

        // Connect to the external database (forcing new connection).
        $authdb = ADONewConnection($this->config->type);
        if (!empty($this->config->debugauthdb)) {
            $authdb->debug = true;
            ob_start(); //Start output buffer to allow later use of the page headers.
        }
        $authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
        $authdb->SetFetchMode(ADODB_FETCH_ASSOC);
        if (!empty($this->config->setupsql)) {
            $authdb->Execute($this->config->setupsql);
        }

        return $authdb;
    }
1135056
public function MoodleQuickForm_selectgroups($elementName=null, $elementLabel=null, $optgrps=null, $attributes=null, $showchoose=false) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($elementName, $elementLabel, $optgrps, $attributes, $showchoose);
    }
549886
public function component_installer($sourcebase, $zippath, $zipfilename, $md5filename='', $destpath='') {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($sourcebase, $zippath, $zipfilename, $md5filename, $destpath);
    }
62223
public static void deprecated(Class<?> clazz, String methodOrPropName, String version) {
        if (LOG_DEPRECATED) {
            deprecated("Property or method [" + methodOrPropName + "] of class [" + clazz.getName() +
                    "] is deprecated in [" + version +
                    "] and will be removed in future releases");
        }
    }
157246
public function compile()
    {
        $indent    = '    ';
        $getters   = array();
        $instances = $this->dumper->getAllInjectedDefinitions();

        /* @var $instance GeneratorInstance */
        foreach ($instances as $name => $instance) {
            $constructor = $instance->getConstructor();
            $instantiatorParams = $this->buildParams($instance->getParams());

            if ('__construct' !== $constructor) {
                // Constructor callback
                if (is_callable($constructor)) {
                    $callback = $constructor;

                    if (is_array($callback)) {
                        $class = (is_object($callback[0])) ? get_class($callback[0]) : $callback[0];
                        $method = $callback[1];
                    } elseif (is_string($callback) && strpos($callback, '::') !== false) {
                        list($class, $method) = explode('::', $callback, 2);
                    }

                    $callback = var_export(array($class, $method), true);

                    if (count($instantiatorParams)) {
                        $creation = sprintf('$object = call_user_func(%s, %s);', $callback, implode(', ', $instantiatorParams));
                    } else {
                        $creation = sprintf('$object = call_user_func(%s);', $callback);
                    }
                } else if (is_string($constructor) && strpos($constructor, '->') !== false) {
                    list($class, $method) = explode('->', $constructor, 2);

                    if (!class_exists($class)) {
                        throw new InvalidArgumentException('No class found: ' . $class);
                    }

                    if (count($instantiatorParams)) {
                        $creation = sprintf(
                            '$object = $di->get(%s)->%s(%s);',
                            var_export($class, true),
                            $method,
                            implode(', ', $instantiatorParams)
                        );
                    } else {
                        $creation = sprintf('$object = $di->get(%s)->%s();', var_export($class, true), $method);
                    }
                } else {
                    throw new InvalidArgumentException('Invalid instantiator supplied for class: ' . $name);
                }
            } else {
                $className = '\\' . trim($this->reduceAlias($name), '\\');

                if (count($instantiatorParams)) {
                    $creation = sprintf('$object = new %s(%s);', $className, implode(', ', $instantiatorParams));
                } else {
                    $creation = sprintf('$object = new %s();', $className);
                }
            }


            // Create method call code
            if ($instance->isShared()) {
                $creation .= "\n\nif (\$isShared) {\n" . $indent
                    . '$di->instanceManager()->addSharedInstance($object, \'' . $instance->getName() . '\');'
                    . "\n}\n";
            }

            $methods = '';

            foreach ($instance->getMethods() as $methodData) {
                $methodName   = $methodData['method'];
                $methodParams = $methodData['params'];
                // Create method parameter representation
                $params = $this->buildParams($methodParams);

                if (count($params)) {
                    $methods .= sprintf("\$object->%s(%s);\n", $methodName, implode(', ', $params));
                }
            }

            // Start creating getter
            $getterBody = "function (\\Zend\\Di\\Di \$di, \$isShared) {\n";

            // Creation and method calls
            $getterBody .= $indent . str_replace("\n", "\n" . $indent, $creation) . "\n";
            $getterBody .= $indent . str_replace("\n", "\n" . $indent, $methods);

            // End getter body
            $getterBody .= "\n" . $indent . "return \$object;\n}";

            $getters[$name] = $getterBody;
        }

        $fileBody = "return array(\n";

        foreach ($getters as $name => $getterBody) {
            $fileBody .= $indent . var_export($name, true);
            $fileBody .= ' => ' . str_replace("\n", "\n" . $indent, $getterBody) . ",\n\n";
        }

        $fileBody .= ");\n";

        // Create PHP file code generation object
        $generator = $this->getFileGenerator();
        $generator->setBody($fileBody);

        return $generator;
    }
470586
public function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN,
                         $level = E_USER_NOTICE, $debuginfo = null) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($code, $mode, $level, $debuginfo);
    }
612903
private static function init()
	{
		$classes[] = array('id' => '1', 'name' => 'uppercase', 'regex' => '[A-Z]',                                       'flag' => '1');
		$classes[] = array('id' => '2', 'name' => 'numeric',   'regex' => '[0-9]',                                       'flag' => '1');
		$classes[] = array('id' => '3', 'name' => 'lowercase', 'regex' => '[a-z]',                                       'flag' => '1');
		$classes[] = array('id' => '4', 'name' => 'special',   'regex' => '[!"\'(),-.:;?[`{}#$%&*+<=>@^_|~\]\/\\\]',     'flag' => '1');
		$classes[] = array('id' => '5', 'name' => 'nonalpha',  'regex' => '[!"\'(),\-.:;?[`{}#$%&*+<=>@^_|~\]\/\\\0-9]', 'flag' => '0');
		$classes[] = array('id' => '6', 'name' => 'alpha',     'regex' => '[A-Za-z]',                                    'flag' => '0');

		self::$classes = $classes;
	}
1041248
public function classWriter(&$doclet)
    {

        parent::HTMLWriter($doclet);

        $this->_id = 'definition';

        $rootDoc =& $this->_doclet->rootDoc();
        $phpdoctor =& $this->_doclet->phpdoctor();

        $packages =& $rootDoc->packages();
        ksort($packages);

        foreach ($packages as $packageName => $package) {

            $this->_sections[0] = array('title' => 'Overview', 'url' => 'overview-summary.html');
            $this->_sections[1] = array('title' => 'Namespace', 'url' => $package->asPath().'/package-summary.html');
            $this->_sections[2] = array('title' => 'Class', 'selected' => TRUE);
            //$this->_sections[3] = array('title' => 'Use');
            if ($phpdoctor->getOption('tree')) $this->_sections[4] = array('title' => 'Tree', 'url' => $package->asPath().'/package-tree.html');
            if ($doclet->includeSource()) $this->_sections[5] = array('title' => 'Files', 'url' => 'overview-files.html');
            $this->_sections[6] = array('title' => 'Deprecated', 'url' => 'deprecated-list.html');
            $this->_sections[7] = array('title' => 'Todo', 'url' => 'todo-list.html');
            $this->_sections[8] = array('title' => 'Index', 'url' => 'index-all.html');

            $this->_depth = $package->depth() + 1;

            $classes =& $package->allClasses();

            if ($classes) {
                ksort($classes);
                foreach ($classes as $name => $class) {

                    ob_start();

                    echo "<hr>\n\n";

                    echo '<div class="qualifiedName">', $class->qualifiedName(), "</div>\n";
                    $this->_sourceLocation($class);

                    if ($class->isInterface()) {
                        echo '<h1>Interface ', $class->name(), "</h1>\n\n";
                    } else {
                        echo '<h1>Class ', $class->name(), "</h1>\n\n";
                    }

                    echo '<pre class="tree">';
                    $result = $this->_buildTree($rootDoc, $classes[$name]);
                    echo $result[0];
                    echo "</pre>\n\n";

                    $implements =& $class->interfaces();
                    if (count($implements) > 0) {
                        echo "<dl>\n";
                        echo "<dt>All Implemented Interfaces:</dt>\n";
                        echo '<dd>';
                        foreach ($implements as $interface) {
                            echo '<a href="', str_repeat('../', $this->_depth), $interface->asPath(), '">';
                            if ($interface->packageName() != $class->packageName()) {
                                echo $interface->packageName(), '\\';
                            }
                            echo $interface->name(), '</a> ';
                        }
                        echo "</dd>\n";
                        echo "</dl>\n\n";
                    }

                    $traits =& $class->traits();
                    if (count($traits) > 0) {
                        echo "<dl>\n";
                        echo "<dt>All Used Traits:</dt>\n";
                        echo '<dd>';
                        foreach ($traits as $trait) {
                            echo '<a href="', str_repeat('../', $this->_depth), $trait->asPath(), '">';
                            if ($trait->packageName() != $class->packageName()) {
                                echo $trait->packageName(), '\\';
                            }
                            echo $trait->name(), '</a> ';
                        }
                        echo "</dd>\n";
                        echo "</dl>\n\n";
                    }

                    $subclasses = $class->subclasses();
                    if ($subclasses) {
                        echo "<dl>\n";
                        echo "<dt>All Known Subclasses:</dt>\n";
                        echo '<dd>';
                        foreach ($subclasses as $subclass) {
                            echo '<a href="', str_repeat('../', $this->_depth), $subclass->asPath(), '">';
                            if ($subclass->packageName() != $class->packageName()) {
                                echo $subclass->packageName(), '\\';
                            }
                            echo $subclass->name(), '</a> ';
                        }
                        echo "</dd>\n";
                        echo "</dl>\n\n";
                    }

                    echo "<hr>\n\n";

                    if ($class->isInterface()) {
                        echo '<p class="signature">', $class->modifiers(), ' interface <strong>', $class->name(), '</strong>';
                    } elseif ($class->isTrait()) {
                        echo '<p class="signature">', $class->modifiers(), ' trait <strong>', $class->name(), '</strong>';
                    } else {
                        echo '<p class="signature">', $class->modifiers(), ' class <strong>', $class->name(), '</strong>';
                    }
                    if ($class->superclass()) {
                        $superclass =& $rootDoc->classNamed($class->superclass());
                        if ($superclass) {
                            echo '<br>extends <a href="', str_repeat('../', $this->_depth), $superclass->asPath(), '">', $superclass->name(), "</a>\n\n";
                        } else {
                            echo '<br>extends ', $class->superclass(), "\n\n";
                        }
                    }
                    echo "</p>\n\n";

                    $textTag =& $class->tags('@text');
                    if ($textTag) {
                        echo '<div class="comment" id="overview_description">', $this->_processInlineTags($textTag), "</div>\n\n";
                    }

                    $this->_processTags($class->tags());

                    echo "<hr>\n\n";

                    $constants =& $class->constants();
                    ksort($constants);
                    $fields =& $class->fields();
                    ksort($fields);
                    $constructor =& $class->constructor();
                    $methods =& $class->methods(TRUE);
                    ksort($methods);

                    if ($constants) {
                        echo '<table id="summary_field">', "\n";
                        echo '<tr><th colspan="2">Constant Summary</th></tr>', "\n";
                        foreach ($constants as $field) {
                            $textTag =& $field->tags('@text');
                            echo "<tr>\n";
                            echo '<td class="type">', $field->modifiers(FALSE), ' ', $field->typeAsString(), "</td>\n";
                            echo '<td class="description">';
                            echo '<p class="name"><a href="#', $field->name(), '">';
                            if (is_null($field->constantValue())) echo '$';
                            echo $field->name(), '</a></p>';
                            if ($textTag) {
                                echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                            }
                            echo "</td>\n";
                            echo "</tr>\n";
                        }
                        echo "</table>\n\n";
                    }

                    if ($fields) {
                        echo '<table id="summary_field">', "\n";
                        echo '<tr><th colspan="2">Field Summary</th></tr>', "\n";
                        foreach ($fields as $field) {
                            $textTag =& $field->tags('@text');
                            echo "<tr>\n";
                            echo '<td class="type">', $field->modifiers(FALSE), ' ', $field->typeAsString(), "</td>\n";
                            echo '<td class="description">';
                            echo '<p class="name"><a href="#', $field->name(), '">';
                            if (is_null($field->constantValue())) echo '$';
                            echo $field->name(), '</a></p>';
                            if ($textTag) {
                                echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                            }
                            echo "</td>\n";
                            echo "</tr>\n";
                        }
                        echo "</table>\n\n";
                    }

                    if ($class->superclass()) {
                        $superclass =& $rootDoc->classNamed($class->superclass());
                        if ($superclass) {
                            $this->inheritFields($superclass, $rootDoc, $package);
                        }
                    }

                    if ($constructor) {
                        echo '<table id="summary_constructor">', "\n";
                        echo '<tr><th colspan="2">Constructor Summary</th></tr>', "\n";
                        $textTag =& $constructor->tags('@text');
                        echo "<tr>\n";
                        echo '<td class="type">', $constructor->modifiers(FALSE), ' ', $constructor->returnTypeAsString(), "</td>\n";
                        echo '<td class="description">';
                        echo '<p class="name"><a href="#', $constructor->name(), '()">', $constructor->name(), '</a>', $constructor->flatSignature(), '</p>';
                        if ($textTag) {
                            echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                        }
                        echo "</td>\n";
                        echo "</tr>\n";
                        echo "</table>\n\n";
                    }

                    if ($methods) {
                        echo '<table id="summary_method">', "\n";
                        echo '<tr><th colspan="2">Method Summary</th></tr>', "\n";
                        foreach ($methods as $method) {
                            $textTag =& $method->tags('@text');
                            echo "<tr>\n";
                            echo '<td class="type">', $method->modifiers(FALSE), ' ', $method->returnTypeAsString(), "</td>\n";
                            echo '<td class="description">';
                            echo '<p class="name"><a href="#', $method->name(), '()">', $method->name(), '</a>', $method->flatSignature(), '</p>';
                            if ($textTag) {
                                echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                            }
                            echo "</td>\n";
                            echo "</tr>\n";
                        }
                        echo "</table>\n\n";
                    }

                    if ($class->superclass()) {
                        $superclass =& $rootDoc->classNamed($class->superclass());
                        if ($superclass) {
                            $this->inheritMethods($superclass, $rootDoc, $package);
                        }
                    }

                    if ($constants) {
                        echo '<h2 id="detail_field">Constant Detail</h2>', "\n";
                        foreach ($constants as $field) {
                            $textTag =& $field->tags('@text');
                            $type =& $field->type();
                            $this->_sourceLocation($field);
                            echo '<h3 id="', $field->name(),'">', $field->name(), "</h3>\n";
                            echo '<code class="signature">', $field->modifiers(), ' ', $field->typeAsString(), ' <strong>';
                            if (is_null($field->constantValue())) echo '$';
                            echo $field->name(), '</strong>';
                            if (!is_null($field->value())) echo ' = ', htmlspecialchars($field->value());
                            echo "</code>\n";
                            echo '<div class="details">', "\n";
                            if ($textTag) {
                                echo $this->_processInlineTags($textTag);
                            }
                            $this->_processTags($field->tags());
                            echo "</div>\n\n";
                            echo "<hr>\n\n";
                        }
                    }

                    if ($fields) {
                        echo '<h2 id="detail_field">Field Detail</h2>', "\n";
                        foreach ($fields as $field) {
                            $textTag =& $field->tags('@text');
                            $type =& $field->type();
                            $this->_sourceLocation($field);
                            echo '<h3 id="', $field->name(),'">', $field->name(), "</h3>\n";
                            echo '<code class="signature">', $field->modifiers(), ' ', $field->typeAsString(), ' <strong>';
                            if (is_null($field->constantValue())) echo '$';
                            echo $field->name(), '</strong>';
                            if (!is_null($field->value())) echo ' = ', htmlspecialchars($field->value());
                            echo "</code>\n";
                            echo '<div class="details">', "\n";
                            if ($textTag) {
                                echo $this->_processInlineTags($textTag);
                            }
                            $this->_processTags($field->tags());
                            echo "</div>\n\n";
                            echo "<hr>\n\n";
                        }
                    }

                    if ($constructor) {
                        echo '<h2 id="detail_method">Constructor Detail</h2>', "\n";
                        $textTag =& $constructor->tags('@text');
                        $this->_sourceLocation($constructor);
                        echo '<h3 id="', $constructor->name(),'()">', $constructor->name(), "</h3>\n";
                        echo '<code class="signature">', $constructor->modifiers(), ' ', $constructor->returnTypeAsString(), ' <strong>';
                        echo $constructor->name(), '</strong>', $constructor->flatSignature();
                        echo "</code>\n";
                        echo '<div class="details">', "\n";
                        if ($textTag) {
                            echo $this->_processInlineTags($textTag);
                        }
                        $this->_processTags($constructor->tags());
                        echo "</div>\n\n";
                        echo "<hr>\n\n";
                    }

                    if ($methods) {
                        echo '<h2 id="detail_method">Method Detail</h2>', "\n";
                        foreach ($methods as $method) {
                            $textTag =& $method->tags('@text');
                            $this->_sourceLocation($method);
                            echo '<h3 id="', $method->name(),'()">', $method->name(), "</h3>\n";
                            echo '<code class="signature">', $method->modifiers(), ' ', $method->returnTypeAsString(), ' <strong>';
                            echo $method->name(), '</strong>', $method->flatSignature();
                            echo "</code>\n";
                            echo '<div class="details">', "\n";
                            if ($textTag) {
                                echo $this->_processInlineTags($textTag);
                            }
                            $this->_processTags($method->tags());
                            echo "</div>\n\n";
                            echo "<hr>\n\n";
                        }
                    }

                    $this->_output = ob_get_contents();
                    ob_end_clean();

                    $this->_write($package->asPath().'/'.strtolower($class->name()).'.html', $class->name(), TRUE);
                }
            }
        }
    }
168755
public function HTML_QuickForm_header($elementName = null, $text = null) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($elementName, $text);
    }
862708
private function constructor(string $class_name, array $params = null)
    {
        $this->state->category = CompilerState::CATEGORY_CONSTRUCTOR;
        $this->state->name = '';
        $params_str = '';
        if (is_array($params)){
            $params_str = $this->decorateParamsForMethodCall($params);
        }
        return $class_name . '(' . $params_str . ')';
    }
986860
public function initialise() {
        global $PAGE, $USER, $OUTPUT, $CFG;
        if (during_initial_install()) {
            return;
        }

        $current = false;

        $course = $PAGE->course;

        $this->page->navigation->initialise();

        // First walk the nav tree looking for "flat_navigation" nodes.
        if ($course->id > 1) {
            // It's a real course.
            $url = new moodle_url('/course/view.php', array('id' => $course->id));

            $coursecontext = context_course::instance($course->id, MUST_EXIST);
            // This is the name that will be shown for the course.
            $coursename = empty($CFG->navshowfullcoursenames) ?
                format_string($course->shortname, true, array('context' => $coursecontext)) :
                format_string($course->fullname, true, array('context' => $coursecontext));

            $flat = new flat_navigation_node(navigation_node::create($coursename, $url), 0);
            $flat->set_collectionlabel($coursename);
            $flat->key = 'coursehome';
            $flat->icon = new pix_icon('i/course', '');

            $courseformat = course_get_format($course);
            $coursenode = $PAGE->navigation->find_active_node();
            $targettype = navigation_node::TYPE_COURSE;

            // Single activity format has no course node - the course node is swapped for the activity node.
            if (!$courseformat->has_view_page()) {
                $targettype = navigation_node::TYPE_ACTIVITY;
            }

            while (!empty($coursenode) && ($coursenode->type != $targettype)) {
                $coursenode = $coursenode->parent;
            }
            // There is one very strange page in mod/feedback/view.php which thinks it is both site and course
            // context at the same time. That page is broken but we need to handle it (hence the SITEID).
            if ($coursenode && $coursenode->key != SITEID) {
                $this->add($flat);
                foreach ($coursenode->children as $child) {
                    if ($child->action) {
                        $flat = new flat_navigation_node($child, 0);
                        $this->add($flat);
                    }
                }
            }

            $this->page->navigation->build_flat_navigation_list($this, true, get_string('site'));
        } else {
            $this->page->navigation->build_flat_navigation_list($this, false, get_string('site'));
        }

        $admin = $PAGE->settingsnav->find('siteadministration', navigation_node::TYPE_SITE_ADMIN);
        if (!$admin) {
            // Try again - crazy nav tree!
            $admin = $PAGE->settingsnav->find('root', navigation_node::TYPE_SITE_ADMIN);
        }
        if ($admin) {
            $flat = new flat_navigation_node($admin, 0);
            $flat->set_showdivider(true, get_string('sitesettings'));
            $flat->key = 'sitesettings';
            $flat->icon = new pix_icon('t/preferences', '');
            $this->add($flat);
        }

        // Add-a-block in editing mode.
        if (isset($this->page->theme->addblockposition) &&
                $this->page->theme->addblockposition == BLOCK_ADDBLOCK_POSITION_FLATNAV &&
                $PAGE->user_is_editing() && $PAGE->user_can_edit_blocks() &&
                ($addable = $PAGE->blocks->get_addable_blocks())) {
            $url = new moodle_url($PAGE->url, ['bui_addblock' => '', 'sesskey' => sesskey()]);
            $addablock = navigation_node::create(get_string('addblock'), $url);
            $flat = new flat_navigation_node($addablock, 0);
            $flat->set_showdivider(true, get_string('blocksaddedit'));
            $flat->key = 'addblock';
            $flat->icon = new pix_icon('i/addblock', '');
            $this->add($flat);
            $blocks = [];
            foreach ($addable as $block) {
                $blocks[] = $block->name;
            }
            $params = array('blocks' => $blocks, 'url' => '?' . $url->get_query_string(false));
            $PAGE->requires->js_call_amd('core/addblockmodal', 'init', array($params));
        }
    }