本文整理汇总了PHP中Arr::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::remove方法的具体用法?PHP Arr::remove怎么用?PHP Arr::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::remove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$paymentData = $this->getPaymentSettings();
if ($this->isRequestMethod('post') && ($settings = $this->getRequest()->request->get('settings'))) {
$settings = Arr::remove($settings, array_keys($paymentData));
$saved_settings = 0;
$systemSettingsModel = $this->get('core.system.settings.model');
foreach ($settings as $setting => $value) {
$systemSettingsModel->setData($setting, $value);
$saved_settings++;
}
if ($saved_settings) {
$this->addFlash(lang('payment_update_success'), 'success');
redirect(current_url());
}
}
$geteways = Payment_gateways::findAll();
$this->template->set('geteways', $geteways);
$this->template->set('paymentData', $paymentData);
$this->template->render();
}
示例2: buildMessage
/**
* Build Mailgun compatible message array from email entity
*
* Documentation at https://mandrillapp.com/api/docs/messages.php.html
*
* @param EmailEntity $emails
* @return array
*/
protected function buildMessage(EmailEntity $email)
{
// Create attachments array
$attachments = json_decode($email->getAttachments(), true) ?: [];
// Convert Mandrill format to Mailgun format
$attachments = array_map(function ($attachment) {
if (isset($attachment['content'])) {
$attachment['data'] = base64_decode(Arr::remove($attachment, 'content'));
}
if (isset($attachment['name'])) {
$attachment['filename'] = Arr::remove($attachment, 'name');
}
if (isset($attachment['type'])) {
$attachment['contentType'] = Arr::remove($attachment, 'type');
}
return attachment;
}, $attachments);
if ($email->getSenderName()) {
$from = "{$email->getSenderName()} <{$email->getSenderEmail()}>";
} else {
$from = $email->getSenderEmail();
}
if ($email->getTemplateName()) {
$html = $this->templateService->renderHbsForEmail($email->getTemplateName(), $email->getTemplateData() ? json_decode($email->getTemplateData(), true) : []);
} else {
$html = $email->getMessage();
}
$message = ['html' => $html, 'subject' => $email->getSubject(), 'from' => $from, 'to' => $this->filterThroughWhitelist($email->getRecipientEmail()), 'attachments' => $attachments];
if ($email->getHeaders()) {
$headers = [];
foreach (json_decode($email->getHeaders(), true) as $key => $value) {
$headers["h:{$key}"] = $value;
}
$message['headers'] = $headers;
}
return $message;
}
示例3: remove
/**
* Remove an array entry by path
*
* @param $array array Source
* @param $path array|string Path to the key you'd want to unset
* @param null $delimiter
* @return bool
*/
public static function remove(&$array, $path, $delimiter = NULL)
{
if (!Arr::is_array($array)) {
// This is not an array!
return false;
}
if (is_array($path)) {
// The path has already been separated into keys
$keys = $path;
} else {
if (array_key_exists($path, $array)) {
// No need to do extra processing
unset($array[$path]);
return true;
}
if ($delimiter === NULL) {
// Use the default delimiter
$delimiter = Arr::$delimiter;
}
// Remove starting delimiters and spaces
$path = ltrim($path, "{$delimiter} ");
// Remove ending delimiters, spaces, and wildcards
$path = rtrim($path, "{$delimiter} *");
// Split the keys by delimiter
$keys = explode($delimiter, $path);
}
do {
$key = array_shift($keys);
if (ctype_digit($key)) {
// Make the key an integer
$key = (int) $key;
}
if (isset($array[$key])) {
if ($keys) {
if (Arr::is_array($array[$key])) {
// Dig down into the next part of the path
$array = $array[$key];
} else {
// Unable to dig deeper
break;
}
} else {
// Found the path requested
unset($array[$key]);
return true;
}
} elseif ($key === '*') {
// Handle wildcards
$success = false;
foreach ($array as $arr) {
if (Arr::remove($arr, implode('.', $keys))) {
$success = true;
}
}
return $success;
} else {
// Unable to dig deeper
break;
}
} while ($keys);
// Unable to find the value requested
return false;
}
示例4: remove
/**
* Removes a param using "dot notation" from the session.
*
* @param string $path
*
* @throws \LogicException If the session has not been started yet
*
* @return bool
*/
public final function remove($path)
{
if (!$this->started()) {
throw new LogicException('The session has not been started yet.');
}
return Arr::remove($this->data, $path);
}
示例5: _requiredFieldValidate
protected function _requiredFieldValidate()
{
$requiredFields = $this->getRequiredFields();
$requiredFieldsInfo = $this->getRequiredFieldsInfo();
$data = Arr::remove($this->getDecodedData(), $requiredFields);
if (count($data) != count($requiredFields)) {
return 'All fields are required!';
}
foreach ($data as $key => $value) {
$fieldInfo = $requiredFieldsInfo[$key];
if ($fieldInfo->isRequired() && strlen($value) == 0) {
return sprintf('Field %s is required.', $fieldInfo->GetLabel());
}
}
}
示例6: remove
/**
* Removes one or more values.
*
* @param array|string $keys
* @return self
*/
public function remove($keys)
{
Arr::remove($this->values, $keys);
return $this;
}