isSnippetValid example

if (\array_key_exists('namespace', $snippets)) {
            $snippets = [$snippets];
            $isSingleSnippet = true;
        }

        foreach ($snippets as $params) {
            $snippet = new Snippet();
            $snippet->fromArray($params);
            $snippet->setDirty(true);

            if (!$this->isSnippetValid($snippet)) {
                $result[$snippet->getId()] = $params;
                continue;
            }

            try {
                $this->get('models')->persist($snippet);
                $this->get('models')->flush();
            } catch (Exception $e) {
                $this->View()->assign(['success' => false, 'message' => $e->getMessage()]);

                return;
            }
Home | Imprint | This part of the site doesn't use cookies.