本文整理汇总了PHP中Action类的典型用法代码示例。如果您正苦于以下问题:PHP Action类的具体用法?PHP Action怎么用?PHP Action使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
/**
* @param Action $action
*/
public function addAction(Action $action)
{
if ($this->hasAction($name = $action->getName())) {
throw new \InvalidArgumentException(sprintf('Action "%s" already exists.', $name));
}
$this->actions[$name] = $action;
}
示例2: getNextStates
/**
* Available paths from current state.
*
* @return array
*/
public function getNextStates()
{
$maxMissionaries = $this->missionariesRight;
if ($this->boatLocation == 'left') {
$maxMissionaries = $this->missionariesLeft;
}
$maxCannibals = $this->cannibalsRight;
if ($this->boatLocation == 'left') {
$maxCannibals = $this->cannibalsLeft;
}
$maxMissionaries = min(BOAT_SIZE, $maxMissionaries);
$maxCannibals = min(BOAT_SIZE, $maxCannibals);
$states = [];
for ($missionaries = 0; $missionaries <= $maxMissionaries; ++$missionaries) {
for ($cannibals = 0; $cannibals <= $maxCannibals; ++$cannibals) {
if ($missionaries == 0 && $cannibals == 0) {
continue;
}
if ($missionaries + $cannibals > BOAT_SIZE) {
continue;
}
$action = new Action($missionaries, $cannibals);
if ($action->isValidAction()) {
$state = clone $this;
$state = $state->transfer($missionaries, $cannibals);
$node = new Node($state, $this, $action, 0, 0);
array_push($states, $node);
}
}
}
return $states;
}
示例3: index
public function index()
{
// Route
if (isset($this->request->get['route']) && $this->request->get['route'] != 'startup/router') {
$route = $this->request->get['route'];
} else {
$route = $this->config->get('action_default');
}
$data = array();
// Sanitize the call
$route = preg_replace('/[^a-zA-Z0-9_\\/]/', '', (string) $route);
// Trigger the pre events
$result = $this->event->trigger('controller/' . $route . '/before', array(&$route, &$data));
if (!is_null($result)) {
return $result;
}
$action = new Action($route);
// Any output needs to be another Action object.
$output = $action->execute($this->registry, $data);
// Trigger the post events
$result = $this->event->trigger('controller/' . $route . '/after', array(&$route, &$output));
if (!is_null($result)) {
return $result;
}
return $output;
}
示例4: onEndShowScripts
function onEndShowScripts(Action $action)
{
$action->inlineScript('var infinite_scroll_on_next_only = ' . ($this->on_next_only ? 'true' : 'false') . ';');
$action->inlineScript('var ajax_loader_url = "' . $this->path('ajax-loader.gif') . '";');
$action->script($this->path('jquery.infinitescroll.js'));
$action->script($this->path('infinitescroll.js'));
}
示例5: init
function init($mySql, $queries, $lang, $module, $idUrl)
{
$HelperOther = new HelperOther();
$Details = new Details();
$Action = new Action();
$entry = $mySql->fetch_row($queries->selectById($mySql, $module, $idUrl));
$getColumn = $queries->selectAll($mySql, $module);
$layout = $Details->debut($lang, $module);
for ($i = 0; $i < $mySql->num_fields($getColumn); $i++) {
$column = $mySql->fetch_field($getColumn);
$column = $column->name;
$details = $entry[$i];
if ($Action->exclusion($module, $column)) {
$field = $HelperOther->findField($column);
@(!(include_once 'controller/fields/' . $field . '.class.php'));
if (class_exists($field)) {
$getValue = new $field($lang, $module, $details, $column, DETAIL);
$details = $getValue->details;
$layout .= $Details->detail($details);
}
}
}
$layout .= $Details->fin();
return $layout;
}
示例6: nextAttemptSort
/**
* Sorts the actions based on which is to execute next.
* @param Action $a
* @param Action $b
* @return -1 if $a < $b, 1 if $a > $b, 0 if $a == $b
*/
private function nextAttemptSort($a, $b)
{
if ($a->getNextAttempt() == $b->getNextAttempt()) {
return 0;
}
return $a->getNextAttempt() < $b->getNextAttempt() ? -1 : 1;
}
示例7: get
public function get()
{
$action = new Action('common/order_status');
$data = $action->execute($this->registry);
$response['order_status'] = $data['order_status'];
$this->response->setOutput($response);
}
示例8: index
public function index()
{
// Route
if (isset($this->request->get['route']) && $this->request->get['route'] != 'startup/router') {
$route = $this->request->get['route'];
} else {
$route = $this->config->get('action_default');
}
// Sanitize the call
$route = str_replace('../', '', (string) $route);
// Trigger the pre events
$result = $this->event->trigger('controller/' . $route . '/before', array(&$route, &$data));
if (!is_null($result)) {
return $result;
}
// We dont want to use the loader class as it would make an controller callable.
$action = new Action($route);
// Any output needs to be another Action object.
$output = $action->execute($this->registry);
// Trigger the post events
$result = $this->event->trigger('controller/' . $route . '/after', array(&$route, &$data, &$output));
if (!is_null($result)) {
return $result;
}
return $output;
}
示例9: add
protected function add(Action $action)
{
if (isset($this->actions[$action->getName()])) {
throw new \InvalidArgumentException(sprintf('The action "%s" already exists.', $action->getName()));
}
$this->actions[$action->getName()] = $action;
}
示例10: index
public function index()
{
// Route
if (isset($this->request->get['route'])) {
$route = $this->request->get['route'];
} else {
$route = 'common/dashboard';
}
$data = array();
// Sanitize the call
$route = str_replace('../', '', (string) $route);
// Trigger the pre events
$result = $this->event->trigger('controller/' . $route . '/before', array(&$route, &$data));
if (!is_null($result)) {
return $result;
}
$action = new Action($route);
// Any output needs to be another Action object.
$output = $action->execute($this->registry, $data);
// Trigger the post events
$result = $this->event->trigger('controller/' . $route . '/after', array(&$route, &$output));
if (!is_null($result)) {
return $result;
}
return $output;
}
示例11: get
/**
* Resource methods
*/
public function get()
{
$action = new Action('common/language');
$data = $action->execute($this->registry);
$response['languages'] = $this->processLanguages($data['languages']);
$this->response->setOutput($response);
}
示例12: onEndAccountSettingsNav
/**
* Menu item for personal subscriptions/groups area
*
* @param Action $action action being executed
*
* @return boolean hook return
*/
function onEndAccountSettingsNav($action)
{
$action_name = $action->trimmed('action');
common_debug("ACTION NAME = " . $action_name);
$action->menuItem(common_local_url('mirrorsettings'), _m('MENU', 'Mirroring'), _m('Configure mirroring of posts from other feeds'), $action_name === 'mirrorsettings');
return true;
}
示例13: populateFromOptions
protected function populateFromOptions($options)
{
foreach ($options as $name => $attrs) {
$action = new Action($name);
if (isset($attrs['route_pattern'])) {
$action->setRoute($attrs['route_name'], $attrs['route_pattern'], array());
}
if (isset($attrs['text'])) {
$action->setText($attrs['text']);
}
if (isset($attrs['icon'])) {
$action->setButtonIcon($attrs['icon']);
}
if (isset($attrs['style'])) {
$action->setButtonStyle($attrs['style']);
}
if (isset($attrs['dialog'])) {
$action->setDialog($attrs['dialog']['title'], $attrs['dialog']['message']);
}
if (isset($attrs['trans_domain'])) {
$action->setTransDomain($attrs['trans_domain']);
}
if (isset($attrs['template'])) {
$action->setTemplate($attrs['template']);
}
if (isset($attrs['roles'])) {
$action->setRoles($attrs['roles']);
}
$this->add($action);
}
}
示例14: getValidationProfile
/**
* Will try and find a validation profile for the action provided
*
* @param Action $action
* @return ValidationProfile
* @throws ValidationException
*/
public function getValidationProfile(Action $action)
{
if (!isset($this->profiles[$action->getName()])) {
throw new ValidationException("Could not find a validation profile for action: [{$action->getName()}]");
}
return $this->profiles[$action->getName()];
}
示例15: get
/**
* Resource methods
*/
public function get()
{
$action = new Action('common/currency');
$data = $action->execute($this->registry);
$response['currencies'] = $this->processCurrencies($data['currencies']);
$this->response->setOutput($response);
}