Get the sections of the current extension's structure

@param string $shownExtension
@param string $shownStructure
@return array the sections
960435
private function getSections($shownExtension, $shownStructure)
    {

        $sections = array();
        $user = $this->getSession()->getUser();
        $structure = MenuService::getPerspective($shownExtension, $shownStructure);
        if (!is_null($structure)) {
            foreach ($structure->getChildren() as $section) {

                $resolver = new ActionResolver($section->getUrl());
                if (FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())) {

                    foreach($section->getActions() as $action){
                        $this->propagate($action);
                        $resolver = new ActionResolver($action->getUrl());
                        if(!FuncProxy::accessPossible($user, $resolver->getController(), $resolver->getAction())){
                            $section->removeAction($action);
                        }

                    }

                    $sections[] = $section;
                }
            }
        }

        return $sections;
    }
622194
protected function sortExtensions(/*# string */ $stage)
    {
        $sorted = &$this->sorted;

        // if not sorted yet
        if (!isset($sorted[$stage])) {
            $sorted[$stage] = [];

            // current stage
            if (isset($this->extensions[$stage])) {
                foreach ($this->extensions[$stage] as $p => $e) {
                    $sorted[$stage][$p] = $e;
                }
            }

            // process the special STAGE_ALL
            $all = ExtensionStage::STAGE_ALL;
            if (isset($this->extensions[$all])) {
                foreach ($this->extensions[$all] as $p => $e) {
                    $sorted[$stage][$p] = isset($sorted[$stage][$p]) ?
                        (array_merge($sorted[$stage][$p], $e)) :
                        $e;
                }
            }

            // sort extensions by priority
            if (count($sorted[$stage])) {
                ksort($sorted[$stage]);
            }
        }
    }
474414
public function getSection($section = null)
    {
        if (null === $this->container) {
            return $this->getRawSection($section);
        }

        return $this->compileParameters($section);
    }
875715
protected function getExtensions()
    {
        if (null === $this->sorted) {
            ksort($this->extensions);
            $this->sorted = !empty($this->extensions)
                ? call_user_func_array('array_merge', $this->extensions)
                : [];
        }

        return $this->sorted;
    }
1242336
private function getControllerClasses(\common_ext_Extension $extension) {
        $returnValue = array();

        // routes
        $namespaces = array();
        foreach ($extension->getManifest()->getRoutes() as $mapedPath => $ns) {
            if (is_string($ns)) {
                $namespaces[] = trim($ns, '\\');
            }
        }
        if (!empty($namespaces)) {
            common_Logger::t('Namespace found in routes for extension '. $extension->getId() );
            $classes = array();
            $recDir = new RecursiveDirectoryIterator($extension->getDir());
            $recIt = new RecursiveIteratorIterator($recDir);
            $regexIt = new RegexIterator($recIt, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
            foreach ($regexIt as $entry) {
                $info = helpers_PhpTools::getClassInfo($entry[0]);
                if (!empty($info['ns'])) {
                    $ns = trim($info['ns'], '\\');
                    if (!empty($info['ns']) && in_array($ns, $namespaces)) {
                        $returnValue[$info['class']] = $ns.'\\'.$info['class'];
                    }
                }
            }
        }

        // legacy
        if ($extension->hasConstant('DIR_ACTIONS') && file_exists($extension->getConstant('DIR_ACTIONS'))) {
            $dir = new DirectoryIterator($extension->getConstant('DIR_ACTIONS'));
            foreach ($dir as $fileinfo) {
                if(preg_match('/^class\.[^.]*\.php$/', $fileinfo->getFilename())) {
                    $module = substr($fileinfo->getFilename(), 6, -4);
                    $returnValue[$module] = $extension->getId().'_actions_'.$module;
                }
            }
        }

        $returnValue = array_filter( $returnValue, array($this, 'isControllerClassNameValid') );

        return (array) $returnValue;
    }
759724
public function seeJsonStructure(array $structure = null, $responseData = null)
    {
        if (is_null($structure)) {
            return $this->seeJson();
        }

        if (is_null($responseData)) {
            $responseData = $this->decodeResponseJson();
        }

        foreach ($structure as $key => $value) {
            if (is_array($value) && $key === '*') {
                $this->assertIsArray($responseData);

                foreach ($responseData as $responseDataItem) {
                    $this->seeJsonStructure($structure['*'], $responseDataItem);
                }
            } elseif (is_array($value)) {
                $this->assertArrayHasKey($key, $responseData);
                $this->seeJsonStructure($structure[$key], $responseData[$key]);
            } else {
                $this->assertArrayHasKey($value, $responseData);
            }
        }

        return $this;
    }
501281
public function stageChildren($showAll = false) {
		// if we don't have an ID directly, we should load and return ALL the external content sources
		if (!$this->ID) {
			return DataObject::get('ExternalContentSource');
		}

		$children = new ArrayList();
		return $children;
	}
1224701
public function removeStructureNodeRelatedByParentId(ChildStructureNode $structureNodeRelatedByParentId)
    {
        if ($this->getStructureNodesRelatedByParentId()->contains($structureNodeRelatedByParentId)) { $structureNodeParent = new ChildStructureNodeParent();

            $structureNodeParent->setStructureNodeRelatedByParentId($structureNodeRelatedByParentId);
            if ($structureNodeRelatedByParentId->isStructureNodeRelatedByStructureNodeIdsLoaded()) {
                //remove the back reference if available
                $structureNodeRelatedByParentId->getStructureNodeRelatedByStructureNodeIds()->removeObject($this);
            }

            $structureNodeParent->setStructureNodeRelatedByStructureNodeId($this);
            $this->removeStructureNodeParentRelatedByStructureNodeId(clone $structureNodeParent);
            $structureNodeParent->clear();

            $this->collStructureNodesRelatedByParentId->remove($this->collStructureNodesRelatedByParentId->search($structureNodeRelatedByParentId));

            if (null === $this->structureNodesRelatedByParentIdScheduledForDeletion) {
                $this->structureNodesRelatedByParentIdScheduledForDeletion = clone $this->collStructureNodesRelatedByParentId;
                $this->structureNodesRelatedByParentIdScheduledForDeletion->clear();
            }

            $this->structureNodesRelatedByParentIdScheduledForDeletion->push($structureNodeRelatedByParentId);
        }


        return $this;
    }
715961
public function findAllWithExtension($extensions)
	{
		$found = [];

		if (!is_array($extensions))
		{
			$extensions = [$extensions];
		}

		foreach ($this->getFlatListOfFiles() as $file)
		{
			$ext = $file->getExtension();
			if (in_array($ext, $extensions))
			{
				$found[] = $file;
			}
		}

		return $found;
	}
301998
protected function getAttachments()
    {
        $attachments = array();
        foreach ($this->getSections(self::SECTION_ATTACHMENTS) as $section) {
            $obj = $this->getSection($section);
            $attachment = new IncomingMessageAttachment($obj);
            $objNew = new \stdClass();
            $objNew->name = $attachment->name;
            $objNew->body = $attachment->body;
            $objNew->info = $obj;
            $attachments[] = $objNew;
        }
        $this->attachments = $attachments;
    }
740876
private function extractLinks(ElementStructure $elementStructure)
    {
        $links = [];

        foreach ($elementStructure->getLanguages() as $language) {
            foreach ($elementStructure->getValues($language) as $elementStructureValue) {
                $field = $this->fieldRegistry->getField($elementStructureValue->getType());

                $links = array_merge($links, $this->linkExtractor->extract($elementStructureValue, $field));
            }
        }

        foreach ($elementStructure->getStructures() as $childStructure) {
            $links = array_merge($links, $this->extractLinks($childStructure));
        }

        return $links;
    }
984742
protected static function calculateFieldPaths(array $structure, string $firstLevelFieldName = null): array
    {
        $fieldPaths = self::calculateFieldPathsAsArray($structure, $firstLevelFieldName);
        array_walk($fieldPaths, function (&$fieldPath) {
            $fieldPath = implode('/', $fieldPath);
        });
        return $fieldPaths;
    }
984921
def getExtensions(self, extname='SCI', section=None):
        
        if section is None:
            numext = 0
            section = []
            for hdu in self._image:
                if 'extname' in hdu.header and hdu.header['extname'] == extname:
                    section.append(hdu.header['extver'])
        else:
            if not isinstance(section,list):
                section = [section]

        return section
1264186
public function findShowByName($showName)
  {
    $response = $this->request('/FindShowByName/' . $showName);
    if ( $response->response->status == 'false' )
      return null;
    $shows = $response->response->results->result;

    if ( count($shows) <= 0 )
      return null;

    $show = $shows[0];
    $show = $this->formatShow($show);

    return $show;
  }
1013816
public function stageChildren($showAll = false) {
		if ($this->Title != 'Content Root' && $this->source) {
			$children = new ArrayList();
			$item = new ExternalContentItem($this->source, $this->Title . '1');
			$item->Title = $this->Title . '1';
			$item->MenuTitle = $item->Title;

			$children->push($item);
			return $children;
		}
	}
449415
private function sortExtensions()
    {
        // Ensure extensions are loaded in order
        $this->sortedExtensions = array();
        foreach ($this->extensions as $extension) {
            $this->addExtensionToSorted($extension);
        }
    }
971743
protected function findDefinitionsByTag(ContainerBuilder $builder, $showHidden)
    {
        $definitions = [];
        $tags = $builder->findTags();
        asort($tags);

        foreach ($tags as $tag) {
            foreach ($builder->findTaggedServiceIds($tag) as $serviceId => $attributes) {
                $definition = $this->resolveServiceDefinition($builder, $serviceId);

                if ($showHidden xor '.' === ($serviceId[0] ?? null)) {
                    continue;
                }

                if (!isset($definitions[$tag])) {
                    $definitions[$tag] = [];
                }

                $definitions[$tag][$serviceId] = $definition;
            }
        }

        return $definitions;
    }