Create action (view|controller).
489879
protected function createAction()
    {
        if (strtolower($this->option('type')) == 'regular' || $this->option('type') == null) {
            return $this->createView();
        }
        if (strtolower($this->option('type')) == 'controller') {
            return $this->createController();
        }
        return $this->createResourceController();
    }
644077
protected function createView($action='view')
    {
        $controller = \Staq\Util::getStackSubQuery($this);
        $view = (new \Stack\View)->byName($action, $controller);
        $view['controller'] = $controller;
        $view['controllerAction'] = $action;
        return $view;
    }
1048719
def createAction(self, parent=None, name=''):
        
        action = super(UiLoader, self).createAction(parent, name)
        if not action.parent():
            action.setParent(self._baseinstance)
        setattr(self._baseinstance, name, action)
        return action
634108
def create(self, **kwargs):
        

        return super(PostController, self).create(**self._with_markdown(kwargs))
915245
private function runAction()
    {
        // Get URL
        $url = $this->request->url();

        // Get route action
        $action = $this->router->getAction($url);

        // Perform the filter
        if ($action['filter']) {
            $filter = $this->router->performFilter($action['filter']);
        }

        // Check if the controller exists
        if (!isset($action) || !is_string($action['class']) || !class_exists($action['class'])) {
            throw new \Exception('Controller not found', 404);
        }

        // Create the required controller
        $controller = $this->make($action['class']);

        // Execute the required method and return the response
        return $this->response->output(call_user_func_array([$controller, $action['method']], $action['params']? : []));
    }
766838
public static IAction createAction(String label, String script) {
        return new Action(script, label, script);
    }
178585
def _create_action(factory_self, action_model, resource_name,
                       service_context, is_load=False):
        
        # Create the action in in this closure but before the ``do_action``
        # method below is invoked, which allows instances of the resource
        # to share the ServiceAction instance.
        action = AIOServiceAction(
            action_model, factory=factory_self,
            service_context=service_context
        )

        # A resource's ``load`` method is special because it sets
        # values on the resource instead of returning the response.
        if is_load:
            # We need a new method here because we want access to the
            # instance via ``self``.
            async def do_action(self, *args, **kwargs):
                # response = action(self, *args, **kwargs)
                response = await action.async_call(self, *args, **kwargs)
                self.meta.data = response

            # Create the docstring for the load/reload mehtods.
            lazy_docstring = docstring.LoadReloadDocstring(
                action_name=action_model.name,
                resource_name=resource_name,
                event_emitter=factory_self._emitter,
                load_model=action_model,
                service_model=service_context.service_model,
                include_signature=False
            )
        else:
            # We need a new method here because we want access to the
            # instance via ``self``.
            async def do_action(self, *args, **kwargs):
                response = await action.async_call(self, *args, **kwargs)

                if hasattr(self, 'load'):
                    # Clear cached data. It will be reloaded the next
                    # time that an attribute is accessed.
                    # TODO: Make this configurable in the future?
                    self.meta.data = None

                return response

            lazy_docstring = docstring.ActionDocstring(
                resource_name=resource_name,
                event_emitter=factory_self._emitter,
                action_model=action_model,
                service_model=service_context.service_model,
                include_signature=False
            )

        do_action.__name__ = str(action_model.name)
        do_action.__doc__ = lazy_docstring
        return do_action
1199915
def make_controller(cls, config, session, left_menu_items=None):
        """"""
        m = config.model
        Controller = config.defaultCrudRestController

        class ModelController(Controller):
            model        = m
            table        = config.table_type(session)
            table_filler = config.table_filler_type(session)
            new_form     = config.new_form_type(session)
            new_filler   = config.new_filler_type(session)
            edit_form    = config.edit_form_type(session)
            edit_filler  = config.edit_filler_type(session)
            allow_only   = config.allow_only

            if hasattr(config.layout, 'crud_resources'):
                resources = config.layout.crud_resources

            def _before(self, *args, **kw):
                super(self.__class__, self)._before(*args, **kw)

                tmpl_context.make_pager_args = make_pager_args

                if request.response_type not in ('application/json',):
                    default_renderer = AdminController._get_default_renderer()
                    for action in ('get_all', 'new', 'edit'):
                        for template in config.layout.crud_templates.get(action, []):
                            if template.startswith(default_renderer):
                                override_template(getattr(self, action), template)

        return ModelController(session, left_menu_items)
1114045
public function createAction()
    {
        $form = $this->createForm();
        $submit = new Submit();
        $lng = \Cmf\Language\Factory::get($this);
        $submit->setValue($lng['create']);
        $form->setElement($submit);

        $response = [
            'form' => $form,
            'actionLinks' => ActionLinkFactory::createLinks($this->getActionLinkConfig()),
        ];

        if ($form->isSubmitted()) {
            $form->getValuesFromRequest();
            if ($form->validate()) {
                $entity = new $this->entityName();
                $this->fillEntityFromForm($entity, $form);
                $this->fillEntityForCreate($entity);

                try {
                    $em = $this->getEntityManager();
                    $em->persist($entity);
                    $em->flush();
                    $result = true;
                } catch (\Exception $e) {
                    $lng = \Cmf\Language\Factory::get($this);
                    $form->getMessages()->setItem(new Message($lng[self::ERR_DB]));
                    $result = false;
                }
                if ($result) {
                    $response = new PostRedirectGet($this);
                    $response->setRedirectPath([
                        'module' => $this->request->getModuleName(),
                        'controller' => $this->getControllerName(),
                        'action' => 'creationOk',
                    ]);
                }
            }
        }

        return $response;
    }
546851
public function createAction()
    {
        if ($this->request->isPost()) {

            $profile = new Profiles([
                'name' => $this->request->getPost('name', 'striptags'),
                'active' => $this->request->getPost('active')
            ]);

            if (!$profile->save()) {
                $this->flash->error($profile->getMessages());
            } else {
                $this->flash->success("Profile was created successfully");
            }

            Tag::resetInput();
        }

        $this->view->form = new ProfilesForm(null);
    }
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']);
    }
551239
private function createController(): void
    {
        $aFields  = $this->getArguments();
        $aCreated = [];

        try {

            $aClasses = array_filter(explode(',', $aFields['CLASS_NAME']));

            foreach ($aClasses as $sClass) {

                $aFields['CLASS_NAME'] = $sClass;
                $this->oOutput->write('Creating controller <comment>' . $sClass . '</comment>... ');

                //  Check for existing controller
                $sPath = static::CONTROLLER_PATH . $sClass . '.php';
                if (file_exists($sPath)) {
                    throw new ControllerExistsException(
                        'Controller "' . $sClass . '" exists already at path "' . $sPath . '"'
                    );
                }

                $this->createFile($sPath, $this->getResource('template/controller.php', $aFields));
                $aCreated[] = $sPath;
                $this->oOutput->writeln('<info>done!</info>');
            }

        } catch (\Exception $e) {
            $this->oOutput->writeln('<error>failed!</error>');
            //  Clean up created models
            if (!empty($aCreated)) {
                $this->oOutput->writeln('<error>Cleaning up - removing newly created controllers</error>');
                foreach ($aCreated as $sPath) {
                    @unlink($sPath);
                }
            }
            throw $e;
        }
    }
846121
private function createView(): void
    {
        $path = $this->getViewPath();

        if ($this->files->exists($path)) {
            $this->error($this->qualifyClass($this->getNameInput()).'View.blade.php - Already exists! (@_@)');

            return;
        }

        $this->files->put($path, $this->getViewStub());

        $this->info(' - '.$this->qualifyClass($this->getNameInput()).'View.blade.php - was created. (^_^)');

        $this->printStarUs();
    }
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();
    }
575001
public function performAction($controller, $action) {
		// Replace namespace with directory separator
		$controllerFile = str_replace("\\", DIRECTORY_SEPARATOR, $controller);

		// Check if controller exists
		if ( false == is_file( $controllerLocation = APP . 'Controllers/' . $controllerFile . '.php' ) )
			throw new ControllerNotFoundException();

		// Include and init the controller
		$controllerClass = "\\Application\\Controllers\\{$controller}";
		$controllerObj = new $controllerClass($this);

		// Check if the action exists
		if ( 'Errors' != $controller && false == method_exists($controllerObj, $action.= "Action" ) )
			throw new ActionNotFoundException();
		// Check if the error display action exists
		elseif ( $controller == $this->defaultRoute['_controller'] && false == method_exists($controllerObj, $action = "display" . $action ) )
			throw new ErrorActionNotFoundException();

		// Run the action
		$data = $controllerObj->{$action}();

		// Data fetching
		if ( false === $controllerObj->__returnActionPerformed ):
			// Format returned data
			if ( false == is_array( $data ) )
				$data = (array) $data;

			// Start reflection for data loading
			$ref = new \ReflectionObject($controllerObj);
			$properties = $ref->getProperties(\ReflectionProperty::IS_PUBLIC);
			$controllerData = array();

			// Get public data
			foreach ( $properties as $property ):
				// Don't add internal variabels
				if ( '__returnActionPerformed' == $property->getName() )
					continue;

				// Add property to controller data
				$controllerData[$property->getName()] = $property->getValue($controllerObj);
			endforeach;

			// Merge data from controller and action
			$data = array_merge($controllerData, $data);
		endif;

		// Return the object
		return $data;
	}
1229009
public function perform()
    {
        /** @var ControllerDeclaration $declaration */
        $declaration = $this->createDeclaration();

        foreach ($this->option('action') as $action) {
            $declaration->addAction($action);
        }

        $this->writeDeclaration($declaration);
    }
792414
public static function start() {
    	$controller = (self::$route->module).'Controller';
    	$view = (self::$route->module).'View';
    	$model = (self::$route->module).'Model';
        $action = (self::$route->action).'Action';

        $module_root = MODULES_ROOT.'/'.self::$route->module;

        switch (true) {
			case (file_exists($module_root) &&
				 file_exists($module_root."/$model.php") &&
				 file_exists($module_root."/$view.php") &&
				 file_exists($module_root."/$controller.php")):
				$namespace = self::$route->module;

				if (class_exists("Module\\$namespace\\$controller")) {
					$app_controller = "Module\\$namespace\\$controller";
					$AppController = new $app_controller();
				} else {
					throw MvcException::UndefinedModule(self::$route->module);
				}

				if (method_exists($AppController, $action)) { $content = $AppController->$action(); } else {
					throw MvcException::UndefinedMethodInController($action, get_class($AppController));
				}
				break;

			default: throw MvcException::UndefinedModule(self::$route->module); break;
		}

        self::setContent($content);
    }