public function Php::execute in DRD Agent 8.3
Same name and namespace in other branches
- 4.0.x src/Agent/Action/Php.php \Drupal\drd_agent\Agent\Action\Php::execute()
Execute an action.
Return value
mixed The response of the action as an array which will be encrypted before returned to DRD.
Overrides Base::execute
File
- src/
Agent/ Action/ Php.php, line 15
Class
- Php
- Provides a 'Php' code.
Namespace
Drupal\drd_agent\Agent\ActionCode
public function execute() {
$args = $this
->getArguments();
try {
if (!empty($args['php'])) {
$filename = 'temporary://drd_agent_php.inc';
file_put_contents($filename, $args['php']);
/** @noinspection PhpIncludeInspection */
require_once $filename;
unlink($filename);
}
} catch (Exception $ex) {
$this->messenger
->addMessage(t('Error while executing PHP: :msg', [
':msg' => $ex
->getMessage(),
]), 'error');
}
return [];
}