mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Shift bindings
PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
This commit is contained in:
parent
19080933b6
commit
299464f604
@ -1167,7 +1167,7 @@ class CompanyImport implements ShouldQueue
|
||||
|
||||
$activity_invitation_key = false;
|
||||
|
||||
if ($class == 'App\Models\Activity') {
|
||||
if ($class == \App\Models\Activity::class) {
|
||||
if (isset($obj->invitation_id)) {
|
||||
if (isset($obj->invoice_id)) {
|
||||
$activity_invitation_key = 'invoice_invitations';
|
||||
@ -1184,7 +1184,7 @@ class CompanyImport implements ShouldQueue
|
||||
/* Transform old keys to new keys */
|
||||
foreach ($transforms as $transform) {
|
||||
foreach ($transform as $key => $value) {
|
||||
if ($class == 'App\Models\Activity' && $activity_invitation_key && $key == 'invitations') {
|
||||
if ($class == \App\Models\Activity::class && $activity_invitation_key && $key == 'invitations') {
|
||||
$key = $activity_invitation_key;
|
||||
}
|
||||
|
||||
@ -1192,7 +1192,7 @@ class CompanyImport implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
if ($class == 'App\Models\CompanyGateway') {
|
||||
if ($class == \App\Models\CompanyGateway::class) {
|
||||
$obj_array['config'] = encrypt($obj_array['config']);
|
||||
}
|
||||
|
||||
@ -1236,7 +1236,7 @@ class CompanyImport implements ShouldQueue
|
||||
}
|
||||
|
||||
/* New to convert product ids from old hashes to new hashes*/
|
||||
if ($class == 'App\Models\Subscription') {
|
||||
if ($class == \App\Models\Subscription::class) {
|
||||
$obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']);
|
||||
$obj_array['recurring_product_ids'] = $this->recordProductIds($obj_array['recurring_product_ids']);
|
||||
$obj_array['webhook_configuration'] = json_encode($obj_array['webhook_configuration']);
|
||||
@ -1284,7 +1284,7 @@ class CompanyImport implements ShouldQueue
|
||||
}
|
||||
|
||||
/* New to convert product ids from old hashes to new hashes*/
|
||||
if ($class == 'App\Models\Subscription') {
|
||||
if ($class == \App\Models\Subscription::class) {
|
||||
if (array_key_exists('company', $obj_array)) {
|
||||
unset($obj_array['company']);
|
||||
}
|
||||
@ -1295,54 +1295,54 @@ class CompanyImport implements ShouldQueue
|
||||
}
|
||||
|
||||
/* Expenses that don't have a number will not be inserted - so need to override here*/
|
||||
if ($class == 'App\Models\Expense' && is_null($obj->{$match_key})) {
|
||||
if ($class == \App\Models\Expense::class && is_null($obj->{$match_key})) {
|
||||
$new_obj = new Expense();
|
||||
$new_obj->company_id = $this->company->id;
|
||||
$new_obj->fill($obj_array);
|
||||
$new_obj->save(['timestamps' => false]);
|
||||
$new_obj->number = $this->getNextExpenseNumber($new_obj);
|
||||
} elseif ($class == 'App\Models\Invoice' && is_null($obj->{$match_key})) {
|
||||
} elseif ($class == \App\Models\Invoice::class && is_null($obj->{$match_key})) {
|
||||
$new_obj = new Invoice();
|
||||
$new_obj->company_id = $this->company->id;
|
||||
$new_obj->fill($obj_array);
|
||||
$new_obj->save(['timestamps' => false]);
|
||||
$new_obj->number = $this->getNextInvoiceNumber($client = Client::find($obj_array['client_id']), $new_obj);
|
||||
} elseif ($class == 'App\Models\Payment' && is_null($obj->{$match_key})) {
|
||||
} elseif ($class == \App\Models\Payment::class && is_null($obj->{$match_key})) {
|
||||
$new_obj = new Payment();
|
||||
$new_obj->company_id = $this->company->id;
|
||||
$new_obj->fill($obj_array);
|
||||
$new_obj->save(['timestamps' => false]);
|
||||
$new_obj->number = $this->getNextPaymentNumber($client = Client::find($obj_array['client_id']), $new_obj);
|
||||
} elseif ($class == 'App\Models\Quote' && is_null($obj->{$match_key})) {
|
||||
} elseif ($class == \App\Models\Quote::class && is_null($obj->{$match_key})) {
|
||||
$new_obj = new Quote();
|
||||
$new_obj->company_id = $this->company->id;
|
||||
$new_obj->fill($obj_array);
|
||||
$new_obj->save(['timestamps' => false]);
|
||||
$new_obj->number = $this->getNextQuoteNumber($client = Client::find($obj_array['client_id']), $new_obj);
|
||||
} elseif ($class == 'App\Models\ClientContact') {
|
||||
} elseif ($class == \App\Models\ClientContact::class) {
|
||||
$new_obj = new ClientContact();
|
||||
$new_obj->company_id = $this->company->id;
|
||||
$new_obj->fill($obj_array);
|
||||
$new_obj->save(['timestamps' => false]);
|
||||
} elseif ($class == 'App\Models\RecurringExpense' && is_null($obj->{$match_key})) {
|
||||
} elseif ($class == \App\Models\RecurringExpense::class && is_null($obj->{$match_key})) {
|
||||
$new_obj = new RecurringExpense();
|
||||
$new_obj->company_id = $this->company->id;
|
||||
$new_obj->fill($obj_array);
|
||||
$new_obj->save(['timestamps' => false]);
|
||||
$new_obj->number = $this->getNextRecurringExpenseNumber($new_obj);
|
||||
} elseif ($class == 'App\Models\Project' && is_null($obj->{$match_key})) {
|
||||
} elseif ($class == \App\Models\Project::class && is_null($obj->{$match_key})) {
|
||||
$new_obj = new Project();
|
||||
$new_obj->company_id = $this->company->id;
|
||||
$new_obj->fill($obj_array);
|
||||
$new_obj->save(['timestamps' => false]);
|
||||
$new_obj->number = $this->getNextProjectNumber($new_obj);
|
||||
} elseif ($class == 'App\Models\Task' && is_null($obj->{$match_key})) {
|
||||
} elseif ($class == \App\Models\Task::class && is_null($obj->{$match_key})) {
|
||||
$new_obj = new Task();
|
||||
$new_obj->company_id = $this->company->id;
|
||||
$new_obj->fill($obj_array);
|
||||
$new_obj->save(['timestamps' => false]);
|
||||
$new_obj->number = $this->getNextTaskNumber($new_obj);
|
||||
} elseif ($class == 'App\Models\CompanyLedger') {
|
||||
} elseif ($class == \App\Models\CompanyLedger::class) {
|
||||
$new_obj = $class::firstOrNew(
|
||||
[$match_key => $obj->{$match_key}, 'company_id' => $this->company->id],
|
||||
$obj_array,
|
||||
|
@ -30,7 +30,7 @@ trait Utilities
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return static::class == 'App\PaymentDrivers\CheckoutComPaymentDriver' ? $this : $this->checkout;
|
||||
return static::class == \App\PaymentDrivers\CheckoutComPaymentDriver::class ? $this : $this->checkout;
|
||||
}
|
||||
|
||||
public function convertToCheckoutAmount($amount, $currency)
|
||||
|
Loading…
x
Reference in New Issue
Block a user