Returns a contentset options according to the layout zone.

@param \StdClass $zone

@return array
994
private function getZoneOptions(\stdClass $zone)
    {
        $options = array(
            'parameters' => array(
                'class' => array(
                    'type' => 'scalar',
                    'options' => array('default' => 'row'),
                ),
            ),
        );

        if (true === property_exists($zone, 'accept')
                && true === is_array($zone->accept)
                && 0 < count($zone->accept)
                && $zone->accept[0] != '') {
            $options['accept'] = $zone->accept;

            $func = function (&$item, $key) {
                        $item = ('' == $item) ? null : 'BackBee\ClassContent\\'.$item;
                    };

            array_walk($options['accept'], $func);
        }

        if (true === property_exists($zone, 'maxentry') && 0 < $zone->maxentry) {
            $options['maxentry'] = $zone->maxentry;
        }

        return $options;
    }
768392
public function serialize(Dropzone $dropzone)
    {
        return [
            'id' => $dropzone->getUuid(),
            'instruction' => $dropzone->getInstruction(),
            'parameters' => $this->serializeParameters($dropzone),
            'display' => $this->serializeDisplay($dropzone),
            'planning' => $this->serializePlanning($dropzone),
            'notifications' => $this->serializeNotifications($dropzone),
        ];
    }
324182
public static function getClassContentClassnamesFromDir($directory)
    {
        if (!is_dir($directory)) {
            return [];
        }

        return array_map(
            function ($path) use ($directory) {
                return str_replace(
                    [DIRECTORY_SEPARATOR, '\\\\'],
                    [NAMESPACE_SEPARATOR, NAMESPACE_SEPARATOR],
                    AbstractClassContent::CLASSCONTENT_BASE_NAMESPACE.str_replace([$directory, '.yml'], ['', ''], $path)
                );
            },
            File::getFilesRecursivelyByExtension($directory, 'yml')
        );
    }
370555
private static function getPadding(Zone $zone)
    {
        $name = $ttl = $type = 0;

        foreach ($zone as $resourceRecord) {
            $name = max($name, strlen($resourceRecord->getName()));
            $ttl = max($ttl, strlen($resourceRecord->getTtl()));
            $type = max($type, strlen($resourceRecord->getType()));
        }

        return [
            $name,
            $ttl,
            $type,
            $name + $ttl + $type + 6,
        ];
    }
1345746
public function getRecords($zone, $force = false)
    {
        if (!isset($this->zones[$zone])) {
            throw new \Exception("Unknown zone {$zone} requested, did you call getZones() first?");
        }
        if (!isset($this->zonerecords[$zone]) || $force) {
            $this->zonerecords[$zone] = $this->fetchRecords($zone);
        }

        return $this->zonerecords[$zone];
    }
1164304
public function isMainZone($content)
    {
        if ($content instanceof ContentSet) {
            $pages = $this->entityManager->getRepository('BackBee\ClassContent\ContentSet')->findPagesByContent($content);

            if (count($pages) > 0) {
                foreach($pages as $page) {
                    if ($page instanceof Page) {
                        if (false !== $index = $page->getContentSet()->indexOf($content, true)) {
                            $zone = $page->getLayout()->getZone($index);
                            if (is_a($zone, '\stdClass') && 1 === $zone->mainZone) {
                                return $page;
                            }
                        }
                    }
                }
            }
        }

        return null;
    }
70399
private function getContentTypes(Options $options): array
    {
        $allContentTypes = [];

        $groups = $this->contentTypeService->loadContentTypeGroups();
        $configuredGroups = $options['types'];

        foreach ($groups as $group) {
            $configuredGroups += [$group->identifier => true];
            if ($configuredGroups[$group->identifier] === false) {
                continue;
            }

            $contentTypes = $this->contentTypeService->loadContentTypes($group);
            foreach ($contentTypes as $contentType) {
                if (
                    is_array($configuredGroups[$group->identifier]) &&
                    !in_array($contentType->identifier, $configuredGroups[$group->identifier], true)
                ) {
                    continue;
                }

                $contentTypeName = $contentType->getName() ?? $contentType->identifier;
                $allContentTypes[$group->identifier][$contentTypeName] = $contentType->identifier;
            }
        }

        return $allContentTypes;
    }
1175542
public function blocks_for_region($region) {
        $blockcontents = $this->page->blocks->get_content_for_region($region, $this);
        $blocks = $this->page->blocks->get_blocks_for_region($region);
        $lastblock = null;
        $zones = array();
        foreach ($blocks as $block) {
            $zones[] = $block->title;
        }
        $output = '';

        foreach ($blockcontents as $bc) {
            if ($bc instanceof block_contents) {
                $output .= $this->block($bc, $region);
                $lastblock = $bc->title;
            } else if ($bc instanceof block_move_target) {
                $output .= $this->block_move_target($bc, $zones, $lastblock, $region);
            } else {
                throw new coding_exception('Unexpected type of thing (' . get_class($bc) . ') found in list of block contents.');
            }
        }
        return $output;
    }
526777
public static function getSettings()
    {
        $ret = parent::getSettings();
        $ret['viewCache'] = true;
        $ret['contentSender'] = 'Kwf_Component_Abstract_ContentSender_Default';
        $ret['layoutClass'] = 'Kwf_Component_Layout_Default';
        $ret['plugins'] = array();
        return $ret;
    }
571600
public function getInheritedZones($uidOnly = false)
    {
        $inheritedZones = array();
        $uidOnly = (isset($uidOnly) && is_bool($uidOnly)) ? $uidOnly : false;
        if (null !== $this->getParent()) {
            $parentZones = $this->getParent()->getContentSet();
            $cPageRootZoneContainer = $this->getContentSet();
            foreach ($cPageRootZoneContainer as $currentpageRootZone) {
                $result = $parentZones->indexOfByUid($currentpageRootZone);
                if ($result) {
                    $inheritedZones[$currentpageRootZone->getUid()] = $currentpageRootZone;
                }
            }
            if ($uidOnly) {
                $inheritedZones = array_keys($inheritedZones);
            }
        }

        return $inheritedZones;
    }
998617
public function setZones(ZoneCollection $components)
    {
        return parent::setZones($components->map(function (Zone $zone) {
            return $zone->setTemplate($this);
        }));
    }
999031
protected function getZonesByTemplate($template)
    {
        $zones = $this->templates[$template]['zones'];

        foreach ($zones as $key => $zone) {
            $temp = array_map([$this, 'jsString'], $zone['restricted_types']);
            $zones[$key]['restricted_types'] = '['.implode(',', $temp).']';

            $zones[$key]['restricted_types'] = json_encode($zone['restricted_types']);
        }

        return $zones;
    }
551248
protected function fetchRecords($zone)
    {
        if (!$zone) {
            throw new \Exception('fetchRecords called with blank zone');
        }
        $uri = $this->baseuri.'/accounts/'.$this->account.'/zones/'.$zone.'/rr';
        $result = $this->httpGet($uri);

        return $result;
    }
1337159
public function getPageTypes($dc)
    {
        $options = [];
        $rootAllowed = true;

        if ($dc->activeRecord->pid > 0) {
            $rootAllowed = false;
            $parentType = $this->db->fetchColumn('SELECT type FROM tl_page WHERE id=?', [$dc->activeRecord->pid]);

            // Allow root in second level if the parent is folder
            if ($parentType === 'folder') {
                $rootAllowed = true;
            }
        }

        foreach (array_keys($GLOBALS['TL_PTY']) as $pty) {
            // Root pages are allowed on the first level only (see #6360)
            if ($pty === 'root' && !$rootAllowed) {
                continue;
            }

            // Allow the currently selected option and anything the user has access to
            if ($pty === $dc->value || $this->user->hasAccess($pty, 'alpty')) {
                $options[] = $pty;
            }
        }

        return $options;
    }
426430
private function get_templates($directory) {
		$templates = [];
		foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::LEAVES_ONLY) as $file)
		{
		    if ($file->isFile() === false) {
		        continue;
		    }

			if ($file->getExtension() != 'twig' && $file->getExtension() != 'tpl') {
				continue;
			}

		    $resource = str_replace($directory, '', $file);
		    $templates[] = $resource;
		}

		return $templates;
	}
1215899
private function _getCustomConfigOptions(string $dir): array
    {
        $options = ['' => Craft::t('redactor', 'Default')];
        $path = Craft::$app->getPath()->getConfigPath().DIRECTORY_SEPARATOR.$dir;

        if (is_dir($path)) {
            $files = FileHelper::findFiles($path, [
                'only' => ['*.json'],
                'recursive' => false
            ]);

            foreach ($files as $file) {
                $options[pathinfo($file, PATHINFO_BASENAME)] = pathinfo($file, PATHINFO_FILENAME);
            }
        }

        return $options;
    }
638958
public function getLayouts($theme, $directory = null)
    {
        if (null === $this->layouts) {
            $this->layouts = [];
            foreach ($this->themeManager->getThemes() as $id => $theme2) {
                if ($theme === $id) {
                    foreach ($theme2->getPaths() as $resource) {
                        $path = $this->themeManager->locateResource($resource) . $directory;
                        if (is_dir($path)) {
                            $finder = new Finder();
                            $finder->files()->in($path)->depth(0)->name('*.html.twig');

                            /** @var \Symfony\Component\Finder\SplFileInfo $file */
                            foreach ($finder as $file) {
                                $this->layouts[] = $file->getRelativePathname();
                            }
                        }
                    }
                }
            }
        }

        return $this->layouts;
    }