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


PHP Arr::flatten方法代码示例

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


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

示例1: addAward

 private function addAward()
 {
     $success = true;
     $errors = array();
     $data = Arr::merge($this->sanitize($_POST), $_FILES);
     Upload::$default_directory = Kohana::config('myshot.basePath');
     if ($stage_path = Upload::save($data['photo'])) {
         $award = $this->site->createAward($this->sanitize($data['name']), $data);
         foreach ($this->site->imageTypes as $imageType) {
             $name = $imageType->name;
             if ($name == self::FULL) {
                 Library_Akamai::factory()->addToDir($stage_path, Kohana::config('akamai.honordir'));
                 $award->addImage(self::FULL, $this->webPath($stage_path));
             } else {
                 if (ImageTypes::types()->{$name}) {
                     $resized = $this->resizeHonor($stage_path, ImageTypes::types()->{$name}->size);
                     $award->addImage($name, $this->webPath($resized));
                 }
             }
         }
     } else {
         $success = false;
         $errors[] = "Image failed to load.";
     }
     if ($success) {
         Message::set(Message::SUCCESS, 'You have successfully added an award.');
         Request::instance()->redirect('admin/awards');
     } else {
         Message::set(Message::ERROR, Arr::flatten($errors));
     }
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:31,代码来源:awards.php

示例2: add_category

 private function add_category()
 {
     $category = ORM::factory('category');
     if ($category->values($_POST)->check()) {
         $category->save();
         Message::set(Message::SUCCESS, 'You have successfully added a category.');
         Request::instance()->redirect('admin/categories');
     } else {
         Message::set(Message::ERROR, Arr::flatten($category->validate()->errors('admin/category')));
     }
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:11,代码来源:categories.php

示例3: flatten

 public static function flatten($array)
 {
     $flat = array();
     foreach ($array as $key => $value) {
         if (is_array($value)) {
             $flat += Arr::flatten($value);
         } else {
             $flat[$key] = $value;
         }
     }
     return $flat;
 }
开发者ID:sxhao,项目名称:resty-1,代码行数:12,代码来源:arr.php

示例4: server_local

 public static function server_local(array $params = array())
 {
     $validation = Validation::factory($params)->rule('path', 'not_empty')->rule('path', 'is_dir')->rule('web', 'not_empty')->rule('url_type', 'in_array', array(':value', array(Flex\Storage\Server::URL_HTTP, Flex\Storage\Server::URL_SSL, Flex\Storage\Server::URL_STREAMING)));
     if (!$validation->check()) {
         throw new Kohana_Exception('Upload server local params had errors: :errors', array(':errors' => join(', ', Arr::flatten($validation->errors()))));
     }
     $server = new Flex\Storage\Server_Local($validation['path'], $validation['web']);
     if (isset($validation['url_type'])) {
         $server->url_type($validation['url_type']);
     }
     return $server;
 }
开发者ID:Konro1,项目名称:pms,代码行数:12,代码来源:Server.php

示例5: merge_resources

 /**
  * Method to merge resources
  * It finds out all the controllers and adds the basenames to the acl config array
  * as resources only if the key doesnot already exists
  */
 private function merge_resources()
 {
     $controllers = Kohana::list_files('classes/controller');
     // controllers can also be nested, so just flatten the array
     $controllers = Arr::flatten($controllers);
     foreach ($controllers as $controller) {
         $resource = basename($controller, '.php');
         if (self::is_resource_ignored($resource) || array_key_exists($resource, $this->_acl)) {
             continue;
         }
         $this->_acl[$resource] = array();
     }
     ksort($this->_acl);
     return $this;
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:20,代码来源:config.php

示例6: routes

 /**
  * @param bool $parseActions
  * @param bool $forced
  */
 static function routes($parseActions = TRUE, $forced = FALSE)
 {
     if ($forced || !static::$_routes) {
         $pathPrefix = 'classes' . DIRECTORY_SEPARATOR;
         $directoryPrefix = self::config('directory_prefix');
         $path = rtrim($pathPrefix . 'Controller' . DIRECTORY_SEPARATOR . $directoryPrefix, DIRECTORY_SEPARATOR);
         $controllers = array_keys(Arr::flatten(Kohana::list_files($path)));
         $urlBase = self::config('route.url.base', 'api');
         $urlPrefix = $urlBase . self::config('route.url.version', '/v{version}');
         foreach ($controllers as $controller) {
             $className = str_replace([$pathPrefix, DIRECTORY_SEPARATOR, EXT], ['', '_', ''], $controller);
             self::getClassRoutes($className, $directoryPrefix, $urlPrefix, $parseActions);
         }
         Route::set('RestfulAPI\\Error', $urlBase . '(/<unknown>)', ['unknown' => '.*'])->filter([get_class(), 'error404']);
         static::$_routes = TRUE;
     }
 }
开发者ID:vspvt,项目名称:kohana-restfulapi,代码行数:21,代码来源:RestfulAPI.php

示例7: receive

 /**
  * Receive Messages From data provider
  *
  * @param  string type    Message type
  * @param  string from    From contact
  * @param  string message Received Message
  * @param  string to      To contact
  * @param  string title   Received Message title
  * @param  string data_provider_message_id Message ID
  * @return void
  */
 public function receive($type, $from, $message, $to = NULL, $title = NULL, $data_provider_message_id = NULL)
 {
     $data_provider = $this->provider_name();
     $contact_type = $this->contact_type;
     $usecase = service('factory.usecase')->get('messages', 'receive');
     try {
         $usecase->setPayload(compact(['type', 'from', 'message', 'to', 'title', 'data_provider_message_id', 'data_provider', 'contact_type']))->interact();
     } catch (Ushahidi\Core\Exception\NotFoundException $e) {
         throw new HTTP_Exception_404($e->getMessage());
     } catch (Ushahidi\Core\Exception\AuthorizerException $e) {
         throw new HTTP_Exception_403($e->getMessage());
     } catch (Ushahidi\Core\Exception\ValidatorException $e) {
         throw new HTTP_Exception_400('Validation Error: \':errors\'', array(':errors' => implode(', ', Arr::flatten($e->getErrors()))));
     } catch (\InvalidArgumentException $e) {
         throw new HTTP_Exception_400('Bad request: :error', array(':error' => $e->getMessage()));
     }
 }
开发者ID:puffadder,项目名称:platform,代码行数:28,代码来源:DataProvider.php

示例8: get_list

 /**
  * Gets list of instances of [CLI_Task] class.
  * 
  *     $catalog = CLI_Task_Info::get_list();
  * 
  * @param  string $path path to root directory of tasks
  * @return array
  */
 public static function get_list($path = CLI_Tasker::DIR_ROOT)
 {
     if (Kohana::$caching) {
         // Create cache key\tag for find task list
         $cache_key = __METHOD__ . '(' . $path . ')';
         // Try load list from cache
         if ($catalog = Kohana::cache($cache_key)) {
             return $catalog;
         }
     }
     $catalog = Kohana::list_files($path);
     $catalog = Arr::flatten($catalog);
     $catalog = array_keys($catalog);
     if (Kohana::$caching) {
         // Cache task information
         Kohana::cache($cache_key, $catalog, 3600);
     }
     return $catalog;
 }
开发者ID:wintersilence,项目名称:kohana-cli,代码行数:27,代码来源:Info.php

示例9: __construct

 public function __construct(Request $req)
 {
     parent::__construct($req);
     $auth = Auth::instance();
     if (!$auth->logged_in()) {
         $curr_url = URL::curr();
         $this->redirect('auth/login?return_url=' . urlencode($curr_url));
     } else {
         $this->user = $auth->get_user();
         $menu = Kohana::config('menu');
         $allmenu = Arr::flatten($menu);
         /*/
           $this->permission = array_values($allmenu);
           $this->user_permission = $this->permission;
           /*/
         $m_permit = Model::factory('permit');
         $permission = $m_permit->getAll()->as_array(null, 'url');
         $permission = array_merge($permission, array_values($allmenu));
         $this->permission = array_unique($permission);
         $m_role = Model::factory('role');
         $role_ids = explode(',', $this->user['role_id']);
         $permit_ids = $m_role->getAll(array('status' => 'normal', 'id' => array('in' => $role_ids)))->as_array(null, 'permit_ids');
         if (!empty($permit_ids)) {
             $permit_ids = implode(',', $permit_ids);
             if ($permit_ids == '*') {
                 $this->user_permission = $this->permission;
             } else {
                 $permit_ids = array_unique(array_filter(explode(',', $permit_ids)));
                 $this->user_permission = $m_permit->getAll(array('id' => array('in' => $permit_ids)))->as_array(null, 'url');
             }
         }
         //*/
         foreach ($menu as $name => $items) {
             foreach ($items as $sub_name => $url) {
                 if (!in_array($url, $this->user_permission)) {
                     unset($menu[$name][$sub_name]);
                 }
             }
         }
         $this->user_menu = $menu;
     }
 }
开发者ID:andygoo,项目名称:kohana,代码行数:42,代码来源:Website.php

示例10: action_get_index_collection

 /**
  * Retrieve a basic information about the API
  *
  * GET /api
  *
  * @return void
  */
 public function action_get_index_collection()
 {
     $path = 'classes/Controller/Api';
     $files = Arr::flatten(Kohana::list_files($path));
     $trim = strlen($path);
     $endpoints = [];
     foreach ($files as $file => $path) {
         if (__FILE__ === $path) {
             continue;
             // skip the index
         }
         // remove the base path (up to Api/) and the .php extension
         $file = substr($file, $trim + 1, -4);
         // @todo this would be much more awesome if it gave back a URI
         $endpoints[] = strtolower($file);
     }
     sort($endpoints);
     $user = service('session.user');
     $this->_response_payload = ['now' => date(DateTime::W3C), 'version' => static::$version, 'endpoints' => $endpoints, 'user' => ['id' => $user->id, 'username' => $user->username]];
 }
开发者ID:nolanglee,项目名称:platform,代码行数:27,代码来源:Index.php

示例11: action_save

 public function action_save()
 {
     if (count($_POST) > 0) {
         $errors = NULL;
         try {
             $user = Auth::instance()->get_user();
             $user = $user->update_user($_POST, array('password', 'email'));
             $user->save();
             EmailHelper::notify($user, $this->request->post('password'));
             $this->redirect_to_albums();
         } catch (ORM_Validation_Exception $e) {
             // todo: specify a real messages file here...
             // external errors are still in a sub-array, so we have to flatten
             // also the message is wrong  - bug #3896
             $errors = Arr::flatten($e->errors('hack'));
         }
         $this->show_profile_form($user, $errors);
     } else {
         $this->redirect_to_albums();
     }
 }
开发者ID:andygoo,项目名称:kohana_demo,代码行数:21,代码来源:user.php

示例12: generate_tables

 public static function generate_tables()
 {
     $models = Kohana::list_files('classes/model');
     $models = array_keys(Arr::flatten($models));
     $tables = array();
     $throughs = array();
     foreach ($models as $name) {
         $name = str_replace(array('classes/model' . DIRECTORY_SEPARATOR, EXT), '', $name);
         $name = str_replace(DIRECTORY_SEPARATOR, '_', $name);
         $reflection = new ReflectionClass('Model_' . $name);
         if (preg_match('/^Base_/', $name)) {
             continue;
         }
         if ($reflection->isAbstract() or $name === 'App' or preg_match('/^(Auth_|User_Token)/', $name)) {
             continue;
         }
         $object_name = ORM::get_model_name($name);
         $model = ORM::factory($name);
         $labels = $model->labels();
         $rules = $model->rules();
         $belongs_to = $model->belongs_to();
         $has_many = $model->has_many();
         $table_name = $model->table_name();
         $tables[$table_name] = $model->table_columns();
         // through
         foreach ($has_many as $key => $values) {
             $through = Arr::get($values, 'through');
             if ($through and !Arr::get($through, $tables) and preg_match('/^' . $table_name . '_/', $through)) {
                 $farkey = ORM::get_model_name(str_replace($table_name . '_', '', $through));
                 $tables[$through] = array(strtolower($farkey) . '_id' => array('type' => 'int', 'data_type' => 'int', 'is_nullable' => FALSE), strtolower($object_name) . '_id' => array('type' => 'int', 'data_type' => 'int', 'is_nullable' => FALSE));
                 $throughs[] = $through;
             }
         }
     }
     foreach ($tables as $name => $value) {
         self::save_tables($name, $value, $throughs);
     }
 }
开发者ID:huiancg,项目名称:kohana-huia,代码行数:38,代码来源:Autogen.php

示例13: action_edit

 public function action_edit()
 {
     $contra = $_GET['contra'];
     //$contra = $this->request->param('contra');
     $content = View::factory('contextoedit')->set('values', $_POST)->bind('errors', $errors)->bind('id', $id)->bind('contextos', $contextos)->bind('data', $data);
     $contextos = ORM::factory('contextos')->where('id', '=', $contra)->find();
     $data = $contextos->as_array();
     //  if(!$contextos->loaded()){HTTP::redirect('contextos');}
     $contextos = ORM::factory('contextos')->find_all()->as_array();
     //$categories = $categories->find_all()->as_array();
     if (isset($_POST['submit'])) {
         $data[] = Arr::extract($_POST, array('nomModalidad', 'modaDescripcion', 'modaDescripcion', 'template'));
         $data = Arr::flatten($data);
         $contextos->values($data);
         try {
             $contextos->save();
             HTTP::redirect('contextos');
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors('validation');
         }
     }
     $this->template->page_title = 'contextos';
     $this->template->content = $content;
 }
开发者ID:sysdevbol,项目名称:entidad,代码行数:24,代码来源:contextos.php

示例14: array_flatten

 /**
  * Flatten a multi-dimensional array into a single level.
  *
  * @param  array  $array
  * @return array
  */
 function array_flatten($array)
 {
     return Arr::flatten($array);
 }
开发者ID:runningjack,项目名称:busticketAPI1,代码行数:10,代码来源:helpers.php

示例15: flatten

 /**
  * Get a flattened array of the items in the collection.
  *
  * @param  int  $depth
  * @return static
  */
 public function flatten($depth = INF)
 {
     return new static(Arr::flatten($this->items, $depth));
 }
开发者ID:danteay,项目名称:CorePHPMapper,代码行数:10,代码来源:Collection.php


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