Improved recursive class traversal (reduced to 1 query per tree depth)
@param core_kernel_classes_Class $resource
@return array
498403
private function getRecursiveSubClasses( core_kernel_classes_Class $resource)
    {
        $returnValue = array();
        $todo = [$resource];
        while (!empty($todo)) {
            $classString = '';
            foreach ($todo as $class) {
                $classString .= ", " . $this->getPersistence()->quote($class->getUri()) ;
            }
            $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ? and '.$this->getPersistence()->getPlatForm()->getObjectTypeCondition() 
                .' in ('.substr($classString, 1).')';
            $sqlResult = $this->getPersistence()->query($sqlQuery, array(OntologyRdfs::RDFS_SUBCLASSOF));
            $todo = [];
            while ($row = $sqlResult->fetch()) {
                $subClass = new core_kernel_classes_Class($row['subject']);
                if (!isset($returnValue[$subClass->getUri()])) {
                    $todo[] = $subClass;
                }
                $returnValue[$subClass->getUri()] = $subClass;
            }
        }
        return (array) $returnValue;
    }
816065
private function serializeToArray($resource): array
    {
        $manager = new Manager();
        $manager->setSerializer(new DataArraySerializer());

        $transformation = $manager->createData($resource)->toArray();

        return $transformation['data'];
    }
404432
protected function sortResources($resources)
    {
        if ($sortBy = config('health.sort_by')) {
            return $resources->sortBy(function ($resource) use ($sortBy) {
                return $this->handleExceptions(function () use (
                    $resource,
                    $sortBy
                ) {
                    return
                        ($resource->isGlobal ? 'a-' : 'z-').$resource->$sortBy;
                });
            });
        }

        return $resources;
    }
1038717
public function serialize(Resource $resource)
    {
        return [
            'id' => $resource->getUuid(),
            'name' => $resource->getName(),
            'resourceType' => $this->resourceTypeSerializer->serialize($resource->getResourceType()),
            'maxTimeReservation' => $resource->getMaxTimeReservation(),
            'description' => $resource->getDescription(),
            'localization' => $resource->getLocalisation(),
            'quantity' => $resource->getQuantity(),
            'color' => $resource->getColor(),
            'organizations' => $this->getOrganizations($resource),
            'resourceRights' => $this->getResourceRights($resource),
        ];
    }
876376
public function resolvePath($resource)
    {
        // Skip blank resources
        if (empty($resource)) {
            return null;
        }
        $resourceObj = $this->resolveResource($resource);
        if ($resourceObj instanceof ModuleResource) {
            return $resourceObj->getRelativePath();
        }
        return $resource;
    }
1203640
public function findAllByResourceAndNames($resource, array $params)
    {
        $where = $this->getWhere(['resource' => $resource]);
        $model = $this->makeModel()->getModel()->widgetParams()->getModel()->newQuery();
        return $model->where($where)->whereIn('name', $params)->get()->toArray();
    }
1224063
public function getProperties( core_kernel_classes_Class $resource, $recursive = false)
    {
        $returnValue = array();
        
        $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ?  AND '. $this->getPersistence()->getPlatForm()->getObjectTypeCondition() .' = ?';
        $sqlResult = $this->getPersistence()->query($sqlQuery, array(
            OntologyRdfs::RDFS_DOMAIN,
            $resource->getUri()
        ));
        
        while ($row = $sqlResult->fetch()) {
            $property = new core_kernel_classes_Property($row['subject']);
            $returnValue[$property->getUri()] = $property;
        }
        
        if ($recursive == true) {
            $parentClasses = $this->getParentClasses($resource, true);
            foreach ($parentClasses as $parent) {
                if($parent->getUri() != OntologyRdfs::RDFS_CLASS) {
                	$returnValue = array_merge($returnValue, $parent->getProperties(false));
                }
            }
        }
        
        return $returnValue;
    }
223705
public function indexOf( common_Object $resource)
    {
        $returnValue = null;

        
        $returnValue = -1;
        foreach($this->sequence as $index => $_resource){
        	if ($_resource instanceof  core_kernel_classes_Resource){
				if($resource->equals($_resource)){
					return $index;
				}
        	}
		}
        

        return $returnValue;
    }
1161075
public function getExportForm(core_kernel_classes_Resource $resource) {
        if ($resource instanceof core_kernel_classes_Class) {
            $formData= array('class' => $resource);
        } else {
            $formData= array('instance' => $resource);
        }
    	$form = new ExportForm($formData);
    	return $form->getForm();
    }
947966
public function parse($resource) {

        $result = array();
        $fieldcnt = mysqli_num_fields($resource);


        $fields_transform = array();

        for($i=0;$i<$fieldcnt;$i++) {
            $finfo = mysqli_fetch_field_direct($resource, $i);

            if(isset(self::$mysqli_type[$finfo->type])) {
                $fields_transform[$finfo->name] = self::$mysqli_to_php[self::$mysqli_type[$finfo->type]];
            }
        }

        while($row = mysqli_fetch_assoc($resource)) {
            foreach($fields_transform as $fieldname => $fieldtype) {
               settype($row[$fieldname], $fieldtype);
            }
            $result[] = $row;
        }
        return $result;
    }
1158782
public function equals( core_kernel_classes_Resource $resource)
    {
        $returnValue = (bool) false;
        $returnValue = $this->getUri() == $resource->getUri();
        return (bool) $returnValue;
    }
1113941
public static function getActions(\core_kernel_classes_Resource $module)
    {
        $returnValue = array();
        $controllerClassName = MapHelper::getControllerFromUri($module->getUri());
        try {
            foreach (ControllerHelper::getActions($controllerClassName) as $actionName) {
                $uri = MapHelper::getUriForAction($controllerClassName, $actionName);
                $returnValue[$uri] = new \core_kernel_classes_Resource($uri);
            }
        } catch (\ReflectionException $e) {
            // unknown controller, no actions returned
        }
        return (array) $returnValue;
    }
1113455
private function parseResource(ResourceInterface $resource): iterable
    {
        $seenBefore = isset($this->resourcesTracker[$resource->getId()][$resource->getType()]);

        // top level resources should be yielded in any case as it could be an array of the resources
        // for deeper levels it's not needed as they go to `included` section and it must have no more
        // than one instance of the same resource.

        if ($seenBefore === false || $resource->getPosition()->getLevel() <= ParserInterface::ROOT_LEVEL) {
            yield $resource;
        }

        // parse relationships only for resources not seen before (prevents infinite loop for circular references)
        if ($seenBefore === false) {
            // remember by id and type
            $this->resourcesTracker[$resource->getId()][$resource->getType()] = true;

            foreach ($resource->getRelationships() as $name => $relationship) {
                \assert(\is_string($name));
                \assert($relationship instanceof RelationshipInterface);

                $isShouldParse = $this->isPathRequested($relationship->getPosition()->getPath());

                if ($isShouldParse === true && $relationship->hasData() === true) {
                    $relData = $relationship->getData();
                    if ($relData->isResource() === true) {
                        yield from $this->parseResource($relData->getResource());

                        continue;
                    } elseif ($relData->isCollection() === true) {
                        foreach ($relData->getResources() as $relResource) {
                            \assert($relResource instanceof ResourceInterface ||
                                $relResource instanceof IdentifierInterface);
                            if ($relResource instanceof ResourceInterface) {
                                yield from $this->parseResource($relResource);
                            }
                        }

                        continue;
                    }

                    \assert($relData->isNull() || $relData->isIdentifier());
                }
            }
        }
    }
935286
public function isLocked(core_kernel_classes_Resource $resource)
    {       
        $values = $resource->getPropertyValues($this->getLockProperty());

        if ((is_array($values)) && (count($values)>0)) {
            return true;
        }
        return false;
    }
1186979
public function findByResource(ResourceNode $resource)
    {
        return $this->createQueryBuilder('c')
            ->select('c')
            ->join('c.resources', 'r')
            ->where('r = :resource')
            ->setParameter(':resource', $resource)
            ->getQuery()
            ->getResult();
    }
744731
public function getAvailableLanguagesByUsage( core_kernel_classes_Resource $usage)
    {
        $returnValue = array();
    	$langClass = new core_kernel_classes_Class(static::CLASS_URI_LANGUAGES);
	    $returnValue = $langClass->searchInstances(array(
            static::PROPERTY_LANGUAGE_USAGES => $usage->getUri()
	    ), array(
	    	'like' => false
	    ));
        return (array) $returnValue;
    }
1298342
public function modelClass($resource=null)
    {

        $resource = $this->passedOrCurrent($resource);

        if ($modelClass = $this->mapper->modelClass($resource)) {
            return $modelClass;
        }

        if ($modelClass = $this->finder->modelClass($resource)) {
            return $modelClass;
        }

    }