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


PHP array_pull函数代码示例

本文整理汇总了PHP中array_pull函数的典型用法代码示例。如果您正苦于以下问题:PHP array_pull函数的具体用法?PHP array_pull怎么用?PHP array_pull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: authenticate

 /**
  * Processes logging in a user.
  *
  * @param LoginRequest $request
  *
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
  */
 public function authenticate(LoginRequest $request)
 {
     try {
         $input = $request->all();
         $remember = (bool) array_pull($input, 'remember', false);
         if ($auth = Sentinel::authenticate($input, $remember)) {
             $message = 'Successfully logged in.';
             return redirect()->intended(route('maintenance.dashboard.index'))->withSuccess($message);
         } else {
             if (Corp::auth($input['login'], $input['password'])) {
                 $user = Corp::user($input['login']);
                 $name = explode(',', $user->name);
                 $credentials = ['email' => $user->email, 'username' => $user->username, 'password' => $input['password'], 'first_name' => array_key_exists(1, $name) ? $name[1] : null, 'last_name' => array_key_exists(0, $name) ? $name[0] : null];
                 return $this->registerAndAuthenticateUser($credentials);
             }
         }
         $errors = 'Invalid login or password.';
     } catch (NotActivatedException $e) {
         $errors = 'Account is not activated!';
     } catch (ThrottlingException $e) {
         $delay = $e->getDelay();
         $errors = "Your account is blocked for {$delay} second(s).";
     }
     return redirect()->back()->withErrors($errors);
 }
开发者ID:redknitin,项目名称:maintenance,代码行数:32,代码来源:AuthController.php

示例2: testArrayPull2dAssoc

 function testArrayPull2dAssoc()
 {
     $arr = array('a' => array('i' => 1, 'ii' => 2), 'b' => array('iii' => 3, 'iv' => 4), 'c' => array('v' => 5, 'vi' => 6));
     $pull = array('a', 'c');
     $new = array_pull($arr, $pull);
     $this->assertEquals($new, array('a' => array('i' => 1, 'ii' => 2), 'c' => array('v' => 5, 'vi' => 6)));
 }
开发者ID:m1ke,项目名称:easy-site-utils,代码行数:7,代码来源:test_functions_common.php

示例3: make

 /**
  * Make a field type.
  *
  * @param array           $parameters
  * @param StreamInterface $stream
  * @param null            $entry
  * @return FieldType
  */
 public function make(array $parameters, StreamInterface $stream = null, $entry = null)
 {
     /* @var EntryInterface $entry */
     if ($stream && $entry instanceof EntryInterface && $entry->hasField(array_get($parameters, 'field'))) {
         $field = clone $entry->getFieldType(array_get($parameters, 'field'));
         $modifier = $field->getModifier();
         $value = array_pull($parameters, 'value');
         /* @var EntryInterface $entry */
         $field->setValue(!is_null($value) ? $modifier->restore($value) : $entry->getAttribute($field->getField()));
     } elseif (is_object($entry)) {
         $field = $this->builder->build($parameters);
         $modifier = $field->getModifier();
         $value = array_pull($parameters, 'value');
         $field->setValue(!is_null($value) ? $modifier->restore($value) : $entry->{$field->getField()});
     } else {
         $field = $this->builder->build($parameters);
         $modifier = $field->getModifier();
         $field->setValue($modifier->restore(array_pull($parameters, 'value')));
     }
     // Set the entry.
     $field->setEntry($entry);
     // Merge in rules and validators.
     $field->mergeRules(array_pull($parameters, 'rules', []))->mergeConfig(array_pull($parameters, 'config', []))->mergeMessages(array_pull($parameters, 'messages', []))->mergeValidators(array_pull($parameters, 'validators', []));
     // Hydrate the field with parameters.
     $this->hydrator->hydrate($field, $parameters);
     return $field;
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:35,代码来源:FieldFactory.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['penerima' => 'required']);
     $all = $request->all();
     //         dd($all);
     $pengadaanFill = $this->pengadaanBarang->getFillable();
     $pengadaan = $this->pengadaanBarang->Create($request->only($pengadaanFill));
     // dd($all);
     try {
         foreach ($all['barpeng'] as $barpeng) {
             if (!is_numeric($barpeng['kuantitas'])) {
                 return redirect()->back()->withErrors(['Kuantitas harus berupa angka']);
             } else {
                 $addedItem = Barang::find($barpeng['barang_id']);
                 $addedItem['pengadaan'] += $barpeng['kuantitas'];
                 $addedItem->save();
                 //                dd($addedItem);
                 Barang::find($barpeng['barang_id'])->update($addedItem->toArray());
                 $barang_id = array_pull($barpeng, 'barang_id');
                 $pengadaan->barangs()->attach($barang_id, $barpeng);
             }
         }
         return redirect('pengadaan/index');
     } catch (Exception $e) {
         return redirect()->back()->withErrors($e);
     }
 }
开发者ID:aridwan,项目名称:gudang,代码行数:33,代码来源:PengadaanController.php

示例5: execf

 /**
  * Sprintf and execute a command
  *
  * @param string $message
  * @param string $parameters ...
  *
  * @return void
  */
 protected function execf()
 {
     $arguments = func_get_args();
     $message = array_pull($arguments, 0);
     $command = vsprintf($message, $arguments);
     return exec($command);
 }
开发者ID:anahkiasen,项目名称:polyglot,代码行数:15,代码来源:AbstractService.php

示例6: __construct

 /**
  * @param array $options
  */
 public function __construct(array $options = [])
 {
     parent::__construct(['di' => $this->buildDi((array) array_pull($options, 'di'))]);
     $this->registerInstance($this);
     $this->validate($options);
     $this->registerConfig($options);
 }
开发者ID:JustinAzoff,项目名称:connectwise-php-generator,代码行数:10,代码来源:Container.php

示例7: apiResource

 /**
  * Route a model to an api controller.
  *
  * @param  string  $model
  * @param  array   $options
  * @return void
  */
 public function apiResource($model, array $options = array())
 {
     $parent = array_pull($options, 'parent', false);
     $name = array_pull($options, 'name', false);
     $controller = array_pull($options, 'controller', $this->controller);
     if (!$name) {
         // nest resource routes if parent is present
         if ($parent) {
             // conventionally we should avoid being repetitive
             // nested model routes should not reference parents
             if (strpos($model, $parent) === 0) {
                 $model = substr($model, strlen($parent));
             }
             $model = static::prepareEntityBaseName($model);
             $parent = static::prepareEntityBaseName($parent);
             $only = array_pull($options, 'only', false);
             $except = array_pull($options, 'except', []);
             $addIndexAction = (false === $only || in_array('index', $only)) && !in_array('index', $except);
             // special case resource index method needs to be handled separately here
             if ($addIndexAction) {
                 $name = $parent . '.' . $model;
                 $this->addResourceIndex($name, $model, $controller, $options);
                 // make sure we skip the index action when we call the resource method
                 $options['except'] = array_merge($except, ['index']);
             }
             // set prefixed name for all other resource actions
             $name = $parent . '/{' . $parent . '}/' . $model;
         } else {
             $model = static::prepareEntityBaseName($model);
             $name = $model;
         }
     }
     // hand off to default resource router
     $this->resource($name, $controller, $options);
 }
开发者ID:edgji,项目名称:hapi,代码行数:42,代码来源:Router.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(\Illuminate\Http\Request $request)
 {
     // Sanity: Make sure $request is valid
     if (!$request->has('Profile')) {
         return response('{"Error": "Invalid Request"}', 422);
     } else {
         $this->validate($request, ['Profile' => 'required|json']);
     }
     // Sanitize the request and extract an assoc array
     $data = json_decode($request->input('Profile'), true);
     $validate = Validator::make($data, ['profile_name' => 'required|alpha_num', "number" => 'required', "numbers" => 'required', "lower" => 'required', "lower_case" => 'required', "upper" => 'required', "upper_case" => 'required', "symbol" => 'required', "symbols" => 'required', "special" => 'required', "specials" => 'required', "length" => 'required', "count" => 'required', "entropy" => 'required']);
     if ($validate->fails()) {
         return response('{"Error": "Invalid Request"}', 422);
     }
     // Sanity Check: (model exist) ? 'update it' : 'create it'
     // Pull 'profile_name' from $data array
     $model = PassProfile::firstOrNew(['profile_name' => array_pull($data, 'profile_name')]);
     // Fill $model
     foreach ($data as $key => $value) {
         $model[$key] = $value;
     }
     // Save model
     $model->save();
     return $model->toJson();
 }
开发者ID:Dev1436,项目名称:laravel-securepassgen,代码行数:31,代码来源:SPGProfileController.php

示例9: normalize

 /**
  * Normalize the assignments input.
  *
  * @param Migration $migration
  */
 public function normalize(Migration $migration)
 {
     $locale = $this->config->get('app.fallback_locale');
     $stream = $migration->getStream();
     $assignments = $migration->getAssignments();
     foreach ($assignments as $field => &$assignment) {
         /*
          * If the assignment is a simple string
          * then the assignment is the field slug.
          */
         if (is_string($assignment)) {
             $assignment = ['field' => $assignment];
         }
         /*
          * Generally the field will be the
          * array key. Make sure we have one.
          */
         if (!isset($assignment['field'])) {
             $assignment['field'] = $field;
         }
         /*
          * If any of the translatable items exist
          * in the base array then move them up into
          * the translation array.
          */
         foreach (['label', 'warning', 'instructions', 'placeholder'] as $key) {
             if ($value = array_pull($assignment, $key)) {
                 $assignment = array_add($assignment, $locale . '.' . $key, $value);
             }
         }
     }
     $migration->setAssignments($assignments);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:38,代码来源:AssignmentNormalizer.php

示例10: clientUpdate

 protected function clientUpdate($params)
 {
     //wrap body params with "doc" to fit update api
     $body = array_pull($params, 'body');
     $params['body']['doc'] = $body;
     return $this->es_client->update($params);
 }
开发者ID:ryanrobertsname,项目名称:laravel-elasticsearch-repository,代码行数:7,代码来源:BaseTrait.php

示例11: normalize

 /**
  * Normalize the fields input.
  *
  * @param Migration $migration
  */
 public function normalize(Migration $migration)
 {
     $locale = $this->config->get('app.fallback_locale');
     $fields = $migration->getFields();
     foreach ($fields as $slug => &$field) {
         /*
          * If the field is a simple string then
          * the $slug is used as is and the field
          * must be the field type.
          */
         if (is_string($field)) {
             $field = ['type' => $field];
         }
         if (!isset($field['type'])) {
             throw new \Exception("The [type] parameter must be defined in fields.");
         }
         $field['slug'] = array_get($field, 'slug', $slug);
         $field['namespace'] = array_get($field, 'namespace', $migration->contextualNamespace());
         /*
          * If any of the translatable items exist
          * in the base array then move them up into
          * the translation array.
          */
         foreach (['name', 'instructions', 'placeholder', 'warning'] as $key) {
             if ($value = array_pull($field, $key)) {
                 $field = array_add($field, $locale . '.' . $key, $value);
             }
         }
     }
     $migration->setFields($fields);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:36,代码来源:FieldNormalizer.php

示例12: boot

 /**
  * Boot service, registering providers.
  * 
  * @return void
  */
 public function boot()
 {
     foreach ($this->toBoot as $key => $class) {
         array_pull($this->toBoot, $key);
         $this->registerProvider($class);
     }
 }
开发者ID:irto,项目名称:php-worker,代码行数:12,代码来源:Service.php

示例13: __construct

 /**
  * Constructor.
  *
  * @param  array $config
  */
 public function __construct(array $config)
 {
     // Setup cache groups
     $cacheGroups = array_pull($config, 'groups');
     $this->setupCacheGroups($cacheGroups);
     // Set cache config
     $this->config = $config;
 }
开发者ID:nodes-php,项目名称:cache,代码行数:13,代码来源:Repository.php

示例14: configureManager

 /**
  * @param ImageManager $imageManager
  * @param Container    $container
  * @param array        $config
  */
 protected function configureManager(ImageManager $imageManager, Container $container, array $config)
 {
     $adapterConfigs = array_merge(array_get($config, 'adapters', []), self::$defaultAdapters);
     foreach ($adapterConfigs as $adapterConfig) {
         $className = array_pull($adapterConfig, 'class');
         $adapter = $container->make($className, ['config' => $adapterConfig]);
         $imageManager->addAdapter($adapter);
     }
 }
开发者ID:nordsoftware,项目名称:lumen-image-manager,代码行数:14,代码来源:ImageManagerServiceProvider.php

示例15: normalize

 /**
  * Normalize button input.
  *
  * @param TreeBuilder $builder
  */
 public function normalize(TreeBuilder $builder)
 {
     $buttons = $builder->getButtons();
     foreach ($buttons as $key => &$button) {
         /*
          * If the button is a string then use
          * it as the button parameter.
          */
         if (is_string($button)) {
             $button = ['button' => $button];
         }
         /*
          * If the key is a string and the button
          * is an array without a button param then
          * move the key into the button as that param.
          */
         if (!is_integer($key) && !isset($button['button'])) {
             $button['button'] = $key;
         }
         /*
          * Make sure some default parameters exist.
          */
         $button['attributes'] = array_get($button, 'attributes', []);
         /*
          * Move the HREF if any to the attributes.
          */
         if (isset($button['href'])) {
             array_set($button['attributes'], 'href', array_pull($button, 'href'));
         }
         /*
          * Move the target if any to the attributes.
          */
         if (isset($button['target'])) {
             array_set($button['attributes'], 'target', array_pull($button, 'target'));
         }
         /*
          * Move all data-* keys
          * to attributes.
          */
         foreach ($button as $attribute => $value) {
             if (str_is('data-*', $attribute)) {
                 array_set($button, 'attributes.' . $attribute, array_pull($button, $attribute));
             }
         }
         /*
          * Make sure the HREF is absolute.
          */
         if (isset($button['attributes']['href']) && is_string($button['attributes']['href']) && !starts_with($button['attributes']['href'], 'http')) {
             $button['attributes']['href'] = url($button['attributes']['href']);
         }
         /*
          * Use small buttons for trees.
          */
         $button['size'] = array_get($button, 'size', 'xs');
     }
     $builder->setButtons($buttons);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:62,代码来源:ButtonNormalizer.php


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