Retrieves sole instance of the object.
@param bool|HTMLPurifier_EntityLookup $prototype Optional prototype of custom lookup table to overload with.
@return HTMLPurifier_EntityLookup
177280
public static function instance($prototype = false)
    {
        // no references, since PHP doesn't copy unless modified
        static $instance = null;
        if ($prototype) {
            $instance = $prototype;
        } elseif (!$instance) {
            $instance = new HTMLPurifier_EntityLookup();
            $instance->setup();
        }
        return $instance;
    }
74244
public function findRootParentRecursively(string $parentProperty, string $table, Model $instance, bool $returnInstanceIfNoParent = true)
    {
        if (!$instance || !$instance->{$parentProperty}
            || null === ($parentInstance = $this->findModelInstanceByPk($table, $instance->{$parentProperty}))) {
            return $returnInstanceIfNoParent ? $instance : null;
        }

        return $this->findRootParentRecursively($parentProperty, $table, $parentInstance);
    }
1346629
protected function sortArgs($prototype, $args) {
        $keyArgs = array();
        $posArgs = array();

        foreach ($args as $arg) {
            list($key, $value) = $arg;
            $key = $key[1];
            if (empty($key)) {
                $posArgs[] = $value;
            } else {
                $keyArgs[$key] = $value;
            }
        }

        if (is_null($prototype)) return $posArgs;

        $finalArgs = array();
        foreach ($prototype as $i => $names) {
            if (isset($posArgs[$i])) {
                $finalArgs[] = $posArgs[$i];
                continue;
            }

            $set = false;
            foreach ((array)$names as $name) {
                if (isset($keyArgs[$name])) {
                    $finalArgs[] = $keyArgs[$name];
                    $set = true;
                    break;
                }
            }

            if (!$set) {
                $finalArgs[] = null;
            }
        }

        return $finalArgs;
    }
580095
public static function getInstance($refresh = false)
    {
        if (is_null(self::$environment) || $refresh) {
            self::$environment = new self();
        }

        return self::$environment;
    }
223629
public static function findBy($criteria = [], $single = false)
    {
        global $wpdb;
        $return = [];
        $query = static::getQueryByCriteria($criteria);
        $dbResults = $wpdb->get_results($query);

        if ($single && isset($dbResults[0])) {
            return static::getModelFromDBObject($dbResults[0]);
        }

        foreach ($dbResults as $object) {
            $return[] = static::getModelFromDBObject($object);
        }

        return $return;
    }
931858
public static function object($objectType)
    {
        //====================================================================//
        // First Access to Local Objects
        if (!isset(self::core()->objects)) {
            //====================================================================//
            // Initialize Local Objects Class Array
            self::core()->objects = array();
        }

        //====================================================================//
        // Check in Cache
        if (array_key_exists($objectType, self::core()->objects)) {
            return self::core()->objects[$objectType];
        }

        //====================================================================//
        // Verify if Object Class is Valid
        if (!self::validate()->isValidObject($objectType)) {
            throw new Exception('You requested access to an Invalid Object Type : '.$objectType);
        }

        //====================================================================//
        // Check if Object Manager is Overriden
        if (self::local() instanceof ObjectsProviderInterface) {
            //====================================================================//
            // Initialize Local Object Manager
            self::core()->objects[$objectType] = self::local()->object($objectType);
        } else {
            //====================================================================//
            // Initialize Standard Class
            $className = SPLASH_CLASS_PREFIX.'\\Objects\\'.$objectType;
            self::core()->objects[$objectType] = new $className();
        }

        //====================================================================//
        //  Load Translation File
        self::translator()->load('objects');

        return self::core()->objects[$objectType];
    }
619494
public static function getInstance($identifier = self::PRIMARY)
    {
        $serviceClassName = get_called_class();


        return self::findOrCreateInstance($serviceClassName, $identifier);
    }
1049834
public function findByEntityInstance($entity)
    {
        $businessEntity = null;
        $class = new \ReflectionClass($entity);
        while (!$businessEntity && $class && $class->name !== null) {
            $businessEntity = $this->findByEntityClassname($class->name);
            $class = $class->getParentClass();
        }

        return $businessEntity;
    }
201819
public static function singleton()
    {
        $returnValue = null;

        

		if (core_kernel_persistence_smoothsql_Property::$instance == null){
			core_kernel_persistence_smoothsql_Property::$instance = new core_kernel_persistence_smoothsql_Property();
		}
		$returnValue = core_kernel_persistence_smoothsql_Property::$instance;

        

        return $returnValue;
    }
263474
public function merge($prototype, $operator = 'and')
    {
        if ($prototype instanceof QueryBuilder) {
            $params = $prototype->getParams();
            $prototype = $prototype->toArray();
            $prototype['params'] = $params;
        } elseif($prototype instanceof \T4\Core\IArrayable) {
            $prototype = $prototype->toArray();
        }
        if (!is_array($prototype) && !$prototype instanceof \ArrayAccess) {
            throw new \InvalidArgumentException('Invalid builder type!');
        }
        if (!empty($this->mode) && !empty($prototype['mode']) && $this->mode !== $prototype['mode']) {
            throw new \DomainException('Query mode is not much!');
        }
        if (!empty($prototype['select'])) {
            $this->select($prototype['select']);
        }
        if (!empty($prototype['from'])) {
            $this->from($prototype['from']);
        }
        if (!empty($prototype['where'])) {
            $this->where = empty($this->where) ? $prototype['where'] : "($this->where) $operator ($prototype[where])";
        }
        foreach(['group','order','limit','offset'] as $property) {
            if (!empty($prototype[$property])) {
                $this->$property = $prototype[$property];
            }
        }
        foreach(['joins','params','insertTables','updateTables','deleteTables','values'] as $arrayProperty) {
            if (!empty($prototype[$arrayProperty])) {
                $this->$arrayProperty = array_merge($this->$arrayProperty ?? [], $prototype[$arrayProperty]);
            }
        }
        return $this;
    }
346212
public function getEntityPersister($entityName)
    {
        if (isset($this->persisters[$entityName])) {
            return $this->persisters[$entityName];
        }

        $class = $this->em->getClassMetadata($entityName);

        switch (true) {
            case ($class->isInheritanceTypeNone()):
                $persister = new BasicEntityPersister($this->em, $class);
                break;

            case ($class->isInheritanceTypeSingleTable()):
                $persister = new SingleTablePersister($this->em, $class);
                break;

            case ($class->isInheritanceTypeJoined()):
                $persister = new JoinedSubclassPersister($this->em, $class);
                break;

            default:
                throw new \RuntimeException('No persister found for entity.');
        }

        if ($this->hasCache && $class->cache !== null) {
            $persister = $this->em->getConfiguration()
                ->getSecondLevelCacheConfiguration()
                ->getCacheFactory()
                ->buildCachedEntityPersister($this->em, $persister, $class);
        }

        $this->persisters[$entityName] = $persister;

        return $this->persisters[$entityName];
    }
1126794
public static function instance($prototype = null)
    {
        if ($prototype !== null) {
            HTMLPurifier_ConfigSchema::$singleton = $prototype;
        } elseif (HTMLPurifier_ConfigSchema::$singleton === null || $prototype === true) {
            HTMLPurifier_ConfigSchema::$singleton = HTMLPurifier_ConfigSchema::makeFromSerial();
        }
        return HTMLPurifier_ConfigSchema::$singleton;
    }
848189
public function getFirst()
    {
        if (is_array($this->queryResult)) {
            $queryResult = &$this->queryResult;
        } else {
            $query = clone $this->query;
            $query->setLimit(1);
            $queryResult = $this->dataMapper->mapToObjects($this->persistenceManager->getObjectDataByQuery($query));
        }
        return (isset($queryResult[0])) ? $queryResult[0] : null;
    }
408216
public function ancestor($lookup = null)
    {
        /** @var Pages $pages */
        $pages = Grav::instance()['pages'];

        return $pages->ancestor($this->route, $lookup);
    }
872969
public function newInstance()
    {
        if ($this->prototype === null) {
            $this->prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
        }

        return clone $this->prototype;
    }
916743
public function getEntityByIdentifier($identifier)
    {
        $found_entities = $this->filter(
            function (EntityInterface $entity) use ($identifier) {
                return $entity->getIdentifier() === $identifier;
            }
        );

        return $found_entities->getFirst();
    }
1122891
public static function instance(): self
    {
        if (!self::$instance) {
            self::$instance = new self(
                Sequencer::sequence('stub-label'),
                MatcherFactory::instance(),
                MatcherVerifier::instance(),
                Invoker::instance(),
                InvocableInspector::instance(),
                EmptyValueFactory::instance(),
                GeneratorAnswerBuilderFactory::instance(),
                InlineExporter::instance()
            );
        }

        return self::$instance;
    }