@param string $action
@param array $data

@throws \RuntimeException
773966
public function write($action, $data)
    {
        $message = http_build_query($data);

        $resource = $this->getResource();
        $length = strlen($message);
        $sent = 0;

        $content = $this->getHeader($action, $length) . $message;

        while ($this->isConnected() && $sent < $length) {
            $chunk = fwrite($resource, substr($content, $sent));

            if (false === $chunk) {
                throw new \RuntimeException('Could not write to socket');
            }

            $sent += $chunk;
        }
    }
61922
public function setData(array $data): void {
		if ($this->compiled) {
			throw new ViewException("Attempt to alter view after compilation.", ViewException::AFTER_COMPILE_ALTERATION);
		}
		// to avoid overwriting any data that has already been set
		// using setDatum(), we don't want to do a simple assignment.
		// instead, we'll more carefully copy information from $data
		// to the data property.
		
		foreach ($data as $index => $datum) {
			$this->setDatum($index, $datum);
		}
	}
1277118
protected function runAction($action)
    {
        $dir = getcwd();
        chdir($this->getVendorDir());
        foreach ($this->managers as $m) {
            if ($m->hasDependencies()) {
                $m->runAction($action);
            }
        }
        chdir($dir);
    }
1124875
public function setAction($action) {
        if (!is_string($action) || empty($action)) {
            $errMessage = "The action value must be a string and not be empty";
            throw new \InvalidArgumentException($errMessage, GeneralErrors::VALUE_IS_NOT_OF_EXPECTED_TYPE);
        }

        $this->action = $action;
    }
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;
	}
628388
protected function execute(string $action)
    {
        if (!$this->getCollectionName()) {
            return false;
        }

        $options = [
            'writeConcern' => new WriteConcern($this->getWriteConcern()),
        ];

        if ($result = $this->getDataMapper()->$action($this, $options)) {
            $this->syncOriginalAttributes();
        }

        return $result;
    }
280444
public function runAction($action)
	{
		$response 		= null;
		$priorAction   	= $this->_action;
		$this->_action 	= $action;
		
		if ($this->beforeAction($action))
		{
			try {
				$response = $action->runWithParams($this->getActionParams());
			} catch (CHttpException $e) {
				$response = null;
				$this->status = $e->statusCode;
				$this->message = $e->getMessage();
			} catch (Exception $e) {
				$response = null;
				$this->status = 500;
				$this->message = Yii::t('Api.Controller', 'An unexpected error occured.');

				if (YII_DEBUG)
					$response = $e->getMessage();

				// Log this error
				Yii::log($e->getMessage(), 'error', 'Api.controller');
			}

			if ($response === false)
				$this->invalidActionParams($action);
			else
				$this->afterAction($action);
		}

		$this->_action=$priorAction;

		$this->renderOutput($response);
	}
738786
public static function each(array $arr, \Closure $action){
		foreach($arr as $k => $v){
			$action($v, $k);
		}
	}
1045803
protected function callOnChild($action, array $parameters = array())
    {
        if ($this->isExternal()) {
            throw new \RuntimeException("Calling ClientThread::CallOnChild from Child context. Did you mean ClientThread::CallOnParent?");
        } else {
            return $this->communicator->SendMessageSync($this->encode($action, $parameters));
        }
    }
833317
public function run(): void
    {
        if ('' === (string)$this->catName) {
            throw new \RuntimeException('You must call setCatName before running this action');
        }
        if ('' === (string)$this->name) {
            throw new \RuntimeException('You must call setName before running this action');
        }
        $this->fakerDataCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->interfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->hasInterfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->embeddableCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
        $this->hasCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
    }
183126
protected function httpRequest($action, $data, $method = 'POST', $options = [ ]) {
        $response = $this->{$this->http_request_type}($action, $data, $method, $options);
        $json = json_decode($response, true);
        if ($json === NULL) {
            throw new Sailthru_Client_Exception(
                "Response: {$response} is not a valid JSON",
                Sailthru_Client_Exception::CODE_RESPONSE_INVALID
            );
        }
        if (!empty($json['error'])) {
            throw new Sailthru_Client_Exception($json['errormsg'], $json['error']);
        }

        return $json;
    }
578137
public function callAction(string $action, ?DataMap $params = null): void
    {
        list ($moduleName, $controllerName, $actionName) = $this->getFullAction($action);
        $this->routeInfo->moduleName = $moduleName;
        $this->routeInfo->controllerName = $controllerName;
        $this->routeInfo->actionName = $actionName;
        if ($params != null) {
            $this->routeInfo->params = $params;
        }
        $this->invokeRoute();
    }
400604
public function setAction(string $action)
    {
        if (!empty($action) && $this->policy === Rule::NOINHERIT)
            throw new Exception("Rule::NOINHERIT can not be used in combination with an action");

        $action = (string)$action;
        if ($action !== $this->action)
        {
            $validator = $this->acl->getActionValidator();
            if (null !== $validator)
            {
                if (($reason = $validator->isValid($action)) !== true)
                    throw new Exception("Action can not be validated: " . $reason);
            }
            $this->changed = true;
            $this->action = $action;
        }
    }
869681
public function fileAppend($file, $data)
    {
        $file = $this->alias->resolve($file);
        $this->_dirCreate(dirname($file));

        if (file_put_contents($file, $data, LOCK_EX | FILE_APPEND) === false) {
            throw new RuntimeException(['write `:file` file failed: :last_error_message', 'file' => $file]);
        }
    }
1318316
public function setAction($action) {
        $this->setVariable(self::ACTION, $this->assembleAssignmentString(self::DATA_HREF, $action));
        $this->setEventType(self::CLICK_EVENT);
        $this->addClass(self::AJAX_ELEMENT_CLASS);
        if(!$this->getId()) {
            $this->setId("button_".floor(rand(0, 1000)));
        }
    }
654335
protected function executeAction($actionName, $data)
    {
        $actionManager = $this->getActionManager();

        $currentAction = $actionManager->getAction();

        $actionManager->setAction($actionName);
        $actionManager->run($data);

        $actionManager->setAction($currentAction);
    }
64530
protected function call($action, array $parameters = [])
    {
        if ($this->batch) {

            $query = ['api_action' => $action];

            foreach ($parameters as $key => $value) {
                if ($value !== null) {
                    $query[urlencode($key)] = urlencode($value);
                }
            }

            $this->batch->addRequest($query);

            return true;
        }

        $curl = curl_init();

        if (!$curl) {
            return false;
        }

        $query = "api_key={$this->key}&api_action={$action}";

        foreach ($parameters as $key => $value) {
            if ($value !== null) {
                $query .= sprintf('&%s=%s', urlencode($key), urlencode($value));
            }
        }

        if ($this->debug) {
            return $query;
        }

        $this->options[CURLOPT_URL]            = 'https://api.linode.com/';
        $this->options[CURLOPT_POST]           = true;
        $this->options[CURLOPT_POSTFIELDS]     = $query;
        $this->options[CURLOPT_RETURNTRANSFER] = true;
        $this->options[CURLOPT_SSLVERSION]     = CURL_SSLVERSION_TLSv1_2;

        curl_setopt_array($curl, $this->options);

        $result = curl_exec($curl);

        curl_close($curl);

        $json = json_decode($result, true);

        if (!$json) {
            throw new \RuntimeException('Empty response');
        }

        $error = reset($json['ERRORARRAY']);

        if ($error) {
            throw new LinodeException($error['ERRORMESSAGE'], $error['ERRORCODE']);
        }

        return $json['DATA'];
    }