Creats a ready javascript object

@param string $script
@param bool $defer

@return JavascriptObjectInterface
332756
public function ready(string $script, bool $defer = true): JavascriptObjectInterface
    {
        $object = new JavascriptObject();

        $object->setType($script::TYPE_READY);
        $object->setContent($script);
        $object->setDefer($defer);

        $this->add($object);

        return $object;
    }
1036737
protected function addFactoryBody(&$script)
    {
        $classname = $this->getClassNameFromBuilder($this->getNewStubQueryBuilder($this->getTable()));
        $script .= "
        if (\$criteria instanceof " . $classname . ") {
            return \$criteria;
        }
        \$query = new " . $classname . "();
        if (null !== \$modelAlias) {
            \$query->setModelAlias(\$modelAlias);
        }
        if (\$criteria instanceof Criteria) {
            \$query->mergeWith(\$criteria);
        }

        return \$query;";
    }
1134849
public function deferedLoadingJavascript($tag, $handle)
    {
        if (is_admin()) {
            return $tag;
        }

        if (isset($_GET['preview']) && $_GET['preview'] == 'true') {
            return $tag;
        }

        $scriptsHandlesToIgnore = apply_filters('Municipio/Theme/Enqueue/deferedLoadingJavascript/handlesToIgnore', array('readspeaker'), $handle);

        if (in_array($handle, $scriptsHandlesToIgnore)) {
            return $tag;
        }

       return str_replace(' src', ' defer="defer" src', $tag);
    }
390067
protected function addToArray(&$script)
    {
        $fks = $this->getTable()->getForeignKeys();
        $referrers = $this->getTable()->getReferrers();
        $hasFks = count($fks) > 0 || count($referrers) > 0;
        $objectClassName = $this->getObjectClassname();
        $pkGetter = $this->getTable()->hasCompositePrimaryKey() ? 'serialize($this->getPrimaryKey())' : '$this->getPrimaryKey()';
        $defaultKeyType = $this->getDefaultKeyType();
        $script .= "
    /**
     * Exports the object as an array.
     *
     * You can specify the key type of the array by passing one of the class
     * type constants.
     *
     * @param     string  \$keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     *                    Defaults to BasePeer::$defaultKeyType.
     * @param     boolean \$includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
     * @param     array \$alreadyDumpedObjects List of objects to skip to avoid recursion";
        if ($hasFks) {
            $script .= "
     * @param     boolean \$includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.";
        }
        $script .= "
     *
     * @return array an associative array containing the field names (as keys) and field values
     */
    public function toArray(\$keyType = BasePeer::$defaultKeyType, \$includeLazyLoadColumns = true, \$alreadyDumpedObjects = array()" . ($hasFks ? ", \$includeForeignObjects = false" : '') . ")
    {
        if (isset(\$alreadyDumpedObjects['$objectClassName'][$pkGetter])) {
            return '*RECURSION*';
        }
        \$alreadyDumpedObjects['$objectClassName'][$pkGetter] = true;
        \$keys = " . $this->getPeerClassname() . "::getFieldNames(\$keyType);
        \$result = array(";
        foreach ($this->getTable()->getColumns() as $num => $col) {
            if ($col->isLazyLoad()) {
                $script .= "
            \$keys[$num] => (\$includeLazyLoadColumns) ? \$this->get" . $col->getPhpName() . "() : null,";
            } else {
                $script .= "
            \$keys[$num] => \$this->get" . $col->getPhpName() . "(),";
            }
        }
        $script .= "
        );";
        $script .= "
        \$virtualColumns = \$this->virtualColumns;
        foreach (\$virtualColumns as \$key => \$virtualColumn) {
            \$result[\$key] = \$virtualColumn;
        }
        ";
        if ($hasFks) {
            $script .= "
        if (\$includeForeignObjects) {";
            foreach ($fks as $fk) {
                $script .= "
            if (null !== \$this->" . $this->getFKVarName($fk) . ") {
                \$result['" . $this->getFKPhpNameAffix($fk, $plural = false) . "'] = \$this->" . $this->getFKVarName($fk) . "->toArray(\$keyType, \$includeLazyLoadColumns,  \$alreadyDumpedObjects, true);
            }";
            }
            foreach ($referrers as $fk) {
                if ($fk->isLocalPrimaryKey()) {
                    $script .= "
            if (null !== \$this->" . $this->getPKRefFKVarName($fk) . ") {
                \$result['" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "'] = \$this->" . $this->getPKRefFKVarName($fk) . "->toArray(\$keyType, \$includeLazyLoadColumns, \$alreadyDumpedObjects, true);
            }";
                } else {
                    $script .= "
            if (null !== \$this->" . $this->getRefFKCollVarName($fk) . ") {
                \$result['" . $this->getRefFKPhpNameAffix($fk, $plural = true) . "'] = \$this->" . $this->getRefFKCollVarName($fk) . "->toArray(null, true, \$keyType, \$includeLazyLoadColumns, \$alreadyDumpedObjects);
            }";
                }
            }
            $script .= "
        }";
        }
        $script .= "

        return \$result;
    }
";
    }
1284699
public function prepare(Script $script)
    {
        $script->addScriptFunction("uiDropdownFunctions", $this->getScriptDropdown());
        $script->addCustomScriptLabel(ScriptLabel::MouseClick, $this->getScriptMouseClick());
        $script->addCustomScriptLabel(ScriptLabel::OnInit, $this->getScriptInit());
    }
636958
public static function addJavaScript($js, $docready = false)
    {
        return self::$app->getResponse()->addJavaScript($js,$docready);
    }
314294
protected function addFindOneOrCreate(&$script)
    {
        $child = $this->getChild();
        $col = $child->getColumn();
        $script .= "

    /**
     * Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria
     * and format the result with the current formatter
     * By default, returns a model object
     *
     * @param PropelPDO \$con an optional connection object
     *
     * @return mixed the result, formatted by the current formatter
     *
     * @throws PropelException
     */
    public function findOneOrCreate(\$con = null)
    {
        if (\$this->joins) {
            throw new PropelException('findOneOrCreate() cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.');
        }
        if (!\$ret = \$this->findOne(\$con)) {
            \$class = " . $this->getPeerClassname() . "::CLASSNAME_" . strtoupper($child->getKey()) . ";
            \$obj = new \$class;
            foreach (\$this->keys() as \$key) {
                \$obj->setByName(\$key, \$this->getValue(\$key), BasePeer::TYPE_COLNAME);
            }
            \$ret = \$this->getFormatter()->formatRecord(\$obj);
        }

        return \$ret;
    }
";
    }
1002235
protected function addRefFKCount(&$script, ForeignKey $refFK)
    {
        $fkQueryClassName = $this->getClassNameFromBuilder($this->getNewStubQueryBuilder($refFK->getTable()));
        $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
        $collName = $this->getRefFKCollVarName($refFK);

        $joinedTableObjectBuilder = $this->getNewObjectBuilder($refFK->getTable());
        $className = $this->getClassNameFromBuilder($joinedTableObjectBuilder);

        $script .= "
    /**
     * Returns the number of related $className objects.
     *
     * @param      Criteria \$criteria
     * @param      boolean \$distinct
     * @param      ConnectionInterface \$con
     * @return int             Count of related $className objects.
     * @throws PropelException
     */
    public function count{$relCol}(Criteria \$criteria = null, \$distinct = false, ConnectionInterface \$con = null)
    {
        \$partial = \$this->{$collName}Partial && !\$this->isNew();
        if (null === \$this->$collName || null !== \$criteria || \$partial) {
            if (\$this->isNew() && null === \$this->$collName) {
                return 0;
            }

            if (\$partial && !\$criteria) {
                return count(\$this->get$relCol());
            }

            \$query = $fkQueryClassName::create(null, \$criteria);
            if (\$distinct) {
                \$query->distinct();
            }

            return \$query
                ->filterBy" . $this->getFKPhpNameAffix($refFK) . "(\$this)
                ->count(\$con);
        }

        return count(\$this->$collName);
    }
";
    }
962984
protected function addDoSelectJoinAll(&$script)
    {
        $table = $this->getTable();
        $className = $this->getObjectClassname();
        $join_behavior = $this->getJoinBehavior();

        $script .= "

    /**
     * Selects a collection of $className objects pre-filled with all related objects.
     *
     * @param      Criteria  \$criteria
     * @param      PropelPDO \$con
     * @param      String    \$join_behavior the type of joins to use, defaults to $join_behavior
     * @return array           Array of $className objects.
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doSelectJoinAll(Criteria \$criteria, \$con = null, \$join_behavior = $join_behavior)
    {
        \$criteria = clone \$criteria;

        // Set the correct dbName if it has not been overridden
        if (\$criteria->getDbName() == Propel::getDefaultDB()) {
            \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME);
        }

        " . $this->getPeerClassname() . "::addSelectColumns(\$criteria);
        \$startcol2 = " . $this->getPeerClassname() . "::NUM_HYDRATE_COLUMNS;
";
        $index = 2;
        foreach ($table->getForeignKeys() as $fk) {

            // Want to cover this case, but the code is not there yet.
            // Propel lacks a system for aliasing tables of the same name.
            if ($fk->getForeignTableName() != $table->getName()) {
                $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
                $new_index = $index + 1;

                $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable);
                $joinClassName = $joinedTablePeerBuilder->getObjectClassname();

                $script .= "
        " . $joinedTablePeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria);
        \$startcol$new_index = \$startcol$index + " . $joinedTablePeerBuilder->getPeerClassname() . "::NUM_HYDRATE_COLUMNS;
";
                $index = $new_index;
            } // if fk->getForeignTableName != table->getName
        } // foreach [sub] foreign keys

        foreach ($table->getForeignKeys() as $fk) {
            // want to cover this case, but the code is not there yet.
            if ($fk->getForeignTableName() != $table->getName()) {
                $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
                $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable);
                $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder);
            }
        }

        // apply behaviors
        $this->applyBehaviorModifier('preSelect', $script);

        $script .= "
        \$stmt = " . $this->basePeerClassname . "::doSelect(\$criteria, \$con);
        \$results = array();

        while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) {
            \$key1 = " . $this->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, 0);
            if (null !== (\$obj1 = " . $this->getPeerClassname() . "::getInstanceFromPool(\$key1))) {
                // We no longer rehydrate the object, since this can cause data loss.
                // See http://www.propelorm.org/ticket/509
                // \$obj1->hydrate(\$row, 0, true); // rehydrate
            } else {";

        if ($table->getChildrenColumn()) {
            $script .= "
                \$omClass = " . $this->getPeerClassname() . "::getOMClass(\$row, 0);
        \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1);
";
        } else {
            $script .= "
                \$cls = " . $this->getPeerClassname() . "::getOMClass();
";
        }

        $script .= "
                " . $this->buildObjectInstanceCreationCode('$obj1', '$cls') . "
                \$obj1->hydrate(\$row);
                " . $this->getPeerClassname() . "::addInstanceToPool(\$obj1, \$key1);
            } // if obj1 already loaded
";

        $index = 1;
        foreach ($table->getForeignKeys() as $fk) {
            // want to cover this case, but the code is not there yet.
            // Why not? -because we'd have to alias the tables in the JOIN
            if ($fk->getForeignTableName() != $table->getName()) {
                $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());

                $thisTableObjectBuilder = $this->getNewObjectBuilder($table);
                $joinedTableObjectBuilder = $this->getNewObjectBuilder($joinTable);
                $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable);


                $joinClassName = $joinedTableObjectBuilder->getObjectClassname();
                $interfaceName = $joinClassName;

                if ($joinTable->getInterface()) {
                    $interfaceName = $this->prefixClassname($joinTable->getInterface());
                }

                $index++;

                $script .= "
            // Add objects for joined $joinClassName rows

            \$key$index = " . $joinedTablePeerBuilder->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, \$startcol$index);
            if (\$key$index !== null) {
                \$obj$index = " . $joinedTablePeerBuilder->getPeerClassname() . "::getInstanceFromPool(\$key$index);
                if (!\$obj$index) {
";
                if ($joinTable->getChildrenColumn()) {
                    $script .= "
                    \$omClass = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(\$row, \$startcol$index);
          \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1);
";
                } else {
                    $script .= "
                    \$cls = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass();
";
                } /* $joinTable->getChildrenColumn() */

                $script .= "
                    " . $this->buildObjectInstanceCreationCode('$obj' . $index, '$cls') . "
                    \$obj" . $index . "->hydrate(\$row, \$startcol$index);
                    " . $joinedTablePeerBuilder->getPeerClassname() . "::addInstanceToPool(\$obj$index, \$key$index);
                } // if obj$index loaded

                // Add the \$obj1 (" . $this->getObjectClassname() . ") to the collection in \$obj" . $index . " (" . $joinedTablePeerBuilder->getObjectClassname() . ")";
                if ($fk->isLocalPrimaryKey()) {
                    $script .= "
                \$obj1->set" . $joinedTablePeerBuilder->getObjectClassname() . "(\$obj" . $index . ");";
                } else {
                    $script .= "
                \$obj" . $index . "->add" . $joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false) . "(\$obj1);";
                }
                $script .= "
            } // if joined row not null
";
            } // $fk->getForeignTableName() != $table->getName()
        } //foreach foreign key

        $script .= "
            \$results[] = \$obj1;
        }
        \$stmt->closeCursor();

        return \$results;
    }
";
    }
1370343
protected function addClassOpen(&$script)
    {
        $table = $this->getTable();
        $script .= "

/**
 * This class defines the structure of the '".$table->getName()."' table.
 *
 *";
        if ($this->getBuildProperty('generator.objectModel.addTimeStamp')) {
            $now = strftime('%c');
            $script .= "
 * This class was autogenerated by Propel " . $this->getBuildProperty('general.version') . " on:
 *
 * $now
 *";
        }
        $script .= "
 *
 * This map class is used by Propel to do runtime db structure discovery.
 * For example, the createSelectSql() method checks the type of a given column used in an
 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
 * (i.e. if it's a text column type).
 *
 */
class ".$this->getUnqualifiedClassName()." extends TableMap
{
    use InstancePoolTrait;
    use TableMapTrait;

";
    }
762015
public function &file($url, $defer = false, $is_external = false)
    {
        // Do not add files already added
        if (in_array($url, $this->files_used)) {
            Throw new PageException(sprintf('Url "%s" is already set as included js file.', $url));
        }

        $dt = debug_backtrace();

        $this->files_used[$this->filecounter . '-' . $dt[1]['function']] = $url;
        $this->filecounter ++;

        $script = new JavascriptObject();

        $script->setType('file');
        $script->setScript($url);
        $script->setIsExternal($is_external);
        $script->setDefer($defer);

        $this->add($script);

        return $script;
    }
498512
public function createScript()
    {
        if ($this->script) {
            return $this->script;
        }
        $script = new Script();
        $this->setScript($script);
        return $this->script;
    }
1318820
protected function addRefFKInit(&$script, ForeignKey $refFK)
    {
        $relCol = $this->getRefFKPhpNameAffix($refFK, true);
        $collName = $this->getRefFKCollVarName($refFK);

        $script .= "
    /**
     * Initializes the $collName collection.
     *
     * By default this just sets the $collName collection to an empty array (like clear$collName());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param      boolean \$overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function init$relCol(\$overrideExisting = true)
    {
        if (null !== \$this->$collName && !\$overrideExisting) {
            return;
        }

        \$collectionClassName = ".$this->getClassNameFromBuilder($this->getNewTableMapBuilder($refFK->getTable()))."::getTableMap()->getCollectionClassName();

        \$this->{$collName} = new \$collectionClassName;
        \$this->{$collName}->setModel('" . $this->getClassNameFromBuilder($this->getNewStubObjectBuilder($refFK->getTable()), true) . "');
    }
";
    }
501664
protected function addFKMutator(&$script, ForeignKey $fk)
    {
        $table = $this->getTable();
        $tblFK = $this->getForeignTable($fk);

        $joinTableObjectBuilder = $this->getNewObjectBuilder($tblFK);
        $className = $joinTableObjectBuilder->getObjectClassname();

        $varName = $this->getFKVarName($fk);

        $script .= "
    /**
     * Declares an association between this object and a $className object.
     *
     * @param                  $className \$v
     * @return "               . $this->getObjectClassname() . " The current object (for fluent API support)
     * @throws PropelException
     */
    public function set" . $this->getFKPhpNameAffix($fk, $plural = false) . "($className \$v = null)
    {";
        foreach ($fk->getLocalColumns() as $columnName) {
            $column = $table->getColumn($columnName);
            $lfmap = $fk->getLocalForeignMapping();
            $colFKName = $lfmap[$columnName];
            $colFK = $tblFK->getColumn($colFKName);
            $script .= "
        if (\$v === null) {
            \$this->set" . $column->getPhpName() . "(" . $this->getDefaultValueString($column) . ");
        } else {
            \$this->set" . $column->getPhpName() . "(\$v->get" . $colFK->getPhpName() . "());
        }
";
        } /* foreach local col */

        $script .= "
        \$this->$varName = \$v;
";

        // Now add bi-directional relationship binding, taking into account whether this is
        // a one-to-one relationship.

        if ($fk->isLocalPrimaryKey()) {
            $script .= "
        // Add binding for other direction of this 1:1 relationship.
        if (\$v !== null) {
            \$v->set" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this);
        }
";
        } else {
            $script .= "
        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the $className object, it will not be re-added.
        if (\$v !== null) {
            \$v->add" . $this->getRefFKPhpNameAffix($fk, $plural = false) . "(\$this);
        }
";
        }

        $script .= "

        return \$this;
    }
";
    }
690052
public function _set_defer( $tag, $handle, $src ) {
		$handles = apply_filters( 'inc2734_wp_page_speed_optimization_defer_scripts', [] );

		if ( ! in_array( $handle, $handles ) ) {
			return $tag;
		}

		return str_replace( ' src', ' defer src', $tag );
	}
204312
protected function addRefFKInit(&$script, ForeignKey $refFK)
    {
        $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
        $collName = $this->getRefFKCollVarName($refFK);

        $script .= "
    /**
     * Initializes the $collName collection (array) .
     *
     * By default this just sets the $collName collection to an empty array (like clear$collName());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @return void
     */
    public function init$relCol()
    {
        \$this->$collName = array();
    }
";
    }
347978
protected function addFactory(&$script)
    {
        $builder = $this->getNewStubQueryInheritanceBuilder($this->getChild());
        $this->declareClassFromBuilder($builder, 'Child');
        $classname = $builder->getClassName();
        $script .= "
    /**
     * Returns a new " . $classname . " object.
     *
     * @param     string \$modelAlias The alias of a model in the query
     * @param     Criteria \$criteria Optional Criteria to build the query from
     *
     * @return " . $classname . "
     */
    public static function create(\$modelAlias = null, Criteria \$criteria = null)
    {
        if (\$criteria instanceof " . $classname . ") {
            return \$criteria;
        }
        \$query = new " . $classname . "();
        if (null !== \$modelAlias) {
            \$query->setModelAlias(\$modelAlias);
        }
        if (\$criteria instanceof Criteria) {
            \$query->mergeWith(\$criteria);
        }

        return \$query;
    }
";
    }