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


PHP Validator::object方法代码示例

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


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

示例1: post

 public function post($manufacturerId)
 {
     $editManufacturer = $this->collection[$manufacturerId]->fetch() ?: new stdClass();
     foreach ($_POST as $k => $v) {
         $editManufacturer->{$k} = $v;
     }
     try {
         v::object()->attribute('name', v::string()->notEmpty()->length(1, 300))->assert($editManufacturer);
         $this->collection->persist($editManufacturer);
         $this->collection->flush();
         if (empty($newManufacturer->manufacturer_featured)) {
             $newManufacturer->manufacturer_featured = null;
         }
         if ($_FILES['files']['error'] != 4) {
             foreach ($_FILES as $file) {
                 $this->uploaderService->setFile($editManufacturer->name, 'files');
                 $image = (object) ['name' => $this->uploaderService->getFile()->getNameWithExtension(), 'title' => $editManufacturer->name, 'type' => $this->uploaderService->getFile()->getMimetype(), 'manufacturer_id' => $editManufacturer->id];
                 $this->imageCollection->persist($image);
                 $this->imageCollection->flush();
                 $this->uploaderService->upload();
             }
         }
         header('HTTP/1.1 303 See Other');
         header('Location: ' . $_SERVER['REQUEST_URI']);
     } catch (NestedValidationExceptionInterface $e) {
         return ['editManufacturer' => $editManufacturer, 'messages' => $e->findMessages(['name' => 'Name must have between 1 and 300 chars', 'enabled' => 'Could not enable manufacturer'])];
     }
 }
开发者ID:supercluster,项目名称:catalog,代码行数:28,代码来源:Edit.php

示例2: postEdit

 protected function postEdit($categoryId)
 {
     $editCategory = $this->collection[$categoryId]->fetch() ?: new stdClass();
     foreach ($_POST as $k => $v) {
         $editCategory->{$k} = $v;
     }
     try {
         v::object()->attribute('name', v::string()->notEmpty()->length(1, 300))->attribute('enabled', v::numeric()->between(0, 1, true), false)->assert($editCategory);
         $this->collection->persist($editCategory);
         $this->collection->flush();
         header('HTTP/1.1 303 See Other');
         header('Location: ' . $_SERVER['REQUEST_URI']);
     } catch (NestedValidationExceptionInterface $e) {
         return ['editCategory' => $editCategory, 'messages' => $e->findMessages(['name' => 'Name must have between 1 and 300 chars', 'enabled' => 'Could not enable category'])];
     }
 }
开发者ID:supercluster,项目名称:catalog,代码行数:16,代码来源:Edit.php

示例3: post

 public function post($featureId)
 {
     $editFeature = $this->collection[$featureId]->fetch() ?: new stdClass();
     foreach ($_POST as $k => $v) {
         $editFeature->{$k} = $v;
     }
     try {
         v::object()->attribute('name', v::string()->notEmpty()->length(1, 300))->assert($editFeature);
         $this->collection->persist($editFeature);
         $this->collection->flush();
         header('HTTP/1.1 303 See Other');
         header('Location: ' . $_SERVER['REQUEST_URI']);
         return $this->get($featureId);
     } catch (NestedValidationExceptionInterface $e) {
         return ['singleFeature' => $editFeature, 'messages' => $e->findMessages(['name' => 'Name must have between 1 and 300 chars', 'enabled' => 'Could not enable product'])];
     }
 }
开发者ID:supercluster,项目名称:catalog,代码行数:17,代码来源:SingleFeature.php


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