本文整理汇总了PHP中Cake\Utility\Hash::combine方法的典型用法代码示例。如果您正苦于以下问题:PHP Hash::combine方法的具体用法?PHP Hash::combine怎么用?PHP Hash::combine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Utility\Hash
的用法示例。
在下文中一共展示了Hash::combine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAll
/**
* Getting all aco records as tree
* @return array
*/
public function getAll()
{
$acos = $this->Acos->find()->toArray();
$acos = Hash::combine($acos, '{n}.name', '{n}');
ksort($acos);
// $acos = Hash::expand($acos, '/');
return $acos;
}
示例2: index
/**
* Index method
*
* @return \Cake\Network\Response|null
*/
public function index()
{
$treeRoles = $this->Roles->find('treeList')->toArray();
$roles = $this->Roles->find('all')->toArray();
$roles = Hash::combine($roles, '{n}.id', '{n}');
$this->set(compact('roles', 'treeRoles'));
$this->set('_serialize', ['roles']);
}
示例3: main
public function main()
{
try {
$DEFAULT_URL = 'https://ens.firebaseio.com/';
$DEFAULT_TOKEN = Configure::read('Firebase.token');
$DEFAULT_PATH = '/sms';
$firebase = new \Firebase\FirebaseLib($DEFAULT_URL, $DEFAULT_TOKEN);
if (!isset($this->args[0])) {
throw new \Exception('Missing queue ID');
}
$this->out('Start...');
$sendQueueTable = TableRegistry::get('SendQueues');
$numberTable = TableRegistry::get('Numbers');
$dateTimeUtc = new \DateTimeZone('UTC');
$now = new \DateTime('now', $dateTimeUtc);
$sendQueue = $sendQueueTable->find('all', ['conditions' => ['type' => 1, 'send_queue_id' => $this->args[0], 'OR' => ['next_try_datetime IS NULL', 'next_try_datetime <=' => $now]]]);
if (!$sendQueue->count()) {
throw new \Exception('No more queue');
}
$firstQueue = $sendQueue->first();
// Mark as being processed...
$firebase->set($DEFAULT_PATH . '/' . $firstQueue->send_queue_id . '/status', 1);
$firstQueue->status = 1;
$firstQueue->start_datetime = $now;
$sendQueueTable->save($firstQueue);
// Mark as sending...
$firebase->set($DEFAULT_PATH . '/' . $firstQueue->send_queue_id . '/status', 2);
$firstQueue->status = 2;
$sendQueueTable->save($firstQueue);
$page = 1;
while (true) {
$numbers = $numberTable->find('all', ['fields' => ['number_id', 'number_list_id', 'country_code', 'phone_number'], 'conditions' => ['number_list_id' => $firstQueue->number_list_id], 'limit' => 5000, 'page' => $page]);
$list = $numbers->toArray();
if (!count($list)) {
break;
}
// Format the number for Firebase
$numberForFb = Hash::combine($list, '{n}.number_id', '{n}');
$this->out(json_encode($numberForFb));
$this->out($page);
// Put the all the number on Firebase
$firebase->update($DEFAULT_PATH . '/' . $firstQueue->send_queue_id . '/numbers', $numberForFb);
// Send SMS
foreach ($numbers as $number) {
shell_exec(ROOT . DS . 'bin' . DS . 'cake SendSmsBackground ' . $firstQueue->send_queue_id . ' ' . $number->number_id . ' ' . $number->country_code . ' ' . $number->phone_number . ' "THIS IS A TEST! ' . $firstQueue->message . '" > /dev/null 2>/dev/null &');
usleep(10000);
}
$page++;
}
// Mark as done...
$firebase->set($DEFAULT_PATH . '/' . $firstQueue->send_queue_id . '/status', 3);
$firstQueue->status = 3;
$firstQueue->end_datetime = new \DateTime('now', $dateTimeUtc);
$sendQueueTable->save($firstQueue);
} catch (\Exception $ex) {
$this->out($ex->getMessage());
}
}
示例4: getCategories
/**
* Finds all the categories
*
* @param string $extensionName The extension to get the categories for
* @return array The categories and all their settings
* @throws InternalErrorException Thrown if the extension entry could not be found or there are no categories
*/
public function getCategories($extensionName)
{
$extension = $this->_getExtension($extensionName);
$categories = $extension->categories;
if (empty($categories)) {
throw new InternalErrorException(__('No categories were found for the extension {0}.', $extension->name) . '\\n' . __('Refer to the author\'s help page for help with this extension.'));
}
$categories = Hash::combine($categories, '{n}.id', '{n}');
foreach ($categories as $category) {
$category->settings = Hash::combine($category->settings, '{n}.id', '{n}');
}
return $categories;
}
示例5: edit
public function edit($id = null)
{
if (!$this->isAuthorizedForClub($id)) {
return $this->redirect(['action' => 'index']);
}
try {
$club = $this->Clubs->getForEdit($id);
} catch (InvalidPrimaryKeyException $e) {
//Usually happens when attempting to go to "/edit" with no
//id specified at all. Just go back to index with no further
//message
return $this->redirect(['action' => 'index']);
} catch (RecordNotFoundException $e) {
$this->Flash->error('Club not found');
return $this->redirect(['action' => 'index']);
}
if ($this->request->is(['patch', 'post', 'put'])) {
//Hack for old, incomplete imported data:
if (empty($this->request->data['advisor']['net_id'])) {
unset($this->request->data['advisor']);
}
if (!empty($this->request->data['members']) && is_array($this->request->data['members'])) {
foreach ($this->request->data['members'] as $memberIndex => $member) {
if (empty($member['net_id'])) {
unset($this->request->data['members'][$memberIndex]);
}
}
}
$club = $this->Clubs->officerPatch($club, $this->request->data);
if ($this->Clubs->save($club)) {
$this->Flash->success("{$club->name} changes saved");
if ($newStatus = $this->Clubs->autoStatus($club->id)) {
$this->Flash->set("Your changes have automatically reset the club status to {$newStatus}", ['element' => $newStatus == "Recognized" ? 'success' : 'warning']);
}
return $this->redirect(['action' => 'view', $id]);
} else {
$this->Flash->error('Error saving changes');
}
}
$this->loadModel('Departments');
$departments = Hash::combine($this->Departments->getList(), '{n}.dept_name', '{n}.sort_name');
$categories = $this->Clubs->Categories->find('list');
$types = array_combine($this->Clubs->types, $this->Clubs->types);
$statuses = array_combine($this->Clubs->statuses, $this->Clubs->statuses);
$advisorStatuses = array_combine($this->Clubs->Advisors->statuses, $this->Clubs->Advisors->statuses);
$officerStatuses = $this->Clubs->Members->Officers->statuses;
$riskEstimates = $this->Clubs->riskEstimates;
$this->set(compact('club', 'categories', 'types', 'statuses', 'departments', 'advisorStatuses', 'officerStatuses', 'riskEstimates'));
}
示例6: _getSettings
/**
* Finds all the categories
*
* @param Table $extensionsTable The extensions database table
* @return array The categories and all their settings
*/
protected function _getSettings(Table $extensionsTable)
{
$extensions = $extensionsTable->find('all', ['fields' => ['Extensions.id', 'Extensions.short_name'], 'contain' => ['Categories' => ['fields' => ['Categories.id', 'Categories.extension_id', 'Categories.short_name', 'Categories.enabled'], 'Settings' => ['fields' => ['Settings.short_name', 'Settings.category_id', 'Settings.default_value'], 'SettingValues' => ['fields' => ['SettingValues.value']]]]]])->all()->toArray();
$extensions = Hash::combine($extensions, '{n}.short_name', '{n}');
foreach ($extensions as $extension) {
$extension->categories = Hash::combine($extension->categories, '{n}.short_name', '{n}');
foreach ($extension->categories as $category) {
$category->settings = Hash::combine($category->settings, '{n}.short_name', '{n}');
foreach ($category->settings as $setting) {
if (isset($setting->setting_value->value)) {
$setting->setting_value = $setting->setting_value->value;
}
}
}
}
return $extensions;
}
示例7: testCombineWithFormatting
/**
* Test combine with formatting rules.
*
* @return void
*/
public function testCombineWithFormatting()
{
$a = static::userData();
$result = Hash::combine($a, '{n}.User.id', ['%1$s: %2$s', '{n}.User.Data.user', '{n}.User.Data.name'], '{n}.User.group_id');
$expected = [1 => [2 => 'mariano.iglesias: Mariano Iglesias', 25 => 'gwoo: The Gwoo'], 2 => [14 => 'phpnut: Larry E. Masters']];
$this->assertEquals($expected, $result);
$result = Hash::combine($a, ['%s: %s', '{n}.User.Data.user', '{n}.User.Data.name'], '{n}.User.id');
$expected = ['mariano.iglesias: Mariano Iglesias' => 2, 'phpnut: Larry E. Masters' => 14, 'gwoo: The Gwoo' => 25];
$this->assertEquals($expected, $result);
$result = Hash::combine($a, ['%1$s: %2$d', '{n}.User.Data.user', '{n}.User.id'], '{n}.User.Data.name');
$expected = ['mariano.iglesias: 2' => 'Mariano Iglesias', 'phpnut: 14' => 'Larry E. Masters', 'gwoo: 25' => 'The Gwoo'];
$this->assertEquals($expected, $result);
$result = Hash::combine($a, ['%2$d: %1$s', '{n}.User.Data.user', '{n}.User.id'], '{n}.User.Data.name');
$expected = ['2: mariano.iglesias' => 'Mariano Iglesias', '14: phpnut' => 'Larry E. Masters', '25: gwoo' => 'The Gwoo'];
$this->assertEquals($expected, $result);
}
示例8: catch
$db->close();
$this->flash->flashLater('success', 'Profile information successfuly updated! Congratulation!');
return $response->withStatus(302)->withHeader('Location', $this->router->pathFor('membership-profile'));
} catch (Exception $e) {
$db->rollback();
$db->close();
$this->flash->flashNow('error', 'System failed<br />' . $e->getMessage());
}
} else {
$this->flash->flashNow('warning', 'Some of mandatory fields is empty!');
}
}
$q_member = $db->createQueryBuilder()->select('m.*', 'reg_prv.regional_name AS province', 'reg_cit.regional_name AS city')->from('members_profiles', 'm')->leftJoin('m', 'regionals', 'reg_prv', 'reg_prv.id = m.province_id')->leftJoin('m', 'regionals', 'reg_cit', 'reg_cit.id = m.city_id')->where('m.user_id = :uid')->setParameter(':uid', $_SESSION['MembershipAuth']['user_id'])->execute();
$q_members_socmeds = $db->createQueryBuilder()->select('member_socmed_id', 'socmed_type', 'account_name', 'account_url')->from('members_socmeds')->where('user_id = :uid')->andWhere('deleted = :d')->setParameter(':uid', $_SESSION['MembershipAuth']['user_id'])->setParameter(':d', 'N')->execute();
$q_provinces = $db->createQueryBuilder()->select('id', 'regional_name')->from('regionals')->where('parent_id IS NULL')->andWhere('city_code = :ccode')->orderBy('province_code, city_code')->setParameter(':ccode', '00', \Doctrine\DBAL\Types\Type::STRING)->execute();
$q_cities = $db->createQueryBuilder()->select('id', 'regional_name')->from('regionals')->where('parent_id = :pvid')->orderBy('province_code, city_code')->setParameter(':pvid', $_SESSION['MembershipAuth']['province_id'], \Doctrine\DBAL\Types\Type::INTEGER)->execute();
$q_religions = $db->createQueryBuilder()->select('religion_id', 'religion_name')->from('religions')->execute();
$q_jobs = $db->createQueryBuilder()->select('job_id')->from('jobs')->execute();
$member = $q_member->fetch();
$members_socmeds = $q_members_socmeds->fetchAll();
$provinces = \Cake\Utility\Hash::combine($q_provinces->fetchAll(), '{n}.id', '{n}.regional_name');
$cities = \Cake\Utility\Hash::combine($q_cities->fetchAll(), '{n}.id', '{n}.regional_name');
$religions = \Cake\Utility\Hash::combine($q_religions->fetchAll(), '{n}.religion_id', '{n}.religion_name');
$jobs = \Cake\Utility\Hash::combine($q_jobs->fetchAll(), '{n}.job_id', '{n}.job_id');
$genders = array('female' => 'Wanita', 'male' => 'Pria');
$identity_types = array('ktp' => 'KTP', 'sim' => 'SIM', 'ktm' => 'Kartu Mahasiswa');
$socmedias = $this->getContainer()->get('settings')['socmedias'];
$db->close();
$this->view->getPlates()->addData(array('page_title' => 'Membership', 'sub_page_title' => 'Update Profile Anggota'), 'layouts::layout-system');
return $this->view->render($response, 'membership/profile-edit', compact('member', 'provinces', 'cities', 'genders', 'religions', 'identity_types', 'socmedias', 'members_socmeds', 'jobs'));
})->setName('membership-profile-edit');
开发者ID:nizarrahmat,项目名称:phpindonesia.or.id-membership2,代码行数:31,代码来源:membership-profile-edit-function.php
示例9: term
public function term()
{
$settings = TableRegistry::get('Settings');
$users = TableRegistry::get('Users');
$session = $this->request->session();
$user = $users->get($this->Auth->user('id'));
$now = Time::now();
$apiId = $settings->get('10')->text;
$apiToken = $settings->get('11')->text;
$apiBase = $settings->get('12')->text;
if (is_null($user->osm_secret) || !$session->check('OSM.Secret')) {
$this->Flash->error(__('Please link your account first'));
return $this->redirect(['action' => 'link']);
} elseif (is_null($user->osm_section_id)) {
$this->Flash->error(__('Please set your section first'));
return $this->redirect(['action' => 'section']);
} else {
$userOsmId = $user->osm_user_id;
$userOsmSecret = $user->osm_secret . $session->read('OSM.Secret');
$userOsmSection = $user->osm_section_id;
}
$http = new Client(['host' => $apiBase, 'scheme' => 'https']);
$url = '/api.php?action=getTerms';
$response = $http->post($url, ['userid' => $userOsmId, 'secret' => $userOsmSecret, 'token' => $apiToken, 'apiid' => $apiId]);
if ($response->isOk()) {
$preBody = $response->json;
// Debugger::dump($preBody);
$body = Hash::get($preBody, $user->osm_section_id);
// Debugger::dump($body);
$terms = Hash::combine($body, '{n}.termid', '{n}', '{n}.past');
// Debugger::dump($terms);
$term = Hash::get($terms, 1);
//Debugger::dump($term);
//$term_end = $term->enddate;
foreach ($term as $term) {
$startdate = Hash::get($term, 'startdate');
$start = Time::parse($startdate);
$enddate = Hash::get($term, 'enddate');
$end = Time::parse($enddate);
$count = 0;
if ($start < $now && $end > $now) {
$count = $count + 1;
$termSel = $term;
}
}
if ($count == 1) {
$termId = Hash::get($termSel, 'termid');
$termEndDate = Hash::get($termSel, 'enddate');
$termEnd = Time::parse($termEndDate);
$usrData = ['osm_current_term' => $termId, 'osm_term_end' => $termEnd, 'osm_linked' => 3];
$users->patchEntity($user, $usrData);
if ($users->save($user)) {
$this->Flash->success(__('Your OSM Term has been set.'));
return $this->redirect(['action' => 'home']);
} else {
$this->Flash->error(__('The user could not be saved. Please, try again.'));
return $this->redirect(['action' => 'home']);
}
} else {
$this->Flash->error(__('More than 1 Term Applies.'));
}
} else {
$this->Flash->error(__('There was a request error, please try again.'));
return $this->redirect(['action' => 'home']);
}
}
示例10: getSelect
/**
* Get an array of key -> values for a select.
*
* @return array
*/
public static function getSelect()
{
return Hash::combine(self::getConstants(), '{s}.value', '{s}.name');
}
示例11: getReport
/**
* Returns an array used in browser-based and Excel reports
*
* @return array
*/
public function getReport()
{
$report = [];
$communitiesTable = TableRegistry::get('Communities');
$communities = $communitiesTable->find('all')->select(['id', 'name', 'score', 'notes'])->where(['dummy' => 0])->contain(['ParentAreas' => function ($q) {
return $q->select(['id', 'name', 'fips']);
}, 'OfficialSurvey' => function ($q) {
return $q->select(['id', 'alignment']);
}, 'OrganizationSurvey' => function ($q) {
return $q->select(['id', 'alignment']);
}])->order(['Communities.name' => 'ASC']);
$respondentsTable = TableRegistry::get('Respondents');
$respondents = $respondentsTable->find('all')->select(['id', 'approved', 'invited', 'survey_id'])->contain(['Responses' => function ($q) {
return $q->select(['id', 'respondent_id']);
}])->toArray();
$respondents = Hash::combine($respondents, '{n}.id', '{n}', '{n}.survey_id');
$responsesTable = TableRegistry::get('Responses');
$surveysTable = TableRegistry::get('Surveys');
$sectors = $surveysTable->getSectors();
foreach ($communities as $community) {
// Collect general information about this community
$report[$community->id] = ['name' => $community->name, 'parentArea' => $community->parent_area->name, 'parentAreaFips' => $community->parent_area->fips, 'presentationsGiven' => ['a' => 'No', 'b' => 'No', 'c' => 'No'], 'notes' => $community->notes];
// Collect information about survey responses and alignment
$surveyTypes = ['official_survey' => $community->official_survey, 'organization_survey' => $community->organization_survey];
foreach ($surveyTypes as $key => $survey) {
$invitationCount = 0;
$approvedResponseCount = 0;
$responseRate = 'N/A';
if ($survey && isset($respondents[$survey->id])) {
foreach ($respondents[$survey->id] as $respondent) {
if ($respondent->invited) {
$invitationCount++;
}
if ($respondent->approved && !empty($respondent->responses)) {
$approvedResponseCount++;
}
}
if ($invitationCount) {
$responseRate = round($approvedResponseCount / $invitationCount * 100) . '%';
} else {
$responseRate = 'N/A';
}
}
// Format and sum internal alignment
$internalAlignment = [];
if ($survey) {
$internalAlignment = $responsesTable->getInternalAlignmentPerSector($survey->id);
if ($internalAlignment) {
foreach ($internalAlignment as $sector => &$value) {
$value = round($value, 1);
}
$internalAlignment['total'] = array_sum($internalAlignment);
}
}
if (!$internalAlignment) {
$internalAlignment = array_combine($sectors, [null, null, null, null, null]);
$internalAlignment['total'] = null;
}
// Determine status
$correspondingStep = $key == 'official_survey' ? 2 : 3;
if ($community->score < $correspondingStep) {
$status = 'Not started yet';
} elseif ($community->score < $correspondingStep + 1) {
$status = 'In progress';
} else {
$status = 'Complete';
}
// PWRRR alignment
if ($survey) {
$alignment = $survey->alignment ? $survey->alignment . '%' : null;
$alignmentCalculated = $survey->alignment ? 'Yes' : 'No';
} else {
$alignment = null;
$alignmentCalculated = 'No';
}
$report[$community->id][$key] = ['invitations' => $invitationCount, 'responses' => $approvedResponseCount, 'responseRate' => $responseRate, 'alignment' => $alignment, 'alignmentCalculated' => $alignmentCalculated, 'internalAlignment' => $internalAlignment, 'status' => $status];
}
}
return $report;
}
示例12: getGroupedList
/**
* Returns an array of ['Capitalized-type' => [$areaId => $areaName], ...]
*
* @return array
*/
public function getGroupedList()
{
$result = $this->find('all')->select(['id', 'name', 'type'])->order(['name' => 'ASC'])->toArray();
$grouped = Hash::combine($result, '{n}.id', '{n}.name', '{n}.type');
// Unfortunately, this (apparently) can't be accomplished with text-transform: capitalize
// because area types are displayed in <optgroup label="areatype">
$capitalizedGrouped = [];
foreach ($grouped as $type => $areas) {
$type = ucwords($type);
$capitalizedGrouped[$type] = $areas;
}
return $capitalizedGrouped;
}
示例13: array
$db = $this->getContainer()->get('db');
if ($request->isPost()) {
$validator = $this->getContainer()->get('validator');
$validator->createInput($_POST);
$validator->rule('required', array('company_name', 'industry_id', 'start_date_y', 'work_status', 'job_title', 'job_desc', 'career_level_id'));
if ($_POST['work_status'] == 'R') {
$validator->rule('required', 'end_date_y');
}
if ($validator->validate()) {
if ($_POST['work_status'] == 'A') {
$_POST['end_date_y'] = null;
$_POST['end_date_m'] = null;
$_POST['end_date_d'] = null;
}
$db->insert('members_portfolios', array('user_id' => $_SESSION['MembershipAuth']['user_id'], 'company_name' => filter_var(trim($_POST['company_name']), FILTER_SANITIZE_STRING), 'industry_id' => filter_var(trim($_POST['industry_id']), FILTER_SANITIZE_STRING), 'start_date_y' => filter_var(trim($_POST['start_date_y']), FILTER_SANITIZE_STRING), 'start_date_m' => $_POST['start_date_m'] == '' ? null : filter_var(trim($_POST['start_date_m']), FILTER_SANITIZE_STRING), 'start_date_d' => $_POST['start_date_d'] == '' ? null : filter_var(trim($_POST['start_date_d']), FILTER_SANITIZE_STRING), 'end_date_y' => filter_var(trim($_POST['end_date_y']), FILTER_SANITIZE_STRING), 'end_date_m' => $_POST['end_date_m'] == '' ? null : filter_var(trim($_POST['end_date_m']), FILTER_SANITIZE_STRING), 'end_date_d' => $_POST['end_date_d'] == '' ? null : filter_var(trim($_POST['end_date_d']), FILTER_SANITIZE_STRING), 'work_status' => filter_var(trim($_POST['work_status']), FILTER_SANITIZE_STRING), 'job_title' => filter_var(trim($_POST['job_title']), FILTER_SANITIZE_STRING), 'job_desc' => filter_var(trim($_POST['job_desc']), FILTER_SANITIZE_STRING), 'career_level_id' => filter_var(trim($_POST['career_level_id']), FILTER_SANITIZE_STRING), 'created' => date('Y-m-d H:i:s'), 'created_by' => $_SESSION['MembershipAuth']['user_id'], 'deleted' => 'N'));
$this->flash->flashLater('success', 'Item portfolio baru berhasil ditambahkan. Selamat! . Silahkan tambahkan lagi item portfolio anda.');
return $response->withStatus(302)->withHeader('Location', $this->router->pathFor('membership-profile'));
} else {
$this->flash->flashNow('warning', 'Masih ada isian-isian wajib yang belum anda isi. Atau masih ada isian yang belum diisi dengan benar');
}
}
$q_carerr_levels = $db->createQueryBuilder()->select('career_level_id')->from('career_levels')->orderBy('order_by', 'ASC')->execute();
$q_industries = $db->createQueryBuilder()->select('industry_id', 'industry_name')->from('industries')->execute();
$career_levels = \Cake\Utility\Hash::combine($q_carerr_levels->fetchAll(), '{n}.career_level_id', '{n}.career_level_id');
$industries = \Cake\Utility\Hash::combine($q_industries->fetchAll(), '{n}.industry_id', '{n}.industry_name');
$years_range = $this->getContainer()->get('years_range');
$months_range = $this->getContainer()->get('months_range');
$days_range = $this->getContainer()->get('days_range');
$this->view->getPlates()->addData(array('page_title' => 'Membership', 'sub_page_title' => 'Update Portfolio'), 'layouts::layout-system');
return $this->view->render($response, 'membership/portfolio-add', compact('career_levels', 'industries', 'years_range', 'months_range', 'days_range'));
})->setName('membership-portfolio-add');
开发者ID:nizarrahmat,项目名称:phpindonesia.or.id-membership2,代码行数:31,代码来源:membership-portfolio-add-function.php
示例14: alignmentCalcSettings
/**
* Alignment calculation settings method
*
* @return void
*/
public function alignmentCalcSettings()
{
$settingsTable = TableRegistry::get('Settings');
$settings = $settingsTable->find('all')->select(['name', 'value'])->where(function ($exp, $q) {
return $exp->in('name', ['intAlignmentAdjustment', 'intAlignmentThreshhold']);
})->toArray();
$settings = Hash::combine($settings, '{n}.name', '{n}.value');
$communities = $this->Communities->find('all')->select(['id', 'name', 'intAlignmentAdjustment', 'intAlignmentThreshhold'])->order(['created' => 'DESC']);
$this->set(['communities' => $communities, 'settings' => $settings, 'titleForLayout' => 'Internal Alignment Calculation Settings']);
}
示例15: getPermissions
/**
* Getting all permission related to given aro entity
* @param Entity $aro
* @return array|mixed
*/
public function getPermissions($aro)
{
if (empty($aro)) {
return [];
}
if (!is_array($aro)) {
$aro = [$aro];
}
$permissions = $this->Aros->find()->contain(['Acos'])->where(['id IN' => Hash::extract($aro, '{n}.id')])->toArray();
$permissions = Hash::extract($permissions, '{n}.acos');
$permissions = Hash::combine($permissions, '{n}.{n}.name', '{n}.{n}');
$permissions = Hash::sort($permissions, '{s}.name');
// $permissions = Hash::expand($permissions, '/');
return $permissions;
}