@param \google\protobuf\FileDescriptorProto $fileDescriptor
@param \Traversable                         $enums
@param string                               $parent

@return array
557636
protected function generateEnums(FileDescriptorProto $fileDescriptor, Traversable $enums, $parent = null)
    {
        $result = [];

        foreach ($enums as $enum) {
            $result[] = $this->generateEnum($fileDescriptor, $enum, $parent);
        }

        return $result;
    }
1002308
public function setParent($parent)
    {
        if (!$parent instanceof ClassDescriptor && !$parent instanceof InterfaceDescriptor && $parent !== null) {
            throw new \InvalidArgumentException('Constants can only have an interface or class as parent');
        }

        $fqsen = $parent !== null
            ? $parent->getFullyQualifiedStructuralElementName() . '::' . $this->getName()
            : $this->getName();

        $this->setFullyQualifiedStructuralElementName($fqsen);

        $this->parent = $parent;
    }
52922
public function toXML(DOMElement $parent) : DOMElement
    {
        if ($this->KeyInfo === null) {
            throw new \Exception('Cannot convert KeyDescriptor to XML without KeyInfo set.');
        }

        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(Constants::NS_MD, 'md:KeyDescriptor');
        $parent->appendChild($e);

        if ($this->use !== null) {
            $e->setAttribute('use', $this->use);
        }

        $this->KeyInfo->toXML($e);

        foreach ($this->EncryptionMethod as $em) {
            $em->toXML($e);
        }

        return $e;
    }
1335971
public function getSubNodes($parent, $onGetNode = null)
    {
        $pl = new PageList();
        $pl->setPermissionsChecker(function ($page) {
            $cp = new Permissions($page);

            return $cp->canViewPageInSitemap();
        });
        $pl->includeAliases();
        $pl->sortByDisplayOrder();
        if ($this->includeSystemPages()) {
            $pl->includeSystemPages();
            $pl->includeInactivePages();
        }
        if (!is_object($parent)) {
            $cID = $parent;
        } elseif ($parent instanceof Tree) {
            $pl->setSiteTreeObject($parent);
            $cID = 0;
        }
        $pl->filterByParentID($cID); // Either 0 or cParentID
        $pl->setPageVersionToRetrieve(\Concrete\Core\Page\PageList::PAGE_VERSION_RECENT);

        if ($cID == 1) {
            $results = $pl->getResults();
            $pagination = null;
        } else {
            $config = $this->app->make('config');
            $pl->setItemsPerPage($config->get('concrete.limits.sitemap_pages'));
            $pagination = $pl->getPagination();
            $total = $pagination->getTotalResults();
            $results = $pagination->getCurrentPageResults();
        }

        $nodes = [];
        foreach ($results as $c) {
            $n = $this->getNode($c, true, $onGetNode);
            if ($n != false) {
                $nodes[] = $n;
            }
        }
        if (is_object($pagination) && $pagination->haveToPaginate()) {
            if ($this->displayNodePagination && isset($pagination)) {
                $n = new stdClass();
                $n->icon = false;
                $n->extraClasses = 'ccm-sitemap-explore';
                $n->noLink = true;
                $n->unselectable = true;
                $html = $pagination->renderView('dashboard');
                $n->title = $html;
                $nodes[] = $n;
            } else {
                $n = new stdClass();
                $n->icon = false;
                $n->extraClasses = 'ccm-sitemap-explore';
                $n->noLink = true;
                $n->active = false;
                $n->focus = false;
                $n->unselectable = true;

                // Avoids redirecting to the flat view page in an overlay context
                if ($this->isSitemapOverlay) {
                    $n->extraClasses = 'ccm-sitemap-open-flat-view';
                    $n->cParentID = (int) $cID;
                    $n->title = ' ' . t('More Pages to Display. <strong>Use the Flat View</strong>');
                } else {
                    $n->title = ' ' . t('More Pages to Display. <strong>Next Page &gt;</strong>');
                    $n->href = (string) \URL::to('/dashboard/sitemap/explore/', $cID);
                }
                $nodes[] = $n;
            }
        }

        return $nodes;
    }
721118
private function buildTree(array $rows, $parent = null)
    {
        $tree = [];

        foreach ($rows as &$row) {
            if ($row['parent'] == $parent) {
                $hasChildren        = $this->propertyAccessor->getValue($row, "[{$this->options['children_column']}]");
                $row['hasChildren'] = (bool)($hasChildren > 0);
                $row['children']    = $this->buildTree($rows, $row['id']);
                $tree[]             = $row;
            }
        }

        return $tree;
    }
717516
private function getParentModelButtons($parentModel, EnvironmentInterface $environment)
    {
        if ('select' === $environment->getInputProvider()->getParameter('act')) {
            return '';
        }

        $config = $environment->getBaseConfigRegistry()->getBaseConfig();
        $environment->getView()->getPanel()->initialize($config);
        if (!$config->getSorting()) {
            return '';
        }

        return \implode(
            ' ',
            [
                'editHeader' => $this->getHeaderEditButton($parentModel, $environment),
                'pasteNew' => $this->getHeaderPasteNewButton($parentModel, $environment),
                'pasteAfter' => $this->getHeaderPasteTopButton($parentModel, $environment)
            ]
        );
    }
876708
public function AddEnumeration(\Peg\Lib\Definitions\Element\Enumeration $enumeration)
    {
        $enumeration->parent_class =& $this;
        $this->enumerations[$enumeration->name] = $enumeration;
        
        return $this;
    }
784006
private function scanNamespaceForPackages(NamespaceInterface $root, PackageInterface $parent = null): Generator
    {
        foreach ($root->iterateNamespaces() as $namespace) {
            yield from $this->loadPackage($namespace, $parent);
        }
    }
1062521
protected function toArrayDeepProc($enum): array
    {
        $array = [];
        foreach ($enum as $k => $v)
            $array[$k] = $v instanceof \Traversable || is_array($v) ? $this->toArrayDeepProc($v) : $v;
        return $array;
    }
812077
protected function toListDeepProc($enum): array
    {
        $array = [];
        foreach ($enum as $v)
            $array[] = $v instanceof \Traversable || is_array($v) ? $this->toListDeepProc($v) : $v;
        return $array;
    }
203759
public function getParents(LoaderInterface $loader = null)
    {
        if (empty($this->parents) && $this->id !== static::$root)
            $this->parents = [$this->getRoot()];

        $acl = $this->getACL();
        if (null === $acl)
            throw new \RuntimeException("ACL is null on " . get_class($this));
        $parents = [];
        $ids = array_keys($this->parents);
        foreach ($ids as $id)
        {
            if ($this->parents[$id] === null)
            {
                if (!$acl->hasInstance(static::class, $id) && $loader !== null)
                {
                    $parent = $loader->load($id, static::class);
                    $acl->setInstance($parent);
                    $this->parents[$id] = $parent;
                }
                else
                {
                    $this->parents[$id] = $acl->getInstance(static::class, $id);
                }
            }
            $parents[] = $this->parents[$id];
        }
        return $parents;
    }
1185515
private static EnumDescriptorProtoPOJO getDescritorProtoPOJO(FileDescriptorProtoPOJO fileDescriptorProto,
            EnumType typeElement, Set<String> messageSet, Set<String> enumSet) {

        EnumDescriptorProtoPOJO ret = new EnumDescriptorProtoPOJO();
        ret.name = typeElement.getName();
        ret.values = new ArrayList<EnumValueDescriptorProtoPOJO>();
        ret.options = new ArrayList<EnumOptionsPOJO>();

        List<Value> values = typeElement.getValues();
        if (values != null) {
            EnumValueDescriptorProtoPOJO fieldDescriptorProto;
            for (com.squareup.protoparser.EnumType.Value fieldElement : values) {
                fieldDescriptorProto = new EnumValueDescriptorProtoPOJO();
                fieldDescriptorProto.name = fieldElement.getName();
                fieldDescriptorProto.number = fieldElement.getTag();

                ret.values.add(fieldDescriptorProto);
            }
        }

        List<Option> options = typeElement.getOptions();
        if (options != null) {
            EnumOptionsPOJO fieldDescriptorProto;
            for (Option option : options) {
                fieldDescriptorProto = new EnumOptionsPOJO();
                ret.options.add(fieldDescriptorProto);
            }
        }

        return ret;
    }
1166869
protected function addConstants($constants, $fileDescriptor)
    {
        foreach ($constants as $constant) {
            $constantDescriptor = $this->getBuilder()->buildDescriptor($constant);
            if ($constantDescriptor) {
                $constantDescriptor->setLocation($fileDescriptor, $constant->getLineNumber());
                if (count($constantDescriptor->getTags()->get('package', new Collection())) == 0) {
                    $constantDescriptor->getTags()
                        ->set('package', $fileDescriptor->getTags()->get('package', new Collection()));
                }

                $fileDescriptor->getConstants()->set(
                    $constantDescriptor->getFullyQualifiedStructuralElementName(),
                    $constantDescriptor
                );
            }
        }
    }
1091102
protected static List<FieldDescriptor> getChildFieldDescriptors(final Descriptor type) {
    final List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>();

    for (final FieldDescriptor field : type.getFields()) {
      if (field.getJavaType() == JavaType.MESSAGE) {
        fields.add(field);
      }
    }

    for (final FieldDescriptor field : type.getExtensions()) {
      if (field.getJavaType() == JavaType.MESSAGE) {
        fields.add(field);
      }
    }

    return Collections.unmodifiableList(fields);
  }
988978
private function valuesToFormParameters($values, $parent)
    {
        $ret = array();
        foreach ($values as $key => $value) {
            if (null !== $parent) {
                $keyName = sprintf('%s[%s]', $parent, $key);
            } else {
                $keyName = $key;
            }
            if (is_scalar($value)) {
                $ret[$keyName] = $value;
            } else {
                $ret = array_merge($ret, $this->valuesToFormParameters($value, $keyName));
            }
        }
        return $ret;
    }
913040
public List<Descriptor> getDescriptors(SessionProvider sp, FolderDescriptor parentFolder) throws RepositoryException
   {
      LOG.info("Get child nodes to : " + parentFolder.getAsString());

      Session session = currentSession(sp);

      session.refresh(true);

      Node rootNode = (Node) session.getItem(rootNodePath);
      String strPath = parentFolder.getAsString();

      Node targetNode;
      if (strPath.equals("/"))
      {
         targetNode = rootNode;
      }
      else
      {
         targetNode = rootNode.getNode(strPath.substring(1));
      }
      LOG.info(targetNode.getPath());
      NodeType[] a = targetNode.getMixinNodeTypes();
      StringBuilder mixins = new StringBuilder();
      for (NodeType type : a)
      {
         mixins.append(type.getName()).append(" ");
      }
      LOG.info("**** Mixins : " + mixins.toString());

      LOG.info("**** Workspace : " + session.getWorkspace().getName());

      List<Descriptor> childNodes = new ArrayList<Descriptor>();
      for (NodeIterator iterator = targetNode.getNodes(); iterator.hasNext();)
      {
         // descriptor holds names of all child nodes than makes up artifact
         // coordinates.
         Node node = iterator.nextNode();

         if (node.isNodeType("nt:folder") || node.isNodeType("nt:file"))
         {
            Descriptor descriptor = new FolderDescriptor(node.getName());
            childNodes.add(descriptor);
         }
      }

      return (childNodes.size() == 0) ? null : childNodes;
   }
1034626
public static function filterEnumByName(
        QueryBuilder $queryBuilder,
        &$criteria,
        $field,
        $enumTypeName,
        $isJoined = false,
        $alias = 'o'
    ) {
        if (isset($criteria[$field])) {
            if (!empty($criteria[$field])) {
                if (!$isJoined) {
                    $queryBuilder->join(sprintf('%s.%s', $alias, $field), 'enum')->join('enum.type', 'enumType');
                }
                $queryBuilder
                    ->andWhere('enumType.name = :enumType')
                    ->andWhere(sprintf('enum.name LIKE :%s', $field))
                    ->setParameter($field, '%'.$criteria[$field].'%')
                    ->setParameter('enumType', $enumTypeName);
            }
            unset($criteria[$field]);
        }

        return $criteria;
    }