• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Utility\Text类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: leadPlus

 /**
  * Show truncated long text and hide full version for flyout
  * 
  * When there is a lot of text for a small area, this shows just the 
  * truncated lead. The full text is in an element that is hidden. 
  * Javascript or css can implement a flyout to show the full thing.
  * 
  * Attributes:
  *	$filed.leadPlus =>
  *		div			// div containing the hidden full text
  *		p			// div > p containg the full text
  *		span		// div + span containg truncated text
  *		truncate	// [truncate][limit] charcter count in truncated text
  * 
  * @param type $helper
  */
 public function leadPlus($field)
 {
     if (!$this->hasUuid()) {
         $uuid = new Uuid();
     } else {
         $uuid = $this->helper->entity->_uuid;
     }
     // established passed and default attributes
     $passed_attributes = $this->helper->attributes("{$field}.leadPlus");
     $default = new \Cake\Collection\Collection(['full_text' => ['span' => ['id' => $uuid->uuid('full'), 'class' => 'full_text', 'style' => 'cursor: pointer; display: none;', 'onclick' => 'var id = this.id.replace("full", "truncated"); this.style.display = "none"; document.getElementById(id).style.display = "inline-block";']], 'truncated_text' => ['span' => ['id' => $uuid->uuid('truncated'), 'class' => 'truncated_text', 'style' => 'cursor: pointer; display: inline-block;', 'onclick' => 'var id = this.id.replace("truncated", "full"); this.style.display = "none"; document.getElementById(id).style.display = "inline-block";']], 'truncate' => ['limit' => [100]], 'p' => []]);
     // intermediary values for calculations
     $key_template = $default->map(function ($value, $key) {
         return null;
     });
     // this yeilds array with all keys. values will be int if passed in, null if default
     $attribute_keys = array_flip(array_keys($passed_attributes)) + $key_template->toArray();
     // get attributes to use during rendering
     $attribute = $default->map(function ($value, $key) use($attribute_keys, $passed_attributes) {
         if (is_null($attribute_keys[$key])) {
             return $value;
         } else {
             return array_merge($value, $passed_attributes[$key]);
         }
     })->toArray();
     // output
     // SOMEONE SORT THIS OUT TO MAKE IT HAVE DEFAULT out-of-the-box BEHAVIOR
     $hidden = $this->helper->Html->tag('span', $this->helper->entity->{$field}, $attribute['full_text']['span']);
     $text = $this->helper->Html->tag('span', Text::truncate($this->helper->entity->{$field}, $attribute['truncate']['limit']), $attribute['truncated_text']['span']);
     return $this->helper->Html->tag('p', $text . $hidden, $attribute['p']);
 }
开发者ID:OrigamiStructures,项目名称:foldingTime,代码行数:46,代码来源:ColumnOutput.php


示例2: upload

 public function upload()
 {
     try {
         $audioTable = TableRegistry::get('Audios');
         $dateTimeUtc = new \DateTimeZone('UTC');
         $now = new \DateTime('now', $dateTimeUtc);
         // Generate file name
         $serverDir = TMP . 'files' . DS;
         $serverFileName = Text::uuid() . '.wav';
         $uploadFullPath = $serverDir . $serverFileName;
         // Move file to temp location
         if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadFullPath)) {
             throw new \Exception('Cannot copy file to tmp location: ' . $uploadFullPath);
         }
         $uploadFullPath = $this->__convertToPhoneAudio($uploadFullPath);
         $data = ['file_name' => $_FILES['file']['name'], 'server_dir' => $serverDir, 'server_name' => $serverFileName, 'create_datetime' => $now];
         $audio = $audioTable->newEntity($data);
         $audioTable->save($audio);
         $response['status'] = 1;
         $response['audioId'] = $audio->audio_id;
     } catch (\Excaption $ex) {
         $response['status'] = 0;
         $response['message'] = $ex->getMessage();
     }
     $this->set(compact('response'));
     $this->set('_serialize', ['response']);
 }
开发者ID:Ytel-Inc,项目名称:ENS,代码行数:27,代码来源:AudioController.php


示例3: tabs

 /**
  * Create bootstrap tabs.
  *
  * @param array $data
  * @param string $id
  * @return string
  * @SuppressWarnings(PHPMD.ShortVariable)
  */
 public function tabs($id, array $data = [])
 {
     $i = 0;
     $output = [];
     foreach ($data as $key => $options) {
         $i++;
         $title = !is_array($options) ? $options : $key;
         $alias = Text::slug((string) Inflector::underscore($key), '-');
         if (is_string($options)) {
             $options = [];
         }
         $_options = ['linkOptions' => ['data-toggle' => 'tab']];
         if (isset($options['title'])) {
             $title = $options['title'];
             unset($options['title']);
         }
         $_options['linkOptions']['title'] = $title;
         if ($i == 1) {
             $_options = $this->addClass($_options, 'active');
         }
         $options = Hash::merge($_options, $options);
         $linkOptions = $options['linkOptions'];
         unset($options['linkOptions']);
         $link = $this->Html->link($title, '#' . $alias, $linkOptions);
         $output[] = $this->Html->tag('li', $link, $options);
     }
     return $this->Html->tag('ul', implode('', $output), ['class' => 'nav nav-tabs', 'id' => $id]);
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:36,代码来源:UnionHelper.php


示例4: getDescription

 /**
  * 
  */
 public function getDescription($data, $entity, $options)
 {
     $content = '';
     extract($options);
     if (isset($fields)) {
         if (is_array($fields)) {
             foreach ($fields as $field) {
                 if ($entity->has($field)) {
                     $temp = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
                         return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
                     }, $entity->{$field});
                     $temp = preg_replace('/&[a-z]+;/', '', $temp);
                     $temp = preg_replace('/<\\/[a-z]+><[a-z]+>/', ' ', $temp);
                     $temp = preg_replace('/[\\s]{1,}/', ' ', $temp);
                     $content .= strip_tags($temp);
                 }
             }
         } else {
             if ($entity->has($fields)) {
                 $temp = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
                     return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
                 }, $entity->{$fields});
                 $temp = preg_replace('/&[a-z]+;/', '', $temp);
                 $temp = preg_replace('/<\\/[a-z]+><[a-z]+>/', ' ', $temp);
                 $temp = preg_replace('/[\\s]{1,}/', ' ', $temp);
                 $content .= strip_tags($temp);
             }
         }
     }
     return Text::truncate($content, 160, ['ellipsis' => '', 'exact' => false, 'html' => false]);
 }
开发者ID:orgasmicnightmare,项目名称:cakephp-seo,代码行数:34,代码来源:SeoTrait.php


示例5: add

 /**
  * Add method
  *
  * @return void Redirects on successful add, renders view otherwise.
  */
 public function add()
 {
     $boletos = $this->Boletoxretornos->Boletos->find('all')->toArray();
     $arrayBoletos;
     $opBoletos;
     $i = 0;
     foreach ($boletos as $x) {
         $arrayBoletos[$i] = $x->id;
         $opBoletos[$i] = $x->inr_boleto;
         $i++;
     }
     $boletoxretorno = $this->Boletoxretornos->newEntity();
     if ($this->request->is('post')) {
         $boletoxretorno = $this->Boletoxretornos->patchEntity($boletoxretorno, $this->request->data);
         $boletoxretorno->id = Text::uuid();
         $boletoxretorno->boleto_id = $arrayBoletos[$boletoxretorno->boleto_id];
         if ($this->Boletoxretornos->save($boletoxretorno)) {
             $this->Flash->success(__('O retorno foi salvo.'));
             return $this->redirect(['action' => 'index']);
         } else {
             $this->Flash->error(__('O retorno não pôde ser salvo. Tente novamente.'));
         }
     }
     $this->set(compact('boletoxretorno', 'opBoletos'));
     $this->set('_serialize', ['boletoxretorno']);
 }
开发者ID:eversonjjo,项目名称:sce,代码行数:31,代码来源:BoletoxretornosController.php


示例6: add

 /**
  * Add method
  *
  * @return void Redirects on successful add, renders view otherwise.
  */
 public function add()
 {
     $participantes = $this->Boletos->Participantes->find('all')->toArray();
     $arrayParticipantes;
     $opParticipantes;
     $i = 0;
     foreach ($participantes as $x) {
         $opParticipantes[$i] = $x['cnm_participante'];
         $arrayParticipantes[$i] = $x['id'];
         $i++;
     }
     $boleto = $this->Boletos->newEntity();
     if ($this->request->is('post')) {
         $boleto = $this->Boletos->patchEntity($boleto, $this->request->data);
         $boleto->id = Text::uuid();
         $boleto->participante_id = $arrayParticipantes[$boleto->participante_id];
         if ($this->Boletos->save($boleto)) {
             $this->Flash->success(__('O boleto foi salvo.'));
             return $this->redirect(['action' => 'index']);
         } else {
             $this->Flash->error(__('O boleto não pôde ser salvo. Tente novamente.'));
         }
     }
     $this->set(compact('boleto', 'opParticipantes'));
     $this->set('_serialize', ['boleto']);
 }
开发者ID:eversonjjo,项目名称:sce,代码行数:31,代码来源:BoletosController.php


示例7: add

 /**
  * Add method
  *
  * @return void Redirects on successful add, renders view otherwise.
  */
 public function add($idSub)
 {
     $submissoes = $this->Submissaoxcoautores->Submissoes->find('all')->toArray();
     $i = 0;
     $arraySubmissoes;
     $opSubmissoes;
     foreach ($submissoes as $x) {
         $arraySubmissoes[$i] = $x->id;
         $opSubmissoes[$i] = $x->ctl_submissao;
         $i++;
     }
     $submissaoxcoautore = $this->Submissaoxcoautores->newEntity();
     if ($this->request->is('post')) {
         $submissaoxcoautore = $this->Submissaoxcoautores->patchEntity($submissaoxcoautore, $this->request->data);
         $submissaoxcoautore->id = Text::uuid();
         $submissaoxcoautore->submissao_id = $idSub;
         //$arraySubmissoes[$submissaoxcoautore->submissao_id];
         if ($this->Submissaoxcoautores->save($submissaoxcoautore)) {
             $this->Flash->success(__('O coautor foi salvo.'));
             return $this->redirect(['controller' => 'Submissoes', 'action' => 'index']);
         } else {
             $this->Flash->error(__('O coautor não pôde ser salvo. Tente novamente.'));
         }
     }
     $this->set(compact('submissaoxcoautore', 'opSubmissoes'));
     $this->set('_serialize', ['submissaoxcoautore']);
 }
开发者ID:eversonjjo,项目名称:sce,代码行数:32,代码来源:SubmissaoxcoautoresController.php


示例8: _getSlug

 /**
  * Gets the tag slug (virtual field)
  * @return string|null
  */
 protected function _getSlug()
 {
     if (empty($this->_properties['tag'])) {
         return null;
     }
     return Text::slug($this->_properties['tag']);
 }
开发者ID:mirko-pagliai,项目名称:me-cms,代码行数:11,代码来源:Tag.php


示例9: add

 public function add()
 {
     $clientInfo = $this->ClientInfos->newEntity();
     if ($this->request->is('post')) {
         $userid = Text::uuid();
         $contactid = Text::uuid();
         $clientid = Text::uuid();
         $this->loadModel('Users');
         $users = $this->Users->newEntity();
         $users = $this->Users->patchEntity($users, $this->request->data['Users']);
         $this->Users->save($users);
         $this->loadModel('ClientInfos');
         $clientInfos = $this->ClientInfos->newEntity();
         $clientInfos = $this->ClientInfos->patchEntity($clientInfos, $this->request->data['ClientInfos']);
         $this->ClientInfos->save($clientInfos);
         $this->loadModel('ClientContacts');
         $clientContacts = $this->ClientContacts->newEntity();
         $clientContacts = $this->ClientContacts->patchEntity($clientContacts, $this->request->data['ClientContacts']);
         $this->ClientContacts->save($clientContacts);
         return $this->redirect(['controller' => 'ClientDevices', 'action' => 'add']);
     }
     $clientTypes = $this->ClientInfos->ClientTypes->find('list', ['limit' => 200]);
     $companyTypes = $this->ClientInfos->CompanyTypes->find('list', ['limit' => 200]);
     $this->set(compact('clientInfo', 'clientTypes', 'companyTypes'));
     $this->set('_serialize', ['clientInfo']);
 }
开发者ID:julkar9,项目名称:ntrack,代码行数:26,代码来源:ClientInfosController.php


示例10: render

 /**
  * Render a text widget or other simple widget like email/tel/number.
  *
  * This method accepts a number of keys:
  *
  * - `name` The name attribute.
  * - `val` The value attribute.
  * - `escape` Set to false to disable escaping on all attributes.
  *
  * Any other keys provided in $data will be converted into HTML attributes.
  *
  * @param array $data The data to build an input with.
  * @param \Cake\View\Form\ContextInterface $context The current form context.
  * @return string
  */
 public function render(array $data, ContextInterface $context)
 {
     $data += ['name' => '', 'val' => null, 'type' => 'text', 'mode' => 'datetime', 'escape' => true, 'readonly' => true, 'templateVars' => []];
     // mode value and class
     $mode = $data['mode'];
     $hval = $data['value'] = $data['val'];
     $data['class'] = $data['type'];
     unset($data['val'], $data['mode']);
     // transform into frozen time if not already
     if (!($data['value'] instanceof FrozenTime || $data['value'] instanceof FrozenDate)) {
         $data['value'] = new FrozenTime($data['value']);
     }
     // transform values
     if ($mode == 'datetime') {
         $hval = $data['value']->format('Y-m-d H:i:s');
         $data['value'] = $data['value']->format('d-M-Y H:i:s');
     }
     if ($mode == 'date') {
         $hval = $data['value']->format('Y-m-d');
         $data['value'] = $data['value']->format('d-M-Y');
     }
     if ($mode == 'time') {
         $hval = $data['value'] = $data['value']->format('H:i:s');
     }
     // render
     $rand = Text::uuid();
     return "<div id='{$rand}' style='position: relative;'>" . $this->_templates->format('input', ['name' => $data['name'], 'type' => 'hidden', 'attrs' => $this->_templates->formatAttributes(['value' => $hval])]) . $this->_templates->format('input', ['name' => $data['name'] . '-' . $rand, 'type' => $mode, 'templateVars' => $data['templateVars'], 'attrs' => $this->_templates->formatAttributes($data, ['name', 'type'])]) . "<div id='dtpicker-{$rand}'></div><scriptend>\$(document).ready(Backend.DTPicker('{$rand}', '{$mode}'));</scriptend></div>";
 }
开发者ID:unimatrix,项目名称:cakephp-utility,代码行数:43,代码来源:DTPickerWidget.php


示例11: slug

 /**
  * Slug a field passed in the default config with its replacement.
  * @param $value The string that needs to be processed
  * @param $config The config array is passed here
  * @return string
  */
 private function slug($value = null, $config = [])
 {
     // generate slug
     $slug = strtolower(Text::slug($value, $config['replacement']));
     // unique slug?
     if ($config['unique']) {
         // does the slug already exist in db?
         $field = $this->_table->alias() . '.' . $config['slug'];
         $conditions = [$field => $slug];
         $suffix = '';
         $i = 0;
         // loop till unique slug is found
         while ($this->_table->exists($conditions)) {
             $i++;
             $suffix = $config['replacement'] . $i;
             $conditions[$field] = $slug . $suffix;
         }
         // got suffix? append it
         if ($suffix) {
             $slug .= $suffix;
         }
     }
     // return slug
     return $slug;
 }
开发者ID:unimatrix,项目名称:cakephp-utility,代码行数:31,代码来源:SluggableBehavior.php


示例12: ajaxSendCall

 public function ajaxSendCall()
 {
     try {
         $numberListTable = TableRegistry::get('NumberLists');
         $sendQueueTable = TableRegistry::get('SendQueues');
         $numberTable = TableRegistry::get('Numbers');
         // Check if list exists
         $numberList = $numberListTable->find('all', ['conditions' => ['number_list_id' => $this->request->data['call']['number_list_id']]]);
         if (!$numberList->count()) {
             throw new \Exception('Cannot locate list.');
         }
         $number = $numberTable->find('all', ['conditions' => ['number_list_id' => $this->request->data['call']['number_list_id']]]);
         $numberCount = $number->count();
         if (!$numberCount) {
             throw new \Exception('No numbers in the list');
         }
         $data = ['unique_id' => Text::uuid(), 'type' => 2, 'number_list_id' => $this->request->data['call']['number_list_id'], 'status' => 0, 'message' => $this->request->data['call']['message'], 'audio_id' => $this->request->data['call']['audio_id'], 'request_by' => null, 'total' => $numberCount, 'create_datetime' => new \DateTime('now', new \DateTimeZone('UTC'))];
         $sendQueue = $sendQueueTable->newEntity($data);
         $sendQueueTable->save($sendQueue);
         // Hit the cron
         shell_exec(ROOT . DS . 'bin' . DS . 'cake SendCall ' . $sendQueue->send_queue_id . ' > /dev/null 2>/dev/null &');
         $response['status'] = 1;
         $response['sendQueueId'] = $sendQueue->send_queue_id;
         $response['numberCount'] = $numberCount;
     } catch (\Exception $ex) {
         $response['status'] = 0;
         $response['message'] = $ex->getMessage();
     }
     $this->set(compact('response'));
     $this->set('_serialize', ['response']);
 }
开发者ID:Ytel-Inc,项目名称:ENS,代码行数:31,代码来源:CallController.php


示例13: run

 /**
  * Run Method.
  *
  * Write your database seeder using this method.
  *
  * More information on writing seeders is available here:
  * http://docs.phinx.org/en/latest/seeding.html
  *
  * @return void
  */
 public function run()
 {
     $time = date("Y-m-d H:i:s");
     $data = [['id' => Text::uuid(), 'email' => '[email protected]', 'username' => 'administrator', 'realname' => 'Administrator', 'password' => (new DefaultPasswordHasher())->hash('adminadmin'), 'created' => $time, 'modified' => $time, 'role' => 'admin', 'status' => '1', 'preferences' => json_encode(Cake\Core\Configure::read('cms.defaultUserPreferences'))]];
     $table = $this->table('users');
     $table->insert($data)->save();
 }
开发者ID:el-cms,项目名称:elabs,代码行数:17,代码来源:UsersSeed.php


示例14: findMap

 /**
  * Custom finder for map the ntofications.
  *
  * @param \Cake\ORM\Query $query The query finder.
  * @param array $options The options passed in the query builder.
  *
  * @return \Cake\ORM\Query
  */
 public function findMap(Query $query, array $options)
 {
     return $query->formatResults(function ($notifications) use($options) {
         return $notifications->map(function ($notification) use($options) {
             $notification->data = unserialize($notification->data);
             switch ($notification->type) {
                 case 'conversation.reply':
                     $username = $notification->data['sender']->username;
                     $conversationTitle = Text::truncate($notification->data['conversation']->title, 50, ['ellipsis' => '...', 'exact' => false]);
                     //Check if the creator of the conversation is the current user.
                     if ($notification->data['conversation']->user_id === $options['session']->read('Auth.User.id')) {
                         $notification->text = __('<strong>{0}</strong> has replied in your conversation <strong>{1}</strong>.', h($username), h($conversationTitle));
                     } else {
                         $notification->text = __('<strong>{0}</strong> has replied in the conversation <strong>{1}</strong>.', h($username), h($conversationTitle));
                     }
                     $notification->link = Router::url(['controller' => 'conversations', 'action' => 'go', $notification->data['conversation']->last_message_id, 'prefix' => false]);
                     break;
                 case 'bot':
                     $notification->text = __('Welcome on <strong>{0}</strong>! You can now post your first comment in the blog.', \Cake\Core\Configure::read('Site.name'));
                     $notification->link = Router::url(['controller' => 'blog', 'action' => 'index', 'prefix' => false]);
                     $notification->icon = $notification->data['icon'];
                     break;
                 case 'badge':
                     $notification->text = __('You have unlock the badge "{0}".', $notification->data['badge']->name);
                     $notification->link = Router::url(['_name' => 'users-profile', 'id' => $notification->data['user']->id, 'slug' => $notification->data['user']->username, '#' => 'badges', 'prefix' => false]);
                     break;
             }
             return $notification;
         });
     });
 }
开发者ID:Xety,项目名称:Xeta,代码行数:39,代码来源:NotificationsTable.php


示例15: groupLink

 /**
  * group link function
  * @param string $title title for menu link
  * @param array $urls force array
  * @param array $options configure for link
  * @return string inside <li> tag
  */
 public function groupLink($title, array $urls = [], array $options = [])
 {
     $result = '<li class="panel panel-default dropdown">';
     $controller = $this->Html->request->controller;
     foreach ($urls as $k => $v) {
         if (isset($v[1]) && $controller === $v[1]['controller']) {
             $result = '<li class="active panel panel-default dropdown">';
             break;
         }
     }
     $collapseId = Text::uuid();
     $result .= $this->Html->link($title, '#' . $collapseId, ['data-toggle' => 'collapse', 'escape' => false]);
     $result .= '<div id="' . $collapseId . '" class="panel-collapse collapse">';
     $result .= '<div class="panel-body">';
     $result .= '<ul class="nav navbar-nav">';
     foreach ($urls as $k => $v) {
         if (empty($v[0]) || empty($v[1])) {
             continue;
         }
         $result .= '<li>' . $this->Html->link($v[0], $v[1]) . '</li>';
     }
     $result .= '</ul>';
     $result .= '</div>';
     $result .= '</div>';
     $result .= '</li>';
     return $result;
 }
开发者ID:crabstudio,项目名称:app,代码行数:34,代码来源:MenuHelper.php


示例16: getName

 /**
  * @return string
  */
 public function getName()
 {
     if (empty($this->name)) {
         $this->name = Text::uuid();
     }
     return $this->name;
 }
开发者ID:slince,项目名称:mechanic,代码行数:10,代码来源:TestSuite.php


示例17: _getExcerpt

 protected function _getExcerpt()
 {
     if (array_key_exists('body', $this->_properties)) {
         return Text::excerpt($this->_properties['body'], 'method', 400);
     }
     return null;
 }
开发者ID:cakemanager,项目名称:cakeadmin-cms,代码行数:7,代码来源:Blog.php


示例18: send

 public function send($data, $old_data = null)
 {
     if (!empty($data)) {
         $filename = $data['name'];
         $file_tmp_name = $data['tmp_name'];
         $dir_root = WWW_ROOT . 'img' . DS . 'uploads';
         $dir = 'uploads';
         $allowed = array('png', 'jpg', 'jpeg');
         if (!in_array(substr(strrchr($filename, '.'), 1), $allowed)) {
             return false;
         } elseif (is_uploaded_file($file_tmp_name)) {
             if ($old_data != null) {
                 $old_file = substr(strrchr($old_data, DS), 1);
                 if (file_exists($dir_root . DS . $old_file)) {
                     unlink($dir_root . DS . $old_file);
                 }
             }
             $file = Text::uuid() . '-' . $filename;
             // enregistrement du nom du fichier
             $file_root = $dir_root . DS . $file;
             // definition du chemin ou sera stocker le fichier
             move_uploaded_file($file_tmp_name, $file_root);
             // deplacement du fichier
             $filedb = $dir . DS . $file;
             // definition du chemin qui sera utilise dans la base de donnee
             return $filedb;
         }
     }
 }
开发者ID:wilrona,项目名称:ApplicationDT,代码行数:29,代码来源:UploadComponent.php


示例19: request_id

 private static function request_id()
 {
     if (empty(self::$_request_id)) {
         self::$_request_id = Text::uuid();
     }
     return self::$_request_id;
 }
开发者ID:snelg,项目名称:cakephp-audit-log,代码行数:7,代码来源:AuditableBehavior.php


示例20: add

 /**
  * Add method
  *
  * @return void Redirects on successful add, renders view otherwise.
  */
 public function add()
 {
     $municipios = $this->Locais->Municipios->find('all')->toArray();
     $array;
     $op;
     $i = 0;
     foreach ($municipios as $x) {
         $op[$i] = $x['cnm_municipio'] . ' (' . $x['ccd_municipio'] . ')';
         $array[$i] = $x['id'];
         $i++;
     }
     $local = $this->Locais->newEntity();
     if ($this->request->is('post')) {
         $local = $this->Locais->patchEntity($local, $this->request->data);
         $local->id = Text::uuid();
         $local->municipio_id = $array[$local->municipio_id];
         if ($this->Locais->save($local)) {
             $this->Flash->success(__('O local foi salvo.'));
             return $this->redirect(['action' => 'index']);
         } else {
             $this->Flash->error(__('O local não pôde ser salvo. Tente novamente.'));
         }
     }
     $this->set(compact('local', 'op'));
     $this->set('_serialize', ['local']);
 }
开发者ID:eversonjjo,项目名称:sce,代码行数:31,代码来源:LocaisController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Validation\Validator类代码示例发布时间:2022-05-23
下一篇:
PHP Utility\Security类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap