Format a valid map between controller and actions and hydrate.

@param BundleExposedControllerInterface $controller
@param array                            $actions
970461
private function formatAndInjectExposedAction($controller, $actions)
    {
        $controllerId = explode('\\', get_class($controller));
        $controllerId = str_replace('controller', '', strtolower(array_pop(($controllerId))));
        $this->exposedActions[$controllerId] = array('actions' => array());

        if ($controller instanceof BundleExposedControllerInterface) {
            $this->exposedActions[$controllerId]['label'] = $controller->getLabel();
            $this->exposedActions[$controllerId]['description'] = $controller->getDescription();
            array_unshift($actions, 'indexAction');
            $actions = array_unique($actions);
        }

        foreach ($actions as $action) {
            if (method_exists($controller, $action)) {
                $actionId = str_replace('action', '', strtolower($action));
                $uniqueName = $controllerId.'_'.$actionId;

                $this->exposedActionsCallbacks[$uniqueName] = array($controller, $action);
                $this->exposedActions[$controllerId]['actions'][] = $actionId;
            }
        }
    }
516593
private static function execController($controller,$action,$args){
        $controller = new $controller();
        $controller->doAction($action,$args);
    }
348176
public function initController(\OWeb\types\Controller $controller = null)
    {

        if ($this->controller == null)
            return;

        Events::getInstance()->sendEvent('Init_Prepare@OWeb\manage\Controller', $this->controller);

        $this->controller->initController();

        Events::getInstance()->sendEvent('Init_Done@OWeb\manage\Controller', $this->controller);

        Events::getInstance()->sendEvent('ActionDist_Prepare@OWeb\manage\Controller', $this->controller);

        //gestion des Actions...
        $source[] = \OWeb\OWeb::getInstance()->get_get();
        $source[] = \OWeb\OWeb::getInstance()->get_post();

        foreach ($source as $get) {
            if (isset($get['action']))
                $this->controller->doAction($get['action']);

            $i = 1;
            while (isset($get['action_' . $i])) {
                $this->controller->doAction($get['action_' . $i]);
                $i++;
            }
        }

        Events::getInstance()->sendEvent('ActionDist_Done@OWeb\manage\Controller', $this->controller);
    }
166099
public function create(array $parameters, $controller = null) {
        $parameters = $this->parseParameters($parameters, $controller);

        $action = new Action(
            $parameters['name'],
            $parameters['pattern'],
            $parameters['uses'],
            $parameters['group']
        );

        $this->setProperties($action, $parameters);

        return $action;
    }
1036808
public function execute(Action $controller, $feedback = true) {

		try {

			$action = $this->parseActionName();

			elgg_make_sticky_form($action);

			$controller->setup();
			if ($controller->validate() === false) {
				throw new ActionValidationException("Invalid input for action $action");
			}
			$controller->execute();
			$this->result = $controller->getResult();
		} catch (ActionValidationException $ex) {
			$this->result->addError($ex->getMessage());
			elgg_log($ex->getMessage(), 'ERROR');
		} catch (PermissionsException $ex) {
			$this->result->addError(elgg_echo('apps:permissions:error'));
			elgg_log($ex->getMessage(), 'ERROR');
		} catch (InvalidEntityException $ex) {
			$this->result->addError(elgg_echo('apps:entity:error'));
			elgg_log($ex->getMessage(), 'ERROR');
		} catch (Exception $ex) {
			$this->result->addError(elgg_echo('apps:action:error'));
			elgg_log($ex->getMessage(), 'ERROR');
		}

		$errors = $this->result->getErrors();
		$messages = $this->result->getMessages();
		if (empty($errors)) {
			elgg_clear_sticky_form($action);
		} else {
			$this->result->setForwardURL(REFERRER);
		}

		if ($feedback) {
			foreach ($errors as $error) {
				register_error($error);
			}
			foreach ($messages as $message) {
				system_message($message);
			}
		}

		return elgg_trigger_plugin_hook('action:after', $action, null, $this->result);
	}
908726
public function addController(ContentControllerInterface $controller)
    {
        $contentClass = $controller->getContentClass();

        if (isset($this->controllers[$contentClass])) {
            throw new ControllerException(sprintf('Content controller for class "%s" already added.', $contentClass));
        }

        $this->controllers[$contentClass] = $controller;
    }
1193030
public function generateEntities(
        BundleInterface $bundle,
        array $parameters,
        OutputInterface $output
    ) {
        $dirPath = sprintf(
            '%s/Entity/Pages/',
            $bundle->getPath()
        );
        $fullSkeletonDir = sprintf(
            '%s/Entity/Pages/',
            $this->skeletonDir
        );

        try {
            $this->generateSkeletonBasedClass(
                $fullSkeletonDir,
                $dirPath,
                'SearchPage',
                $parameters
            );
        } catch (\Exception $error) {
            throw new \RuntimeException($error->getMessage());
        }

        $output->writeln('Generating entities : <info>OK</info>');
    }
16289
public function getBundleLoader($bundle, $controller, $params = null){
        $attributes = [
            'data-config'     => $this->configUrl,
            'src'             => $bundle,
            'data-controller' => $controller
        ];

        if(!is_null($params)){
            $attributes['data-params'] = json_encode($params);
        }

        return $this->buildScriptTag($attributes);
    }
926477
public function controllers(array $controllers)
	{
		foreach ($controllers as $uri => $name)
		{
			$this->controller($uri, $name);
		}
	}
33588
protected function generateCrud(AbstractResourceBundle $bundle)
    {
        $summary = array();
        $this->generateMacrosView($bundle);

        if (in_array('index', $this->configuration['actions'])) {
            $this->generateIndexView($bundle, $summary);
        }

        if (in_array('show', $this->configuration['actions'])) {
            $this->generateShowView($bundle, $summary);
        }

        if (in_array('create', $this->configuration['actions'])) {
            $this->generateCreateView($bundle, $summary);
        }

        if (in_array('update', $this->configuration['actions'])) {
            $this->generateUpdateView($bundle, $summary);
        }

        $this->writeOutput($summary);
    }
580395
private function _callAction(Controller $controller, $action, $error)
    {
        if ($error) {
            $method = $this->actionChain->actionNameStrategy($action . '_' . $error);
        } else {
            $method = $this->actionChain->actionNameStrategy($action);
        }
        if (method_exists($controller, $method)) {
            return $controller->$method();
        } else {
            return $error;
        }
    }
1000931
public function setActions($actions): Controller
    {
        $this->controllerRoutes = array_merge($this->controllerRoutes, $actions);

        return $this;
    }
1152297
@Override
    public synchronized Renderable<?> render(Controller controller, Map<String, Object> variables) {
        HashMap<String, Object> map = new HashMap<>(variables);
        if (!map.containsKey(ExtendedOGNLExpressionEvaluator.BUNDLE_VAR_KEY)) {
            map.put(ExtendedOGNLExpressionEvaluator.BUNDLE_VAR_KEY, bundle);
        }
        return templateEngine.process(this, controller, router, assets, map);
    }
1126967
public function handleControllerDependencies($controller, $action, $params = [])
    {
        // make and return instance of controller
        $instance = $this->getContainer()->make($controller);
        $instance->initialize($this->getContainer());

        if (!method_exists($instance, $action)) {
            throw new HttpNotFoundException("Method $action() doesn't exists in $controller class.");
        }

        /** Auto resolve all method dependencies */
        $methodArgs = $this->getContainer()->resolveMethod($controller, $action);
        // Inject all properties of controller defined in definition file
        $this->getContainer()->propertyInjection($instance, $controller);
        // Trigger Before Action Events
        $this->triggerActionEvent($instance, $action);
        $response = call_user_func_array([$instance, $action], array_merge($methodArgs, $params));
        // Trigger After Action Events
        $this->triggerActionEvent($instance, $action, 'after');

        return $response;
    }
843951
public function runController($controller, $method, Array $params) {
    $transactional = $controller instanceof \Psc\CMS\Controller\TransactionalController;
    
    try {
      try {
        $this->logf('running Controller: %s::%s(%s)', Code::getClass($controller), $method, implode(', ',array_map(function ($param) { return Code::varInfo($param); }, $params)));
        $cb = new Callback($controller, $method);
        $controllerResponse = $cb->call($params);
        
        $this->log('Converting Controller Response');
        $this->setResponseFromControllerResponse($controllerResponse);
        $this->log('Response Format: '.($this->response->getFormat() ?: 'null'));
        $this->log('successful run');
        
        $this->log('überprüfe ResponseMetadataController');
        if ($controller instanceof \Psc\CMS\Controller\ResponseMetadataController && ($meta = $controller->getResponseMetadata()) != NULL) {
          $this->response->setMetadata($meta);
          $this->log('Metadaten übertragen');
        }
        
      /* PDO Exceptions */
      } catch (\PDOException  $e) {
        throw \Psc\Doctrine\Exception::convertPDOException($e);
      }

    } catch (\Exception $e) {
      if ($transactional && $controller->hasActiveTransaction())
        $controller->rollbackTransaction();
      
      $this->handleException($e);
    }
  }
257741
protected function execute(InputInterface $input, OutputInterface $output)
    {
        /**
         * GENERATE THE BUNDLEBUNDLE
         */
        $bundleBundleDir = sprintf(self::BUNDLE_NAME_MASK, 'Bundle');

        // GravitonDynBundleBundle
        $bundleName = str_replace('/', '', $bundleBundleDir);

        // bundlebundle stuff..
        $this->bundleBundleNamespace = $bundleBundleDir;
        $this->bundleBundleDir = $input->getOption('srcDir') . $bundleBundleDir;
        $this->bundleBundleClassname = $bundleName;
        $this->bundleBundleClassfile = $this->bundleBundleDir . '/' . $this->bundleBundleClassname . '.php';

        $filesToWorkOn = $this->definitionLoader->load($input->getOption('json'));

        if (count($filesToWorkOn) < 1) {
            throw new \LogicException("Could not find any usable JSON files.");
        }

        $templateHash = $this->getTemplateHash();
        $existingBundles = $this->getExistingBundleHashes($input->getOption('srcDir'));

        /**
         * GENERATE THE BUNDLE(S)
         */
        foreach ($filesToWorkOn as $jsonDef) {
            $thisIdName = $jsonDef->getId();
            $namespace = sprintf(self::BUNDLE_NAME_MASK, $thisIdName);

            // make sure bundle is in bundlebundle
            $this->bundleBundleList[] = $namespace;

            $jsonDef->setNamespace($namespace);

            $bundleName = str_replace('/', '', $namespace);
            $bundleDir = $input->getOption('srcDir').$namespace;
            $bundleNamespace = str_replace('/', '\\', $namespace).'\\';

            try {
                $thisHash = sha1($templateHash.PATH_SEPARATOR.serialize($jsonDef));

                $needsGeneration = true;
                if (isset($existingBundles[$bundleDir])) {
                    if ($existingBundles[$bundleDir] == $thisHash) {
                        $needsGeneration = false;
                    }
                    unset($existingBundles[$bundleDir]);
                }

                if ($needsGeneration) {
                    $this->generateBundle($bundleNamespace, $bundleName, $input->getOption('srcDir'));
                    $this->generateGenerationHashFile($bundleDir, $thisHash);
                }

                if ($needsGeneration) {
                    $this->generateResources(
                        $jsonDef,
                        $bundleName,
                        $bundleDir,
                        $bundleNamespace
                    );

                    $output->write(
                        PHP_EOL.
                        sprintf('<info>Generated "%s" from definition %s</info>', $bundleName, $jsonDef->getId()).
                        PHP_EOL
                    );
                } else {
                    $output->write(
                        PHP_EOL.
                        sprintf('<info>Using pre-existing "%s"</info>', $bundleName).
                        PHP_EOL
                    );
                }
            } catch (\Exception $e) {
                $output->writeln(
                    sprintf('<error>%s</error>', $e->getMessage())
                );

                // remove failed bundle from list
                array_pop($this->bundleBundleList);
            }
        }

        // whatever is left in $existingBundles is not defined anymore and needs to be deleted..
        foreach ($existingBundles as $dirName => $hash) {
            $fileInfo = new \SplFileInfo($dirName);
            $bundleClassName = $this->getBundleClassnameFromFolder($fileInfo->getFilename());

            // remove from bundlebundle list
            unset($this->bundleBundleList[array_search($bundleClassName, $this->bundleBundleList)]);

            $this->fs->remove($dirName);

            $output->write(
                PHP_EOL.
                sprintf('<info>Deleted obsolete bundle "%s"</info>', $dirName).
                PHP_EOL
            );
        }

        // generate bundlebundle
        $this->generateBundleBundleClass();
    }
322743
public function hookTheme(Controller $controller)
    {
        if ($controller->isCurrentTheme('mobile') && !$controller->isInternalRoute()) {
            $this->setModuleAssets($controller);
            $this->setModuleMetaTags($controller);
        }
    }