本文整理汇总了PHP中arr::merge方法的典型用法代码示例。如果您正苦于以下问题:PHP arr::merge方法的具体用法?PHP arr::merge怎么用?PHP arr::merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arr
的用法示例。
在下文中一共展示了arr::merge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
public static function set($conference)
{
$xml = FreeSwitch::setSection('conferences');
foreach (Conference::$default_keymap as $action => $digits) {
$xml->update('/caller-controls/group[@name="default-keymap"]/control[@action="' . $action . '"]{@digits="' . $digits . '"}');
}
$xml = FreeSwitch::setSection('conference_profile', $conference['conference_id']);
$xml->deleteChildren();
$profile = arr::merge(Conference::$default_profile, $conference['profile']);
$registry = $conference['registry'];
foreach ($profile as $parameter => $value) {
$value = str_replace('/', '\\/', $value);
if (isset($registry[$parameter])) {
$value = $registry[$parameter];
}
$xml->update('/param[@name="' . $parameter . '"]{@value="' . $value . '"}');
}
if (!empty($registry['moh_type'])) {
$value = str_replace('/', '\\/', $registry['moh_type']);
$xml->update('/param[@name="moh-sound"]{@value="' . $value . '"}');
}
if (empty($conference['pins'])) {
return;
}
foreach ($conference['pins'] as $pin) {
if (empty($pin)) {
continue;
}
$xml->update('/param[@name="pin"]{@value="' . $pin . '"}');
}
}
示例2: render
public function render($print = FALSE, $renderer = FALSE)
{
// Give helpers an entry to this view instance
self::$instance = $this;
if ($this->is_set('mustache_template') or stristr($this->kohana_filename, '.mus')) {
if (isset($this->kohana_local_data['mustache_template']) and $this->kohana_local_data['mustache_template'] === FALSE) {
return parent::render($print, $renderer);
}
$mustache_data = arr::merge(self::$kohana_global_data, $this->kohana_local_data);
if (empty($this->kohana_local_data['mustache_partials'])) {
$mustache_partials = array();
} else {
$mustache_partials = $this->kohana_local_data['mustache_partials'];
unset($mustache_data['mustache_partials']);
}
$mustache = new Mustache();
$output = $mustache->render(parent::render(FALSE), $mustache_data, $mustache_partials);
$output = str_replace(array("\n", ' '), '', $output);
if (!empty($this->kohana_local_data['mustache_escape_apostrophes'])) {
$output = str_replace('\'', '\\\'', $output);
}
if ($print === TRUE) {
// Display the output
echo $output;
return;
}
return $output;
} else {
return parent::render($print, $renderer);
}
}
示例3: createExtension
public static function createExtension()
{
Event::$data += array('voicemail_password' => self::generatePin(), 'voicemail_timezone' => kohana::config('locale.timezone'), 'voicemail_email_all_messages' => empty(Event::$data['user']['email_address']) ? 0 : 1, 'voicemail_delete_file' => 0, 'voicemail_attach_audio_file' => 1, 'voicemail_email_address' => empty(Event::$data['user']['email_address']) ? '' : Event::$data['user']['email_address']);
extract(Event::$data);
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
$name_append = '';
if (!empty($owner_name)) {
$name_append = ' for ' . $owner_name;
}
try {
$voicemail = new Voicemail();
$voicemail['name'] = 'VM ' . $extension . $name_append;
$voicemail['mailbox'] = $extension;
$voicemail['password'] = $voicemail_password;
$voicemail['account_id'] = $account_id;
$voicemail['plugins'] = array('timezone' => array('timezone' => $voicemail_timezone));
$voicemail['registry'] = array('email_all_messages' => $voicemail_email_all_messages, 'delete_file' => $voicemail_delete_file, 'attach_audio_file' => $voicemail_attach_audio_file, 'email_address' => $voicemail_email_address);
$voicemail->save();
$plugin = array('voicemail' => array('mwi_box' => $voicemail['voicemail_id']));
$device['plugins'] = arr::merge($device['plugins'], $plugin);
} catch (Exception $e) {
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
kohana::log('error', 'Unable to generate voicemail for device: ' . $e->getMessage());
throw $e;
}
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
}
示例4: validate
public function validate(CM_Form_Abstract $form)
{
if ($this->_extra_validation) {
$values = array();
foreach ($form->get_values() as $name => $value) {
$values[$name] = $value->get_raw();
$this->_extra_validation->label($name, $form->get_field($name)->get_label());
}
// Validation только read-only, поэтому создаем новый объект
$this->_extra_validation = $this->_extra_validation->copy($values);
}
try {
$this->get_model()->check($this->_extra_validation);
} catch (ORM_Validation_Exception $e) {
$errors = $e->errors('validation');
if ($external = arr::get($errors, '_external')) {
$errors = arr::merge($errors, $external);
unset($errors['_external']);
}
foreach ($errors as $name => $error) {
$form->get_field($name)->set_error($error);
}
return FALSE;
}
return TRUE;
}
示例5: createExtension
public static function createExtension()
{
Event::$data += array('callerid_internal_name' => Event::$data['owner_name'], 'callerid_external_name' => Event::$data['owner_name'], 'callerid_external_number' => str_pad(Event::$data['extension'], 10, "5", STR_PAD_LEFT));
extract(Event::$data);
$plugin = array('callerid' => array('internal_name' => $callerid_internal_name, 'internal_number' => $extension, 'external_name' => $callerid_external_name, 'external_number' => $callerid_external_number));
$device['plugins'] = arr::merge($device['plugins'], $plugin);
}
示例6: createExtension
public static function createExtension()
{
Event::$data += array('sip_username' => html::token(Event::$data['owner_name']), 'sip_password' => inflector::generatePassword());
extract(Event::$data);
$plugin = array('sip' => array('username' => $sip_username, 'password' => $sip_password));
$device['plugins'] = arr::merge($device['plugins'], $plugin);
}
示例7: dropdown
public static function dropdown($data, $selected = NULL, $extra = '')
{
// standardize the $data as an array, strings default to the class_type
if (!is_array($data)) {
$data = array('name' => $data);
}
// add in all the defaults if they are not provided
$defaults = array('null_option' => FALSE, 'default_first' => TRUE, 'unauth_before_auth' => FALSE);
$data = arr::merge($defaults, $data);
$options = array();
$sipinterfaces = Doctrine::getTable('SipInterface')->findAll();
foreach ($sipinterfaces as $sipinterface) {
if (!($id = arr::get($sipinterface, 'sipinterface_id')) or !($name = arr::get($sipinterface, 'name'))) {
continue;
}
if ($data['unauth_before_auth'] and !$sipinterface['auth'] or !$data['unauth_before_auth'] and $sipinterface['auth']) {
arr::unshift_assoc($options, $id, $name);
continue;
}
$options[$id] = $name;
}
if ($data['default_first'] and $default_sipinterface = SipInterface::get_default()) {
unset($options[$default_sipinterface['sipinterface_id']]);
arr::unshift_assoc($options, $default_sipinterface['sipinterface_id'], $default_sipinterface['name']);
}
if ($data['null_option']) {
arr::unshift_assoc($options, 0, $data['null_option']);
}
$data = array_diff($data, $defaults);
// use kohana helper to generate the markup
return form::dropdown($data, $options, $selected, $extra);
}
示例8: tiers_POST
protected static function tiers_POST($id, $envelope)
{
if (is_null($id)) {
self::throwErrorAndDie('Invalid request', array($id), 410);
}
$data = self::requireData($envelope);
$tier_agents = array();
if ($agents = arr::get($data, 'agents')) {
foreach ($agents as $agent) {
if ($tier_agent_id = arr::get($agent, 'tier_agent_id')) {
$tier_agent = Doctrine::getTable('TierAgent')->findOneBy('tier_agent_id', $tier_agent_id);
} else {
$tier_agent = new TierAgent();
}
try {
$tier_agent->synchronizeWithArray($agent);
$tier_agent->save();
$tier_agents[] = $tier_agent->toArray();
} catch (Exception $e) {
self::throwErrorAndDie('Invalid data', Bluebox_Controller::$validation->errors(), 400);
}
}
arr::remove('agents', $data);
arr::merge($envelope['data'], $data);
}
$response = self::generalAPI_POST($id, 'tier_id', 'Tier', $envelope);
$response['agents'] = $tier_agents;
return $response;
}
示例9: ignoreLogLevels
public static function ignoreLogLevels($ignore)
{
if (!is_array($ignore)) {
$ignore = array($ignore);
}
self::$ignore = arr::merge(self::$ignore, $ignore);
}
示例10: determineUninstallOrder
public static function determineUninstallOrder()
{
self::$uninstallOrder = array();
$dependencies = self::listDependencies();
$catalog = Package_Catalog::getCatalog();
foreach ($catalog as $id => $package) {
$reliance = self::graphReliance($dependencies, $package['packageName']);
self::$uninstallOrder = arr::merge(self::$uninstallOrder, $reliance);
}
self::$uninstallOrder = array_unique(self::$uninstallOrder);
self::$uninstallOrder = array_flip(self::$uninstallOrder);
}
示例11: __construct
/**
* Intialize migration library
*
* @param bool Do we want output of migration steps?
* @param string Database group
*/
public function __construct($config = NULL)
{
$this->config = arr::merge(Kohana::$config->load('migrations')->as_array(), (array) $config);
$database = Kohana::$config->load('database.' . Arr::get(Kohana::$config->load('migrations'), 'database', 'default'));
// Set the driver class name
$driver = 'Migration_Driver_' . ucfirst($database['type']);
// Create the database connection instance
$this->driver = new $driver(Arr::get(Kohana::$config->load('migrations'), 'database', 'default'));
$this->driver->versions()->init();
if (!is_dir($this->config['path'])) {
mkdir($this->config['path'], 0777, TRUE);
}
}
示例12: view_category
protected function view_category($id = 1, $t = NULL)
{
if (!isset($this->list[$id])) {
return array();
}
$result = array();
$tmp = $this->list[$id];
$result[$tmp['id']] = trim($t . ' ' . $tmp['title']);
if (array_key_exists($tmp['id'], $this->parent)) {
foreach ($this->parent[$tmp['id']] as $v) {
$result = arr::merge($result, $this->view_category($v, $t . $this->dash));
}
}
return $result;
}
示例13: dropdown
public static function dropdown($data, $selected = NULL, $extra = '')
{
// standardize the $data as an array, strings default to the class_type
if (!is_array($data)) {
$data = array('name' => $data);
}
// add in all the defaults if they are not provided
$defaults = array('nullOption' => FALSE);
$data = arr::merge($defaults, $data);
$options = TTSEngine::catalog();
if ($data['nullOption']) {
array_unshift($options, $data['nullOption']);
}
$data = array_diff($data, $defaults);
// use kohana helper to generate the markup
return form::dropdown($data, $options, $selected, $extra);
}
示例14: main_right_tabs
/**
* Generate Main Tab Menus (RIGHT SIDE)
*/
public static function main_right_tabs($user = FALSE)
{
$main_right_tabs = array();
// Change tabs for MHI
if (Kohana::config('config.enable_mhi') == TRUE and Kohana::config('settings.subdomain') == '') {
$main_right_tabs = array('users' => Kohana::lang('ui_admin.users'), 'mhi/settings' => Kohana::lang('ui_admin.settings'));
} else {
// Build the tabs array depending on the role permissions for each section
if ($user) {
// Check permissions for settings panel
$main_right_tabs = Auth::instance()->has_permission('settings', $user) ? arr::merge($main_right_tabs, array('settings/site' => Kohana::lang('ui_admin.settings'))) : $main_right_tabs;
// Check permissions for the manage panel
$main_right_tabs = Auth::instance()->has_permission('manage', $user) ? arr::merge($main_right_tabs, array('manage' => Kohana::lang('ui_admin.manage'))) : $main_right_tabs;
// Check permissions for users panel
$main_right_tabs = Auth::instance()->has_permission('users', $user) ? arr::merge($main_right_tabs, array('users' => Kohana::lang('ui_admin.users'))) : $main_right_tabs;
}
}
return $main_right_tabs;
}
示例15: meta_data
/**
* Load addon Information from readme.txt file
*
* @param string addon name
* @param string addon type
* @param array default meta data
* @return array
*/
public static function meta_data($addon, $type, $defaults = array())
{
$base = $type == 'plugin' ? PLUGINPATH : THEMEPATH;
// Determine if readme.txt (Case Insensitive) exists
$file = $base . $addon . "/readme.txt";
if (file::file_exists_i($file, $file)) {
$fp = fopen($file, 'r');
// Pull only the first 8kiB of the file in.
$file_data = fread($fp, 8192);
fclose($fp);
preg_match_all('/^(.*):(.*)$/mU', $file_data, $matches, PREG_PATTERN_ORDER);
$meta_data = array_combine(array_map('trim', $matches[1]), array_map('trim', $matches[2]));
foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
if (file_exists($base . $addon . "/screenshot.{$ext}")) {
$meta_data['Screenshot'] = "screenshot.{$ext}";
break;
}
}
return arr::merge($defaults, $meta_data);
}
return false;
}