当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::filter方法代码示例

本文整理汇总了PHP中Pagekit\Application::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::filter方法的具体用法?PHP Application::filter怎么用?PHP Application::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::filter方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onEnable

 /**
  * Adds protected node types.
  */
 public function onEnable($event, $module)
 {
     foreach ((array) $module->get('nodes') as $type => $route) {
         if (isset($route['protected']) and $route['protected'] and !Node::where(['type = ?'], [$type])->first()) {
             Node::create(['title' => $route['label'], 'slug' => App::filter($route['label'], 'slugify'), 'type' => $type, 'status' => 1, 'link' => $route['name']])->save();
         }
     }
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:11,代码来源:NodesListener.php

示例2: registerType

 /**
  * Register a node type.
  *
  * @param string $type
  * @param array  $route
  */
 public function registerType($type, array $route)
 {
     if (isset($route['protected']) and $route['protected'] and !array_filter(Node::findAll(true), function ($node) use($type) {
         return $type === $node->type;
     })) {
         Node::create(['title' => $route['label'], 'slug' => App::filter($route['label'], 'slugify'), 'type' => $type, 'status' => 1, 'link' => $route['name']])->save();
     }
     $route['id'] = $type;
     $this->types[$type] = $route;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:16,代码来源:SiteModule.php

示例3: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"node": "array", "id": "int"}, csrf=true)
  */
 public function saveAction($data, $id = 0)
 {
     if (!($node = Node::find($id))) {
         $node = Node::create();
         unset($data['id']);
     }
     if (!($data['slug'] = App::filter($data['slug'] ?: $data['title'], 'slugify'))) {
         App::abort(400, __('Invalid slug.'));
     }
     $node->save($data);
     return ['message' => 'success', 'node' => $node];
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:17,代码来源:NodeApiController.php

示例4: formatValue

 /**
  * @param FieldBase    $field
  * @param FieldValueBase $fieldValue
  * @return array
  */
 public function formatValue(FieldBase $field, FieldValueBase $fieldValue)
 {
     $valuedata = $fieldValue->getValuedata();
     if (count($valuedata)) {
         return array_map(function ($file) {
             if (!isset($file['url'])) {
                 return '';
             }
             return sprintf('<a href="%s" download>%s</a> <small>(%s)</small>', App::url($file['url'], [], UrlGenerator::ABSOLUTE_URL), $file['name'], App::filter($file['size'], 'filesize'));
         }, $valuedata);
     }
     return ['-'];
 }
开发者ID:stroborobo,项目名称:pagekit-framework,代码行数:18,代码来源:UploadFieldType.php

示例5: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"project": "array", "id": "int"}, csrf=true)
  */
 public function saveAction($data, $id = 0)
 {
     if (!$id || !($project = Project::find($id))) {
         if ($id) {
             App::abort(404, __('Post not found.'));
         }
         $project = Project::create();
     }
     if (!($data['slug'] = App::filter($data['slug'] ?: $data['title'], 'slugify'))) {
         App::abort(400, __('Invalid slug.'));
     }
     $project->save($data);
     return ['message' => 'success', 'project' => $project];
 }
开发者ID:4nxiety,项目名称:pagekit-portfolio,代码行数:19,代码来源:ProjectApiController.php

示例6: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"category": "array", "id": "int"}, csrf=true)
  */
 public function saveAction($data, $id = 0)
 {
     if (!($category = Category::where(compact('id'))->related('files')->first())) {
         $category = Category::create();
         unset($data['id']);
     }
     if (!($data['slug'] = App::filter($data['slug'] ?: $data['title'], 'slugify'))) {
         App::abort(400, __('Invalid slug.'));
     }
     $category->updateOrdering($data);
     //unset array typed files
     unset($data['files']);
     $category->save($data);
     return ['message' => 'success', 'category' => $category];
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:20,代码来源:CategoryApiController.php

示例7: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"field": "array", "id": "int"}, csrf=true)
  */
 public function saveAction($data, $id = 0)
 {
     if (!($field = Field::find($id))) {
         $field = Field::create(['data' => ['value' => [], 'data' => [], 'classSfx' => '', 'help_text' => '', 'help_show' => '']]);
         unset($data['id']);
     }
     if (!($data['slug'] = App::filter($data['slug'] ?: $data['label'], 'slugify'))) {
         App::abort(400, __('Invalid slug.'));
     }
     try {
         $field->save($data);
     } catch (Exception $e) {
         App::abort(400, $e->getMessage());
     }
     return ['message' => 'success', 'field' => $field];
 }
开发者ID:Bixie,项目名称:pagekit-userprofile,代码行数:21,代码来源:FieldApiController.php

示例8: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"file": "array", "id": "int"}, csrf=true)
  */
 public function saveAction($data, $id = 0)
 {
     /** @var File $file */
     if (!$id || !($file = File::where(compact('id'))->related('categories')->first())) {
         if ($id) {
             App::abort(404, __('File not found.'));
         }
         $file = File::create();
     }
     if (!($data['slug'] = App::filter($data['slug'] ?: $data['title'], 'slugify'))) {
         App::abort(400, __('Invalid slug.'));
     }
     $file->save($data);
     $file->saveCategories($data['category_ids']);
     return ['message' => 'success', 'file' => $file];
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:21,代码来源:FileApiController.php

示例9: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"formitem": "array", "id": "int"}, csrf=true)
  */
 public function saveAction($data, $id = 0)
 {
     if (!($form = Form::find($id))) {
         $form = Form::create();
         unset($data['id']);
     }
     if (!($data['slug'] = App::filter($data['slug'] ?: $data['title'], 'slugify'))) {
         App::abort(400, __('Invalid slug.'));
     }
     try {
         $form->save($data);
     } catch (Exception $e) {
         App::abort(400, $e->getMessage());
     }
     return ['message' => 'success', 'formitem' => $form];
 }
开发者ID:4nxiety,项目名称:pagekit-formmaker,代码行数:21,代码来源:FormApiController.php

示例10: saveAction

 /**
  * @Route("/", methods="POST")
  * @Request({"menu":"array"}, csrf=true)
  */
 public function saveAction($menu)
 {
     $oldId = isset($menu['id']) ? trim($menu['id']) : null;
     $label = trim($menu['label']);
     if (!($id = App::filter($label, 'slugify'))) {
         App::abort(400, __('Invalid id.'));
     }
     if ($id != $oldId) {
         if ($this->config->has('menus.' . $id)) {
             throw new ConflictException(__('Duplicate Menu Id.'));
         }
         $this->config->remove('menus.' . $oldId);
         Node::where(['menu = :old'], [':old' => $oldId])->update(['menu' => $id]);
     }
     $this->config->merge(['menus' => [$id => compact('id', 'label')]]);
     App::menu()->assign($id, $menu['positions']);
     return ['message' => 'success', 'menu' => $menu];
 }
开发者ID:rifal89,项目名称:pagekit,代码行数:22,代码来源:MenuApiController.php

示例11: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"post": "array", "id": "int"}, csrf=true)
  */
 public function saveAction($data, $id = 0)
 {
     if (!$id || !($post = Post::find($id))) {
         if ($id) {
             App::abort(404, __('Post not found.'));
         }
         $post = Post::create();
     }
     if (!($data['slug'] = App::filter($data['slug'] ?: $data['title'], 'slugify'))) {
         App::abort(400, __('Invalid slug.'));
     }
     // user without universal access is not allowed to assign posts to other users
     if (!App::user()->hasAccess('blog: manage all posts')) {
         $data['user_id'] = App::user()->id;
     }
     // user without universal access can only edit their own posts
     if (!App::user()->hasAccess('blog: manage all posts') && !App::user()->hasAccess('blog: manage own posts') && $post->user_id !== App::user()->id) {
         App::abort(400, __('Access denied.'));
     }
     $post->save($data);
     return ['message' => 'success', 'post' => $post];
 }
开发者ID:pagekit,项目名称:extension-blog,代码行数:27,代码来源:PostApiController.php

示例12: addCache

 protected function addCache($user)
 {
     $this->cacheEntries[$user->id] = ['id' => $user->id, 'username' => App::filter($user->username, 'slugify'), 'name' => App::filter($user->name, 'slugify')];
     $this->cacheDirty = true;
 }
开发者ID:Bixie,项目名称:pagekit-userprofile,代码行数:5,代码来源:UrlResolver.php


注:本文中的Pagekit\Application::filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。