Validates the layout styles.

@param array $layout
765907
protected function validateLayoutStyles(array $layout)
    {
        if (isset($layout[static::PADDING_TOP])
            && (0 > $layout[static::PADDING_TOP] || 300 < $layout[static::PADDING_TOP])
        ) {
            throw new InvalidArgumentException('Invalid layout padding top');
        }

        if (isset($layout[static::PADDING_BOTTOM])
            && (0 > $layout[static::PADDING_BOTTOM] || 300 < $layout[static::PADDING_BOTTOM])
        ) {
            throw new InvalidArgumentException('Invalid layout padding bottom');
        }
    }
1089983
private function processZones(Layout $layout, array $layoutData): void
    {
        foreach ($layout->getZones() as $zone) {
            if (!array_key_exists($zone->getIdentifier(), $layoutData['zones'])) {
                throw new RuntimeException(
                    sprintf('Missing data for zone "%s"', $zone->getIdentifier())
                );
            }

            $this->processZone($zone, $layoutData['zones'][$zone->getIdentifier()]);
        }
    }
1345868
protected function getLayoutOptions($layout)
    {
        // If passed a layout, use that for any request.
        if (! is_null($layout)) {
            return [
                'default' => $layout,
                'ajax'    => $layout,
            ];
        }

        // If a set of layout options is defined, use those.
        if (isset($this->layoutOptions)) {
            return $this->layoutOptions;
        }

        // Use nothing.
        return null;
    }
1360883
public function validateLayoutUpdateStruct(LayoutUpdateStruct $layoutUpdateStruct): void
    {
        $layoutName = is_string($layoutUpdateStruct->name) ?
            trim($layoutUpdateStruct->name) :
            $layoutUpdateStruct->name;

        if ($layoutName !== null) {
            $this->validate(
                $layoutName,
                [
                    new Constraints\NotBlank(),
                    new Constraints\Type(['type' => 'string']),
                ],
                'name'
            );
        }

        if ($layoutUpdateStruct->description !== null) {
            $this->validate(
                $layoutUpdateStruct->description,
                [
                    new Constraints\Type(['type' => 'string']),
                ],
                'description'
            );
        }
    }
473643
protected function _initLayout($layout)
    {
        list($theme, ) = namespaceSplit(get_class($this));
        $layoutClass = $theme . '\\View\\Layout\\' . $layout . 'Layout';

        try {
            /** @var Layout $layout */
            $layout = new $layoutClass();
        } catch (Exception $e) {
            throw new Exception(__d('wasabi_cms', 'The layout "{0}" could not be instatiated. Check the namespace and file location.', $layoutClass));
        }

        $this->_layouts[$layout->id()] = $layout;
    }
758668
public boolean applyLayout(Layout layout) {
        boolean applied = false;
        if (layout != null && isValidLayout(layout)) {
            Layout defaultLayout  = getDefaultLayout();
            if (layout != defaultLayout) {
                mLayouts.remove(defaultLayout);
            }
            if(mLayouts.add(layout)) {
                layout.onLayoutApplied(this, mViewPort);
                applied = true;
            }
        }
        return applied;
    }
1249060
protected function validateBlockLayout(array $data)
    {
        foreach (array_keys(static::getDevices()) as $device) {
            // If layout set for this device
            if (!isset($data[$device])) {
                continue;
            }

            $size = isset($data[$device][static::SIZE]) ? $data[$device][static::SIZE] : 12;
            $offset = isset($data[$device][static::OFFSET]) ? $data[$device][static::OFFSET] : 0;

            // Validate size
            if (1 > $size || $size > 12) {
                throw new InvalidArgumentException('Invalid layout size');
            }

            // Validate offset
            if (0 > $offset || $offset > 11) {
                throw new InvalidArgumentException('Invalid layout offset');
            }

            // Validate sum
            if (12 < ($size + $offset)) {
                throw new InvalidArgumentException('Invalid block layout size/offset');
            }
        }
    }
382363
public function validate(array $fields)
    {
        $this->flashInput($fields);

        $rules = $this->getValidationRules($fields);

        $validator = $this->getValidatorInstance($rules);

        if($validator->fails()){

            $this->failedValidation($validator);
        }
    }
1066543
public function interpretLayout(array $layout)
    {
        $this->assignedModuleKeys = [];

        $modulePresences = $this->modulesInterpreter->interpret();

        $layout = $this->mergeModulePresencesIntoLayout($this->interpretNestedGroupLayout($layout), $modulePresences);

        $layout = new LayoutData([
            'layout'      => $layout,
            'alternative' => $modulePresences->alternative()->toarray(),
        ]);

        $this->filterEmptyGroups($layout);

        return $layout;
    }
973795
private void validateAttributes() {
    if (content == null) {
      throw new NullContentException("RendererBuilder needs content to create Renderer instances");
    }

    if (parent == null) {
      throw new NullParentException("RendererBuilder needs a parent to inflate Renderer instances");
    }

    if (layoutInflater == null) {
      throw new NullLayoutInflaterException(
          "RendererBuilder needs a LayoutInflater to inflate Renderer instances");
    }
  }
174941
public function validate($value)
    {
        $validator = new Validator();
        $jsonSchema = $this->json;

        $validator->check($value, $jsonSchema);

        if (!$validator->isValid()) {
            foreach ($validator->getErrors() as $error) {
                $this->errors[] = new TypeValidationError($error['property'], $error['constraint']);
            }
        }
    }
283749
public function validate($value)
    {
        if (!$value instanceof DOMDocument) {
            $this->errors[] = TypeValidationError::xmlValidationFailed('Expected value of type DOMDocument');

            return;
        }

        $originalErrorLevel = \libxml_use_internal_errors(true);
        $value->schemaValidateSource($this->xml);
        $errors = \libxml_get_errors();
        \libxml_clear_errors();
        if ($errors) {
            foreach ($errors as $error) {
                $this->errors[] = TypeValidationError::xmlValidationFailed($error->message);
            }

            return;
        }

        \libxml_use_internal_errors($originalErrorLevel);
    }
1010694
public function validate(array $elements = null)
    {
        $return = true;
        $arElements = $this->getFieldsToValidate($elements);
        foreach ($arElements as $element) {
            if ($this->isValidationNeeded($element, $elements)) {
                $res = $this->validateElement($element);
                if ($res === false) {
                    $return = false;
                }
            }
        }

        return $return;
    }
1313995
public void setLayout(java.lang.String layout) {
        getStateHelper().put(PropertyKeys.layout, layout);
    }
30069
public function setStyles(array $styles)
    {
        $this->styles = [];

        foreach ($styles as $style) {
            $this->addStyle($style);
        }
    }
58347
function GrantAddContentToLayout(Layout $layout)
    {
        //dummy content for evaluation
        $content = new Content();
        $content->SetUserGroup($layout->GetUserGroup());
        $layoutRights = $layout->GetUserGroupRights();
        if ($layoutRights)
        {
            $content->SetUserGroupRights($layoutRights->GetContentRights());
        }
        return $this->Grant(BackendAction::Create(), $content);
    }
1220417
private function validateLayoutTypes(array $layoutTypes, array $blockDefinitions): void
    {
        foreach ($layoutTypes as $layoutType => $layoutTypeConfig) {
            foreach ($layoutTypeConfig['zones'] as $zoneConfig) {
                foreach ($zoneConfig['allowed_block_definitions'] as $blockDefinition) {
                    if (!isset($blockDefinitions[$blockDefinition])) {
                        throw new RuntimeException(
                            sprintf(
                                'Block definition "%s" used in "%s" layout type does not exist.',
                                $blockDefinition,
                                $layoutType
                            )
                        );
                    }
                }
            }
        }
    }