Creates a new story. This is an internal method and can not be
called from outside.

Check
ComStoriesControllerPermissionStory::canAdd

(non-PHPdoc)

@see ComBaseControllerService::_actionAdd()
508321
protected function _actionAdd(AnCommandContext $context)
    {
        $data = $context->data;

        return $this->getRepository()->create($data->toArray());
    }
503538
public function add()
    {
        $data = (array)$this->request->getData();
        if (!empty($data['group_id'])) {
            $data['owner_model'] = 'Groups';
            $data['owner_foreign_key'] = $data['group_id'];
        } elseif (!empty($data['user_id'])) {
            $data['owner_model'] = 'Users';
            $data['owner_foreign_key'] = $data['user_id'];
        } else {
            throw new InvalidArgumentException("Missing user or group!");
        }

        $data['creator'] = $this->Auth->user('id');
        $permission = $this->Permissions->newEntity();
        if ($this->request->is('post')) {
            $permission = $this->Permissions->patchEntity($permission, $data);
            $this->Permissions->save($permission) ?
                $this->Flash->success((string)__('The  permission has been saved.')) :
                $this->Flash->error((string)__('The  permission could not be saved. Please, try again.'));

            return $this->redirect($this->referer());
        }
        $users[''] = '';
        asort($users);
        $types[''] = '';
        foreach (PermissionsTable::ALLOWED_ACTIONS as $action) {
            $types[$action] = Inflector::humanize($action);
        }
        $this->set(compact('permission', 'users', 'types'));
        $this->set('_serialize', ['permission']);
    }
157211
protected function _actionAdd($context)
    {
        $entity = parent::_actionAdd($context);

        if ($entity->owner->isSubscribable()) {
            $notification = $this->createNotification(array(
                'name' => 'topic_add',
                'object' => $entity,
                'subscribers' => $entity->owner->subscriberIds->toArray(),
            ))->setType('post', array('new_post' => true));
        }

        return $entity;
    }
1110146
public function add() {
		$block = $this->Blocks->newEntity($this->request->data);
		if ($this->request->is('post')) {
			if ($this->Blocks->save($block)) {
				$this->Flash->success('The block has been saved.');
				return $this->redirect(['action' => 'index']);
			} else {
				$this->Flash->error('The block could not be saved. Please, try again.');
			}
		}
		$this->set(compact('block'));
	}
1100453
public function addAction()
    {
        $parent = $this->params()->fromRoute('parent');
        if (! is_numeric($parent)) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('The category location was not specified.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }
        try {
            $categoryId = $this->getCategoryService()->makeCategory($parent);
        } catch (RuntimeException $e) {
            $this->flashMessenger()->addMessage($e->getMessage());
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }
        return $this->redirect()->toRoute(
            'sc-admin/category/edit',
            ['id' => $categoryId]
        );
    }
1193908
public function addAction()
    {
        $isPosted = $this->request->getPost('doCreate');
        
        if (!$isPosted) {
            $this->response->redirect($this->request->getPost('redirect'));
        }

        $comment = [
            'content'   => $this->request->getPost('content'),
            'name'      => $this->request->getPost('name'),
            'web'       => $this->request->getPost('web'),
            'mail'      => $this->request->getPost('mail'),
            'timestamp' => time(),
            'ip'        => $this->request->getServer('REMOTE_ADDR'),
        ];

        $comments = new \Phpmvc\Comment\CommentsInSession();
        $comments->setDI($this->di);

        $comments->add($comment);

        $this->response->redirect($this->request->getPost('redirect'));
    }
811631
public function Add() {
		if(!$this->_Permission())
			return;

      $this->Title(T('Add Role'));

      // Use the edit form with no roleid specified.
      $this->View = 'Edit';
      $this->Edit();
   }
741981
public function add()
    {
        $this->loadModel('User.Roles');
        $role = $this->Roles->newEntity();

        if ($this->request->data()) {
            $role = $this->Roles->patchEntity($role, $this->request->data(), ['fieldList' => 'name']);
            if ($this->Roles->save($role)) {
                $this->Flash->success(__d('user', 'Role successfully created.'));
            } else {
                $this->Flash->danger(__d('user', 'Role could not be created.'));
            }
        }

        $this->title(__d('user', 'Define New Role'));
        $this->set(compact('role'));
        $this->Breadcrumb
            ->push('/admin/user/manage')
            ->push(__d('user', 'Roles'), ['plugin' => 'User', 'controller' => 'roles', 'action' => 'index'])
            ->push(__d('user', 'Add new role'), '');
    }
587812
public function add()
    {
        $post = $this->Posts->newEntity();

        if ($this->request->is('post')) {
            //Only admins and managers can add posts on behalf of other users
            if (!$this->Auth->isGroup(['admin', 'manager'])) {
                $this->request = $this->request->withData('user_id', $this->Auth->user('id'));
            }

            $post = $this->Posts->patchEntity($post, $this->request->getData());

            if ($this->Posts->save($post)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('post'));
    }
521022
public function add()
    {
        $group = $this->Groups->newEntity();
        if ($this->request->is('post')) {
            /**
             * @var array $data
             */
            $data = $this->request->getData();
            $group = $this->Groups->patchEntity($group, $data);
            if ($this->Groups->save($group)) {
                $this->Flash->success((string)__('The group has been saved.'));

                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error((string)__('The group could not be saved. Please, try again.'));
            }
        }
        $users = $this->Groups->Users->find('list', ['limit' => 500]);
        $remoteGroups = $this->Groups->getRemoteGroups();
        $this->set(compact('group', 'users', 'remoteGroups'));
        $this->set('_serialize', ['group']);
    }
359414
protected function addAddCart()
    {
        if (!$this->isError()) {
            $id = $this->cart->add($this->getSubmitted());
            if (empty($id)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }
            $this->line($id);
        }
    }
397161
public function createAction()
    {
        if ($this->enableScreens) {
            $edit = false;
            $org  = $this->getRespondent()->getOrganization();
            if (! $org) {
                $org = $this->currentOrganization;
            }

            if ($org) {
                $edit = $org->getRespondentEditScreen();
            }

            if (! $edit) {
                $group = $this->currentUser->getGroup();
                if ($group) {
                    $edit = $group->getRespondentEditScreen();
                }
            }

            if ($edit ) {
                if ($edit instanceof ProcessModelInterface) {
                    $edit->processModel($this->getModel());
                }

                // All are arrays, so easy to set
                $this->createParameters = $edit->getCreateParameters() + $this->createParameters;
                $editSnippets = $edit->getSnippets();
                if (false !== $editSnippets) {
                    $this->createEditSnippets = $editSnippets;
                }
            }
        }

        parent::createAction();
    }
1029504
public function add()
    {
        $group = $this->Groups->newEntity();
        if ($this->request->is('post')) {
            $group  = $this->Groups->patchEntity($group, $this->request->getData());
            $result = $this->Groups->save($group);
            if ($result) {
                $this->Flash->success(__d('community', 'The group has been saved.'));
                return $this->App->redirect([
                    'apply' => ['action' => 'edit', $result->id],
                ]);
            } else {
                $this->Flash->error(__d('community', 'The group could not be saved. Please, try again.'));
            }
        }

        $parents = $this->Groups->getTreeList();
        $this->set(compact('group', 'parents'));
        $this->set('page_title', __d('community', 'Add new group'));
    }
907204
public function newAction(): void
    {
        try {
            $maximumFileUploadSize = $this->getMaximumFileUploadSize();
        } catch (FilesException $e) {
            $maximumFileUploadSize = null;
        }

        $this->view->assignMultiple([
            'tags' => $this->tagRepository->findAll(),
            'assetCollections' => $this->assetCollectionRepository->findAll(),
            'maximumFileUploadSize' => $maximumFileUploadSize,
            'humanReadableMaximumFileUploadSize' => Files::bytesToSizeString($maximumFileUploadSize)
        ]);
    }
501531
public function addStories(Story ...$stories): void
    {
        \array_walk($stories, function ($story) {
            $this->stories[] = $story;
            $this->storyCount++;
        });
    }
772229
public function createAction()
    {
        $this->initializeScaffolding();
        $this->checkRequest();

        try {
            $this->beforeCreate();
            $this->scaffolding->doCreate($this->request->getPost());
            $this->flash->success($this->successMessage);
            return $this->afterCreate();
        } catch (Exception $e) {
            $this->flash->error($e->getMessage());
            $this->afterCreateException();
        }

        return $this->dispatcher->forward(['action' => 'new']);
    }
663758
public function add()
    {
        $this->loadModel('Content.ContentTypes');
        $this->loadModel('User.Roles');
        $type = $this->ContentTypes->newEntity();

        if ($this->request->data()) {
            $type = $this->ContentTypes->patchEntity($type, $this->request->data());
            $errors = $type->errors();
            $success = empty($errors);

            if ($success) {
                $success = $this->ContentTypes->save($type);
                if ($success) {
                    $this->Flash->success(__d('content', 'Content type created, now attach some fields.'));
                    $this->redirect(['plugin' => 'Content', 'controller' => 'fields', 'type' => $type->slug]);
                }
            }

            if (!$success) {
                $this->Flash->danger(__d('content', 'Content type could not be created, check your information.'));
            }
        }

        $roles = $this->Roles->find('list');
        $this->title(__d('content', 'Define New Content Type'));
        $this->set(compact('type', 'roles'));
        $this->set('languages', LocaleToolbox::languagesList());
        $this->Breadcrumb
            ->push('/admin/content/manage')
            ->push(__d('content', 'Content Types'), '/admin/content/types')
            ->push(__d('content', 'Creating Content Type'), '#');
    }