Builds a class node including it's content

@param core_kernel_classes_Class $class
@param core_kernel_classes_Class $parent
@return array
@throws
179131
private function classToNode(core_kernel_classes_Class $class, core_kernel_classes_Class $parent = null) {
        $returnValue = $this->buildClassNode($class, $parent);

        // allow the class to be opened if it contains either instances or subclasses
        $subclasses = $this->getSubClasses($class);

        if($this->showResources) {
            $options = array_merge(['recursive' => false], $this->optionsFilter);
            $queryBuilder = $this->getQueryBuilder($class, $this->propertyFilter, $options);
            $search = $this->getSearchService();
            $search->setLanguage($queryBuilder, \common_session_SessionManager::getSession()->getDataLanguage());
            $instancesCount = $search->getGateway()->count($queryBuilder);

            if ($instancesCount > 0 || count($subclasses) > 0) {
                if (in_array($class->getUri(), $this->openNodes)) {
                    $returnValue['state']	= 'open';
                    $returnValue['children'] = $this->buildChildNodes($class, $subclasses);
                } else {
                    $returnValue['state']	= 'closed';
                }

                // only show the resources count if we allow resources to be viewed
                $returnValue['count'] = $instancesCount;
            }
        } else {
            if(count($subclasses) > 0) {
                if (in_array($class->getUri(), $this->openNodes)) {
                    $returnValue['state'] = 'open';
                    $returnValue['children'] = $this->buildChildNodes($class, $subclasses);
                } else {
                    $returnValue['state'] = 'closed';
                }

                $returnValue['count'] = 0;
            }
        }
        return $returnValue;
    }
1136448
protected function validateRuntimeMetadata($class, $parent)
    {
        if (!$class->reflClass) {
            // only validate if there is a reflection class instance
            return;
        }

        $class->validateIdentifier();
        $class->validateReferenceable();
        $class->validateReferences();
        $class->validateChildClasses();
        $class->validateLifecycleCallbacks($this->getReflectionService());
        $class->validateTranslatables();

        // verify inheritance
        // TODO
    }
1274992
public function getNodeInformation(
    $entityClass = '',
        $parentEntity = null
    )
    {
        if ($entityClass === '') {
            throw new Exception('messages.error.classNameNotProvided');
        }
        return $this->repository->getNodeInformation($entityClass, $parentEntity);
    }
159351
public function set_parent(Node_Container $parent=null)
	{
		$this->parent = $parent;

		if($parent instanceof Node_Container_Document)
			$this->root = $parent;
		else
			$this->root = $parent->root();
	}
440444
void buildEntityJson(ObjectNode parent) {
    for (Element child : this.children) {
      ObjectNode node = child.asEntityJson(parent);

      if (node != null) {
        child.buildEntityJson(node);
      } else {
        child.buildEntityJson(parent);
      }
    }
  }
179160
private function validateChildClass(NodeInterface $parentNode, ClassMetadata $class)
    {
        $parentClass = $this->documentClassMapper->getClassName($this->dm, $parentNode);

        if (null === $parentClass) {
            return;
        }

        $metadata = $this->dm->getClassMetadata($parentClass);
        $metadata->assertValidChildClass($class);
    }
992353
public function generate(PackageClass $package_class)
    {
        $parent              = $this->getParentClass($package_class);
        $class_name          = $package_class->getShortName();
        $generated_namespace = $package_class->getGeneratedNamespaceName();
        $methods             = $this->getMethods($package_class);

        $params = [
            'class_name'  => $class_name,
            'namespace'   => $generated_namespace,
            'methods'     => $methods,
            'parent'      => $parent ? $parent->getShortName() : null,
        ];

        $interface = $this->environment->render('interface.php.twig', $params);
        $path      = $package_class->getGeneratedDirectory();
        $this->filesystem->dumpFile($path . $class_name . 'Interface.php', $interface);
    }
1128339
public function parents()
    {
        if (!$this->nodes) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }

        $node = $this->getNode(0);
        $nodes = array();

        while ($node = $node->parentNode) {
            if (XML_ELEMENT_NODE === $node->nodeType) {
                $nodes[] = $node;
            }
        }

        return $this->createSubCrawler($nodes);
    }
1233134
private function buildTree(string $class): void
    {
        $level = 0;
        $stack = new SplStack();

        while (true) {

            //initialize array if not already initialized
            if (empty($this->tree[$level][$class])) {
                $this->tree[$level][$class] = [];
            }

            //get parameter from constructor
            //can return error when constructor not declared
            $parameters = (new ReflectionClass($class))->getConstructor()->getParameters();

            //loop parameter
            foreach ($parameters as $param) {

                //check if argument is already stored
                $notAlreadyStored = !\in_array($param, $this->tree[$level][$class]);

                //if there is parameter with callable type
                if (\class_exists((string) $param->getType()) && $notAlreadyStored) {

                    //push values in stack for simulate later recursive function
                    $stack->push([$level, $class]);

                    //store dependency
                    $this->tree[$level][$class][] = $param;

                    //update values for simulate recursive function
                    $level++;
                    $class = $param->getClass()->name;

                    //return to main while
                    continue 2;
                }

                if ($notAlreadyStored) {
                    //store dependency
                    $this->tree[$level][$class][] = $param;
                }
            }

            //if stack is empty break while end exit from function
            if ($stack->count() === 0) {
                break;
            }

            //get last value pushed into stack;
            list($level, $class) = $stack->pop();
        }
    }
1326693
public function getAncestors($class)
    {
        $ancestors = [];
        while (true) {
            $parent = $this->getParent($class);
            if ($parent) {
                $ancestors[] = $parent;
                $class = $parent;
            } else {
                break;
            }
        }
        return $ancestors;
    }
464373
public function createWithParent( $parent, $config = [] ) {

		$modelClass	= static::$modelClass;

		$parentId	= $config[ 'parentId' ];
		$parentType	= $config[ 'parentType' ];
		$type		= isset( $config[ 'type' ] ) ? $config[ 'type' ] : $parent->type;
		$order		= isset( $config[ 'order' ] ) ? $config[ 'order' ] : 0;

		$file = null;

		switch( $parent->type ) {

			case 'image': {

				$file = $this->fileService->saveImage( $parent );
			}
			// TODO: Add case to save cross-browser compatible videos
			default: {

				$file = $this->fileService->saveFile( $parent );
			}
		}

		$model = new $modelClass;

		$model->modelId		= $file->id;
		$model->parentId	= $parentId;
		$model->parentType	= $parentType;

		$model->type	= $type;
		$model->order	= $order;
		$model->active	= true;

		return parent::create( $model );
	}
761698
public function setDomain( core_kernel_classes_Class $class)
    {
        $returnValue = (bool) false;
 
        if(!is_null($class)){
        	foreach($this->getDomain()->getIterator() as $domainClass){
        		if ($class->equals($domainClass)) {
        			$returnValue = true;
        			break;
        		}
        	}
        	if(!$returnValue){
        		$this->setPropertyValue($this->getProperty(OntologyRdfs::RDFS_DOMAIN), $class->getUri());
        		if(!is_null($this->domain)){
        			$this->domain->add($class);
        		}
        		$returnValue = true;
        	}
        }
        return (bool) $returnValue;
    }
810313
public function getChildrenOfClass($class)
    {
        // Check for namespace alias
        if (strpos($class, ':') !== false) {
            list($namespaceAlias, $simpleClassName) = explode(':', $class);
            $class = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
        }
        $result = array();
        $children = $this->getChildren();
        foreach ($children as $child) {
            if ($child->getPage() instanceof $class) {
                $result[] = $child;
            }
        }

        return $result;
    }
566508
public function getParentOfClass($class)
    {
        // Check for namespace alias
        if (strpos($class, ':') !== false) {
            list($namespaceAlias, $simpleClassName) = explode(':', $class);
            $class = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
        }
        if ($this->getParent() === null) {
            return null;
        }
        if ($this->parent->getPage() instanceof $class) {
            return $this->parent;
        }

        return $this->parent->getParentOfClass($class);
    }
607727
public function getParentClasses( core_kernel_classes_Class $resource, $recursive = false)
    {
        $returnValue = array();
		
        $sqlQuery = 'SELECT object FROM statements WHERE subject = ?  AND predicate = ?';

		$sqlResult = $this->getPersistence()->query($sqlQuery, array($resource->getUri(), OntologyRdfs::RDFS_SUBCLASSOF));

		while ($row = $sqlResult->fetch()){

            $parentClass = new core_kernel_classes_Class($row['object']);
            
            $returnValue[$parentClass->getUri()] = $parentClass ;
            if ($recursive == true && $parentClass->getUri() != OntologyRdfs::RDFS_CLASS && $parentClass->getUri() != OntologyRdfs::RDFS_RESOURCE) {
                if ($parentClass->getUri() == GenerisRdf::CLASS_GENERIS_RESOURCE) {
                    $returnValue[OntologyRdfs::RDFS_RESOURCE] = new core_kernel_classes_Class(OntologyRdfs::RDFS_RESOURCE);
                } else {
                    $plop = $parentClass->getParentClasses(true);
                	$returnValue = array_merge($returnValue, $plop);
                }
            }
		}

        return $returnValue;
    }
1107867
private function buildTreeFromArray(
        array $treeStructure,
        \Tx_Oelib_Visibility_Node $parentNode
    ) {
        foreach ($treeStructure as $nodeKey => $nodeContents) {
            /** @var \Tx_Oelib_Visibility_Node $childNode */
            $childNode = GeneralUtility::makeInstance(\Tx_Oelib_Visibility_Node::class);
            $parentNode->addChild($childNode);

            if (is_array($nodeContents)) {
                $this->buildTreeFromArray($nodeContents, $childNode);
            } elseif ($nodeContents === true) {
                $childNode->markAsVisible();
            }

            $this->nodes[$nodeKey] = $childNode;
        }
    }
1124919
public static function getAllChildClasses($class): array
    {
        $type = gettype($class);
        $className = '';

        /* If input an object */
        if ($type == 'object') {
            $className = get_class($class);
        }

        /* If input a string */
        elseif ($type == 'string') {
            $className = $class;
        }

        $classes = [];

        /* Go through all classes */
        foreach (get_declared_classes() as $class) {
            if (is_subclass_of($class, $className)) {
                $classes[] = $class;
            }
        }

        return $classes;
    }