本文整理汇总了PHP中Action::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Action::find方法的具体用法?PHP Action::find怎么用?PHP Action::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Action
的用法示例。
在下文中一共展示了Action::find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAcl
public function getAcl()
{
//if (!isset($this->persistent->acl)) {
$acl = new Phalcon\Acl\Adapter\Memory();
$acl->setDefaultAction(Phalcon\Acl::DENY);
//Register roles
$rol = Role::find(array("cache" => array("key" => "role")));
foreach ($rol as $ros) {
$roles[strtolower($ros->name)] = new Phalcon\Acl\Role($ros->name);
}
foreach ($roles as $role) {
$acl->addRole($role);
}
foreach (Action::find(array("cache" => array("key" => "action"))) as $actions) {
$acl->addResource(new Phalcon\Acl\Resource($actions->controller->name), $actions->name);
}
//Grant access to public areas to both users and guests
foreach ($rol as $role) {
foreach ($role->action as $action) {
$roledann[$role->name][$action->controller->name][] = $action->name;
}
}
// print_r($roledann);
foreach ($roledann as $keys => $dann) {
foreach ($dann as $key => $dan) {
$acl->allow($keys, $key, $dan);
}
}
//The acl is stored in session, APC would be useful here too
//$this->persistent->acl = $acl;
// }
//return $this->persistent->acl;
return $acl;
}
示例2: editedAction
/**
* [editedAction description]
* @param [type] $id [description]
* @return [type] [description]
*/
public function editedAction($id)
{
$data = Input::all();
$rules = array('actionname' => array('min:3', 'required'));
// Build the custom messages array.
$messages = array('action.min' => 'กรุณาระบุชื่อการกระทำอย่างน้อย :min ตัวอักษร.', 'action.required' => 'กรุณาระบุชื่อการกระทำ');
$action_content = trim($data['actionname']);
// Create a new validator instance.
$validator = Validator::make($data, $rules, $messages);
if ($validator->passes()) {
$action = new Action();
$chk_action = $action->checkAction($action_content);
if ($chk_action) {
$action = Action::find($id);
$action->action_name = $action_content;
$action->save();
return Redirect::to('action')->with('success', 'แก้ไขชื่อการกระทำสำเร็จ');
} else {
return Redirect::to('action-edit/' . $id)->with('warning', 'มีชื่อการกระทำในระบบแล้ว');
}
} else {
// $errors = $validator->messages();
return Redirect::to('action-edit/' . $id)->withErrors($validator);
}
}
示例3: initialize
public function initialize($entity = null, $options = null)
{
$action = new Select('actionid', Action::find(), array('using' => array('id', 'action'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione una Acción')));
$action->setLabel('Acción');
$this->add($action);
//añadimos un botón de tipo submit
$submit = $this->add(new Submit('Guardar', array('class' => 'btn btn-success')));
}
示例4: actionEdit
public function actionEdit()
{
//echo "<pre>";var_dump($_REQUEST);exit;
$action = new Action();
$actionInfo = array();
$label = '';
foreach ($_REQUEST as $k => $v) {
$_REQUEST[$k] = trim($v);
}
$menutype = isset($_REQUEST['menu_type']) ? intval($_REQUEST['menu_type']) : '0';
$whichFirstMenu = isset($_REQUEST['firstmenu']) ? intval($_REQUEST['firstmenu']) : '-1';
$menusort = isset($_REQUEST['menusort']) ? intval($_REQUEST['menusort']) : 0;
$firstmenus = Action::model()->findAll('is_menu=1');
if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
// 修改
$actionInfo = $action->find('aid=:id', array(':id' => $_REQUEST['id']));
if (!empty($_REQUEST['modify'])) {
$action->updateByPk($_REQUEST['id'], array('aname' => $_REQUEST['name'], 'route' => $_REQUEST['route'], 'is_menu' => $menutype, 'menusort' => $menusort, 'first_menu' => $whichFirstMenu));
$this->redirect('/main/action/list');
}
} elseif (!empty($_REQUEST['name'])) {
// 新增
$actionInfo = $action->find('aname=:name or route=:route', array(':name' => $_REQUEST['name'], ':route' => $_REQUEST['route']));
if (!empty($actionInfo)) {
$this->render('edit', array('firstmenus' => $firstmenus, 'entity' => $actionInfo, 'label' => 'has_action'));
exit;
}
if (!empty($_REQUEST['modify'])) {
$action->aname = $_REQUEST['name'];
$action->route = $_REQUEST['route'];
$action->is_menu = $menutype;
$action->first_menu = $whichFirstMenu;
$action->menusort = $menusort;
$action->save();
$this->redirect('/main/action/list');
}
//echo "<pre>";var_dump($_REQUEST,$actionInfo);exit;
}
$this->render('edit', array('firstmenus' => $firstmenus, 'entity' => $actionInfo, 'label' => $label));
}
示例5: initActions
public static function initActions()
{
$actions = (include Yii::app()->basePath . '/config-dist/actions.php');
foreach ($actions as $k => $v) {
$action = new Action();
$ret = $action->find('aname=:name', array(':name' => $v['aname']));
if (empty($ret)) {
$action->aname = $v['aname'];
$action->route = $v['route'];
$action->is_menu = $v['is_menu'];
$action->save();
}
}
}