src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php
protected function getAvailableSections(BundleInterface $bundle, $context = null, $defaultSections = [])
    {
        $configs = [];
        $counter = 1;

        // Get the available sections from disc
        $dir = Kernel::VERSION_ID >= 40000 ?
            $this->getContainer()->getParameter('kernel.project_dir').'/config/kunstmaancms/pageparts/' :
            $bundle->getPath().'/Resources/config/pageparts/'
        ;
        if (file_exists($dir) && is_dir($dir)) {
            $finder = new Finder();
            $finder->files()->in($dir)->depth('== 0');
            foreach ($finder as $file) {
                $info = $this->getSectionInfo($dir, $file->getFileName());

                if (is_array($info) && (is_null($context) || $info['context'] == $context)) {
                    $configs[$counter++] = $info;
                    if (array_key_exists($info['file'], $defaultSections)) {
                        unset($defaultSections[$info['file']]);
                    }
                }
            }
        }

        // Add the default sections
        foreach ($defaultSections as $file => $info) {
            if (is_null($context) || $info['context'] == $context) {
                $configs[$counter++] = $info;
            }
        }

        return $configs;
    }
protected function getAvailableSections(BundleInterface $bundle, $context = null, $defaultSections = [])
    {
        $configs = [];
        $counter = 1;

        // Get the available sections from disc
        $dir = Kernel::VERSION_ID >= 40000 ?
            $this->getContainer()->getParameter('kernel.project_dir').'/config/kunstmaancms/pageparts/' :
            $bundle->getPath().'/Resources/config/pageparts/'
        ;
        if (file_exists($dir) && is_dir($dir)) {
            $finder = new Finder();
            $finder->files()->in($dir)->depth('== 0');
            foreach ($finder as $file) {
                $info = $this->getSectionInfo($dir, $file->getFileName());

                if (is_array($info) && (is_null($context) || $info['context'] == $context)) {
                    $configs[$counter++] = $info;
                    if (array_key_exists($info['file'], $defaultSections)) {
                        unset($defaultSections[$info['file']]);
                    }
                }
            }
        }

        // Add the default sections
        foreach ($defaultSections as $file => $info) {
            if (is_null($context) || $info['context'] == $context) {
                $configs[$counter++] = $info;
            }
        }

        return $configs;
    }
protected function getAvailableSections ( BundleInterface $ bundle , $ context = null , $ defaultSections = [ ] ) { $ configs = [ ] ; $ counter = 1 ; // Get the available sections from disc $ dir = Kernel :: VERSION_ID >= 40000 ? $ this -> getContainer ( ) -> getParameter ( 'kernel.project_dir' ) . '/config/kunstmaancms/pageparts/' : $ bundle -> getPath ( ) . '/Resources/config/pageparts/' ; if ( file_exists ( $ dir ) && is_dir ( $ dir ) ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ dir ) -> depth ( '== 0' ) ; foreach ( $ finder as $ file ) { $ info = $ this -> getSectionInfo ( $ dir , $ file -> getFileName ( ) ) ; if ( is_array ( $ info ) && ( is_null ( $ context ) || $ info [ 'context' ] == $ context ) ) { $ configs [ $ counter ++ ] = $ info ; if ( array_key_exists ( $ info [ 'file' ] , $ defaultSections ) ) { unset ( $ defaultSections [ $ info [ 'file' ] ] ) ; } } } } // Add the default sections foreach ( $ defaultSections as $ file => $ info ) { if ( is_null ( $ context ) || $ info [ 'context' ] == $ context ) { $ configs [ $ counter ++ ] = $ info ; } } return $ configs ; }
Get an array with the available page sections. We also parse the yaml files to get more information about
the sections.

@param BundleInterface $bundle          The bundle for which we want to get the section configuration
@param string|null     $context         If provided, only return configurations with this context
@param array           $defaultSections The default section configurations that are always available

@return array
Get an array with the available page sections . We also parse the yaml files to get more information about the sections .