Load layout options

@param string $methodCalled
@return Nexcessnet_Turpentine_Block_Core_Messages
11191
protected function _handleDirectCall($methodCalled) {
        // this doesn't actually do anything because _real_toHtml() won't be
        // called in this request context (unless the flash message isn't
        // actually supposed to be ajax/esi'd in)
        $this->_directCall = $methodCalled;
        if ($this->_fixMessages()) {
            $layout = $this->getLayout();
            $layoutUpdate = $layout->getUpdate()->load('default');
            if (Mage::app()->useCache('layout')) {
                // this is skipped in the layout update load() if the "layout"
                // cache is enabled, which seems to cause the esi layout stuff
                // to not load, so we manually do it here
                foreach ($layoutUpdate->getHandles() as $handle) {
                    $layoutUpdate->merge($handle);
                }
            }
            $layout->generateXml();
            $layoutShim = Mage::getSingleton('turpentine/shim_mage_core_layout');
            foreach ($layout->getNode()->xpath(
                    sprintf('//reference[@name=\'%s\']/action',
                        $this->getNameInLayout()) ) as $node) {
                $layoutShim->shim_generateAction($node);
            }
        }
        return $this;
    }
844069
protected function getAdditionAdapterOptions()
    {
        /** @var \common_ext_ExtensionsManager $extManager */
        $extManager = ServiceManager::getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID);
        $taoTestTaker = $extManager->getExtensionById('taoTestTaker');
        $config = $taoTestTaker->getConfig('csvImporterCallbacks');

        if (empty($config['callbacks'])){
            $returnValue = array(
                'callbacks' => array(
                    '*' => array('trim'),
                    GenerisRdf::PROPERTY_USER_PASSWORD => array('oat\taoTestTaker\models\CsvImporter::taoSubjectsPasswordEncode')
                )
            );
        } else {
            $returnValue = array(
                'callbacks' => $config['callbacks']
            );
        }

        return $returnValue;
    }
518331
protected function getFactoryCallsNumber(MethodNode $method)
    {
        $factoryCallNumber = 0;
        $primaryPrefixes = $method->findChildrenOfType('MemberPrimaryPrefix');

        foreach ($primaryPrefixes as $key => $primaryPrefix) {
            if (!$this->isChildNameEqual($primaryPrefix, 0, static::PSEUDO_VAR_THIS)) {
                continue;
            }

            if (!$this->isChildNameEqual($primaryPrefix, 1, static::OBJECT_OPERATOR)) {
                continue;
            }

            if (!isset($primaryPrefixes[$key + 1])) {
                continue;
            }

            if ($this->isChildNameEqual($primaryPrefixes[$key + 1], 0, static::GET_FACTORY_METHOD)) {
                $factoryCallNumber++;
            }
        }

        return $factoryCallNumber;
    }
968357
public function options($url, $callable, $name = null, $templatePath = null)
    {
        $this->multiple([\Parable\Http\Request::METHOD_OPTIONS], $url, $callable, $name, $templatePath);
        return $this;
    }
848779
protected function asyncBuild($method, $slugLayouts)
    {
        $this->arguments = $this->request->json()->all();

        $this->reflectionParams($method);
        $query = call_user_func_array([$this, $method], $this->arguments);
        $post = new Repository($query);

        foreach ($this->layout() as $layout) {

            /** @var \Orchid\Screen\Layouts\Base|string $layout */
            $layout = is_object($layout) ? $layout : new $layout();

            if ($layout->getSlug() === $slugLayouts) {
                $layout->async = true;

                return $layout->build($post);
            }
        }
    }
1092928
public function addCallableHandle()
    {
        if ($this->handler) {
            throw new AlreadyBuildedException('The handler already builded.');
        }

        $loader = new CallableLoader();
        $resolver = new CallableResolver();

        $this->addCallableResolver($resolver);
        $this->addActionLoader($loader);

        return $loader;
    }
768067
public function getLayoutTemplate(string $context = ViewInterface::CONTEXT_DEFAULT): ?string
    {
        $layoutView = $this->buildLayoutView($context);
        if (!$layoutView instanceof LayoutViewInterface) {
            return $this->getPageLayoutTemplate();
        }

        return $layoutView->getTemplate();
    }
209564
public static function addMethod($methodName, $methodCallable)
    {
        if (!is_callable($methodCallable)) {
            throw new InvalidArgumentException('Second param must be callable');
        }
        self::$methods[$methodName] = \Closure::bind($methodCallable, Mailer::instance(), get_class());
    }
1123775
protected function parse($callable)
    {
        list($callable, $args) = $this->parseArgs($callable);

        if ($this->isClassMethod($callable)) {
            $callable = $this->parseClassMethod($callable);
        } elseif ($this->isMutatorMethod($callable)) {
            $callable = [$this, $callable];
        } elseif (!function_exists($callable)) {
            throw new InvalidCallableException("Function [{$callable}] not found.");
        }

        return [$callable, $args];
    }
832297
public function loadMessages($blockName) {
        $messages = $this->getMessages();
        if (is_array(@$messages[$blockName])) {
            return $messages[$blockName];
        } else {
            return array();
        }
    }
604377
public function loadLayoutsData(array $layoutIds, bool $includeDrafts): array
    {
        $query = $this->getLayoutSelectQuery();

        if ($includeDrafts) {
            $query->leftJoin(
                'l',
                'ngbm_layout',
                'l2',
                $query->expr()->andX(
                    $query->expr()->eq('l.id', 'l2.id'),
                    $query->expr()->eq('l2.status', ':status')
                )
            );
        }

        $query->where(
            $query->expr()->in('l.id', [':layout_ids'])
        );

        $statusExpr = $query->expr()->eq('l.status', ':status');
        if ($includeDrafts) {
            $statusExpr = $query->expr()->orX(
                $statusExpr,
                $query->expr()->isNull('l2.id')
            );
        }

        $query->andWhere($statusExpr);

        $query->setParameter('layout_ids', $layoutIds, Connection::PARAM_INT_ARRAY);
        $query->setParameter('status', Value::STATUS_PUBLISHED, Type::INTEGER);

        $query->orderBy('l.name', 'ASC');

        return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
    }
231794
protected function loadLayoutSetup($pageId)
    {
        // Load page TSconfig.
        if (\TYPO3_MODE === 'FE') {
            $pageTSconfig = $GLOBALS['TSFE']->getPagesTSconfig();
        } else {
            $pageTSconfig = BackendUtility::getPagesTSconfig($pageId);
        }
        $excludeLayoutIds = !empty($pageTSconfig['tx_gridelements.']['excludeLayoutIds'])
            ? array_flip(GeneralUtility::trimExplode(',', $pageTSconfig['tx_gridelements.']['excludeLayoutIds']))
            : [];

        $overruleRecords = isset($pageTSconfig['tx_gridelements.']['overruleRecords'])
            && (int)$pageTSconfig['tx_gridelements.']['overruleRecords'] === 1;

        $gridLayoutConfig = [];
        if (!empty($pageTSconfig['tx_gridelements.']['setup.'])) {
            foreach ($pageTSconfig['tx_gridelements.']['setup.'] as $layoutId => $item) {
                // remove tailing dot of layout ID
                $layoutId = rtrim($layoutId, '.');

                // Continue if layout is excluded.
                if (isset($excludeLayoutIds[$layoutId])) {
                    continue;
                }

                // Parse icon path for records.
                if ($item['icon']) {
                    $icons = explode(',', $item['icon']);
                    foreach ($icons as &$icon) {
                        $icon = trim($icon);
                        if (strpos($icon, 'EXT:') === 0) {
                            $icon = str_replace(PATH_site, '../', GeneralUtility::getFileAbsFileName($icon));
                        }
                    }
                    $item['icon'] = $icons;
                }

                // remove tailing dot of config
                if (isset($item['config.'])) {
                    $item['config'] = $item['config.'];
                    unset($item['config.']);
                    if (isset($item['backend_layout.'])) {
                        $item['config'] = $item['backend_layout.'];
                    }
                    unset($item['backend_layout.']);
                }

                // Change topLevelLayout to top_level_layout.
                $item['top_level_layout'] = $item['topLevelLayout'];
                unset($item['topLevelLayout']);

                // Change flexformDS to pi_flexform_ds.
                $item['pi_flexform_ds'] = $item['flexformDS'];
                unset($item['flexformDS']);

                $gridLayoutConfig[$layoutId] = $item;
            }
        }

        $storagePid = isset($pageTSconfig['TCEFORM.']['pages.']['_STORAGE_PID'])
            ? (int)$pageTSconfig['TCEFORM.']['pages.']['_STORAGE_PID']
            : 0;
        $pageTSconfigId = isset($pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID'])
            ? implode(',', GeneralUtility::intExplode(
                ',',
                $pageTSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['PAGE_TSCONFIG_ID']
            ))
            : 0;

        // Load records.
        $queryBuilder = $this->getQueryBuilder();
        $layoutQuery = $queryBuilder
            ->select('*')
            ->from('tx_gridelements_backend_layout')
            ->where(
                $queryBuilder->expr()->orX(
                    $queryBuilder->expr()->andX(
                        $queryBuilder->expr()->comparison($pageTSconfigId, '=', 0),
                        $queryBuilder->expr()->comparison($storagePid, '=', 0)
                    ),
                    $queryBuilder->expr()->orX(
                        $queryBuilder->expr()->eq(
                            'pid',
                            $queryBuilder->createNamedParameter((int)$pageTSconfigId, \PDO::PARAM_INT)
                        ),
                        $queryBuilder->expr()->eq(
                            'pid',
                            $queryBuilder->createNamedParameter((int)$storagePid, \PDO::PARAM_INT)
                        )
                    ),
                    $queryBuilder->expr()->andX(
                        $queryBuilder->expr()->comparison($pageTSconfigId, '=', 0),
                        $queryBuilder->expr()->eq(
                            'pid',
                            $queryBuilder->createNamedParameter((int)$pageId, \PDO::PARAM_INT)
                        )
                    )
                )
            )
            ->orderBy('sorting', 'ASC');

        $layoutItems = $layoutQuery->execute()->fetchAll();

        $gridLayoutRecords = [];

        foreach ($layoutItems as $item) {
            if (isset($item['alias']) && (string)$item['alias'] !== '') {
                $layoutId = $item['alias'];
            } else {
                $layoutId = $item['uid'];
            }
            // Continue if layout is excluded.
            if (isset($excludeLayoutIds[$layoutId])) {
                continue;
            }

            // Prepend icon path for records.
            if ($item['icon']) {
                $icons = explode(',', $item['icon']);
                foreach ($icons as &$icon) {
                    $icon = '../' . $GLOBALS['TCA']['tx_gridelements_backend_layout']['ctrl']['selicon_field_path'] . '/' . htmlspecialchars(trim($icon));
                }
                $item['icon'] = $icons;
            }

            // parse config
            if ($item['config']) {
                $parser = GeneralUtility::makeInstance(TypoScriptParser::class);
                $parser->parse($parser->checkIncludeLines($item['config']));
                if (isset($parser->setup['backend_layout.'])) {
                    $item['config'] = $parser->setup['backend_layout.'];
                }
            }

            $gridLayoutRecords[$layoutId] = $item;
        }

        if ($overruleRecords === true) {
            ArrayUtility::mergeRecursiveWithOverrule($gridLayoutRecords, $gridLayoutConfig, true, false);
            $this->setLayoutSetup($gridLayoutRecords);
        } else {
            ArrayUtility::mergeRecursiveWithOverrule($gridLayoutConfig, $gridLayoutRecords, true, false);
            $this->setLayoutSetup($gridLayoutConfig);
        }
    }
204157
public function options($callable = null)
    {
        if (null === $callable) {
            if (is_callable($this->options)) {
                return call_user_func($this->options);
            }

            $rep = new $this->options;

            return $rep->options();
        }

        $this->options = $callable;

        return $this;
    }
69813
private function explodeCallable(callable $method)
    {
        if (is_array($method)) {
            return $method;
        }

        if (is_string($method)) {
            return explode('::', $method);
        }

        return [$method];
    }
562038
protected function resolveCallableArguments(
        callable $callable,
        array $providedArguments
    )/*# : array */ {
        // object with __invoke defined or \Closure
        if (is_object($callable) && !$callable instanceof \Closure) {
            $reflector = new \ReflectionClass($callable);
            $method = $reflector->getMethod('__invoke');

        // array-like callable
        } elseif (is_array($callable)) {
            $reflector = new \ReflectionClass($callable[0]);
            $method = $reflector->getMethod($callable[1]);

        // simple function
        } else {
            $method = new \ReflectionFunction($callable);
        }

        // dereference the provided arguments
        $this->dereferenceArray($providedArguments);

        // match provided arguments with method parameter definitions
        return $this->matchMethodArguments(
            $method->getParameters(),
            $providedArguments
        );
    }
647558
protected function getCallback()
    {
        if (!array_key_exists($this->logName, self::$loggers)) {
            $c = new LoggingClient($this->getUnwrappedClientConfig());
            self::$loggers[$this->logName] = $c->logger($this->logName);
        }
        return [self::$loggers[$this->logName], $this->batchMethod];
    }
194130
public function loadLayoutZonesData(Layout $layout): array
    {
        $query = $this->getZoneSelectQuery();
        $query->where(
            $query->expr()->eq('layout_id', ':layout_id')
        )
        ->setParameter('layout_id', $layout->id, Type::INTEGER)
        ->orderBy('identifier', 'ASC');

        $this->applyStatusCondition($query, $layout->status);

        return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
    }