public function assertActionInvokeFail(Action $action) { $ret = $action->invoke(); $result = $action->getResult(); $this->assertFalse($ret, $result->message); $this->assertEquals('error', $result->type, $result->message); return $result; }
public function register($kernel, $options = array()) { if (isset($options['DefaultFieldView'])) { Action::$defaultFieldView = $options['DefaultFieldView']; } $container = new ServiceContainer(); $generator = $container['generator']; $generator->registerTemplate('TwigActionTemplate', new TwigActionTemplate()); $generator->registerTemplate('CodeGenActionTemplate', new CodeGenActionTemplate()); $generator->registerTemplate('RecordActionTemplate', new RecordActionTemplate()); $generator->registerTemplate('UpdateOrderingRecordActionTemplate', new UpdateOrderingRecordActionTemplate()); $action = new ActionRunner($container); $action->registerAutoloader(); $kernel->action = function () use($options, $action) { return $action; }; $kernel->event->register('view.init', function ($view) use($action) { $view->args['Action'] = $action; }); $kernel->event->register('phifty.before_path_dispatch', function () use($kernel) { if (!ActionRequest::hasAction($_REQUEST)) { return; } $runner = $kernel->action; // get runner $kernel->event->trigger('phifty.before_action'); $strout = fopen("php://output", "w"); // If we found any ajax action, exit the application if ($runner->handleWith($strout, $_REQUEST, $_FILES)) { exit(0); } }); }
public function __construct($args = null, $options = array()) { $this->email = new Email(); if ($this->template) { # XXX: check template file $this->email->template($this->template); } return parent::__construct($args, $options); }
public function run() { if (!kernel()->currentUser->hasLoggedIn()) { return $this->error('無上傳權限。'); } parent::run(); $filePath = $this->arg('file'); $session = kernel()->session; $session->set('_current_upload', $filePath); return $this->success('上傳成功', ['filepath' => $filePath]); }
public function register(Kernel $kernel, $options = array()) { $kernel->actionService = function () use($kernel, $options) { $container = new ServiceContainer(); $container['cache_dir'] = $kernel->cacheDir; if ($kernel->locale) { $container['locale'] = $kernel->locale->current; } if (isset($options['DefaultFieldView'])) { Action::$defaultFieldView = $options['DefaultFieldView']; } $generator = $container['generator']; $generator->registerTemplate('TwigActionTemplate', new TwigActionTemplate()); $generator->registerTemplate('CodeGenActionTemplate', new CodeGenActionTemplate()); $generator->registerTemplate('RecordActionTemplate', new RecordActionTemplate()); $generator->registerTemplate('UpdateOrderingRecordActionTemplate', new UpdateOrderingRecordActionTemplate()); return $container; }; $kernel->actionRunner = function () use($kernel) { $actionRunner = new ActionRunner($kernel->actionService); $actionRunner->registerAutoloader(); // $actionRunner->setDebug(); return $actionRunner; }; $kernel->action = function () use($kernel) { return $kernel->actionRunner; }; $kernel->event->register('view.init', function ($view) use($kernel) { $view['Action'] = $kernel->actionRunner; }); $kernel->event->register('phifty.before_path_dispatch', function () use($kernel) { if (!ActionRequest::hasAction($_REQUEST)) { return; } $runner = $kernel->action; // the new trigger for actions defined in Bundle::actions method $kernel->event->trigger('phifty.prepare_actions'); $kernel->event->trigger('phifty.before_action'); $strout = fopen('php://output', 'w'); // If we found any ajax action, exit the application if ($runner->handleWith($strout, $_REQUEST, $_FILES)) { exit(0); } }); }
/** * Create Action View from Action object. * * @param ActionKit\RecordAction */ public function createActionView(Action $action, $viewClass = NULL, array $viewOptions = NULL) { if (!$viewClass) { $viewClass = $this->actionViewClass; } if ($viewOptions) { $viewOptions = array_merge($this->actionViewOptions, $viewOptions); } else { $viewOptions = $this->actionViewOptions; } // {{ CRUD.Action.asView('AdminUI\\Action\\View\\StackView',{ ajax: true, close_button: true }).render|raw}} return $action->asView($viewClass, $viewOptions); }
/** * Load record values into param instead of arguments. * * @override */ protected function loadParamValues() { // load record values into param objects if ($columns = $this->record->getColumns(true)) { foreach ($columns as $column) { $name = $column->name; if (isset($this->params[$name])) { $param = $this->params[$name]; $value = $this->record->getValue($name); if ($value !== NULL) { $param->value($value); } else { $param->value($column->getDefaultValue()); } } } } parent::loadParamValues(); }