Airship\Cabin\Bridge\Landing\PageManager::processNewPage PHP Method

processNewPage() protected method

Create a new page in the current directory
protected processNewPage ( string $cabin, string $path, array $post = [] ) : boolean
$cabin string
$path string
$post array
return boolean
    protected function processNewPage(string $cabin, string $path, array $post = []) : bool
    {
        $expected = ['url', 'format', 'page_body', 'save_btn', 'metadata'];
        if (!\Airship\all_keys_exist($expected, $post)) {
            return false;
        }
        $url = $path . '/' . \str_replace('/', '_', $post['url']);
        if (!empty($post['ignore_collisions']) && $this->detectCollisions($url, $cabin)) {
            $this->storeLensVar('post_response', ['message' => \__('The given filename might conflict with another route in this Airship.'), 'status' => 'error']);
            return false;
        }
        $raw = $this->isSuperUser() ? !empty($post['raw']) : false;
        if ($this->can('publish')) {
            $publish = $post['save_btn'] === 'publish';
        } elseif ($this->can('create')) {
            $publish = false;
        } else {
            $this->storeLensVar('post_response', ['message' => \__('You do not have permission to create new pages.'), 'status' => 'error']);
            return false;
        }
        if ($this->pg->createPage($cabin, $path, $post, $publish, $raw)) {
            \Airship\redirect($this->airship_cabin_prefix . '/pages/' . $cabin, ['dir' => $path]);
        }
        return true;
    }