Skip to content

Instantly share code, notes, and snippets.

View MasterHans's full-sized avatar

Alexander Suvorov MasterHans

  • Russia
View GitHub Profile
@MasterHans
MasterHans / PHP create class without constructor
Created October 21, 2021 17:40
PHP create class without constructor
public function getSettingsFieldsMap($providerName, $moduleName)
{
Yii::import('application.modules.' . $moduleName . '.models.' . $providerName);
$reflection = new ReflectionClass($providerName);
$instance = $reflection->newInstanceWithoutConstructor();
return $instance->getAttributeConfig();
}
private function fetchSearchName($item)
{
// bp_prad_kli_id
$this->log(gettype($item['searchName']));
$this->log($item);
if (gettype($item['searchName']) == 'object') {
if ($item['name'] === 'clientName') {
return 'kli_pav';
}
@MasterHans
MasterHans / AngularJs - modal windows
Created October 12, 2021 07:26
AngularJs - modal windows
function openClientInvoices(templateUrl, clientId) {
return $uibModal.open({
// templateUrl: util.buildUrl('warehouse/sales', {clientId: clientId}),
templateUrl: util.buildUrl('resource/partials/modal', {clientId: clientId}),
controller: function ($uibModalInstance, templateUrl) {
var c = this;
c.templateUrl = templateUrl;
c.dismiss = function () {
$uibModalInstance.dismiss('close');
};
@MasterHans
MasterHans / AngularJS - pass parameters out from the Custom Directory
Last active October 6, 2021 09:37
AngularJS - pass parameters out from the Custom Directory
//Controller
angular.module('b1').controller('WarehousePurchaseEdit', function (){
c.onPurchaseDateChange = function (param) {
alert(param);
}
}
//View
@MasterHans
MasterHans / AngularJS - link in Custom Directive sample
Created October 6, 2021 09:05
AngularJS - link in Custom Directive sample
@MasterHans
MasterHans / Pass Event into custom directive
Last active October 6, 2021 08:45
AndularJS - Pass Event into custom directive
//controller
angular.module('b1').controller('WarehousePurchaseEdit',
function () {
c.onPurchaseDateChange = function () {
alert(c.oldPurchaseDate);
}
)};
//view
@MasterHans
MasterHans / Yii1 creteria for CActiveDataProvider
Last active August 28, 2021 10:33
Передаём критерии (набор параметров для sql запроса) в DataProvider , который мы вставим в Грид (или Лист) во вью
Controller:
$dataProvider=new CActiveDataProvider('Comment', array(
'criteria'=>array(
'with'=>'post',
'order'=>'t.status, t.create_time DESC',
),
));
$this->render('index',array(
@MasterHans
MasterHans / Yii1 $model->findAll($creteria)
Created August 28, 2021 10:28
Получить записи из модели по кретериям
$criteria = new CDbCriteria();
$criteria->select = 't.id, t.email';
$criteria->order = 't.created_at';
$criteria->condition = "t.status in (:s1, :s2) AND t.created_at >= :f AND t.created_at <= :u";
$criteria->params = [
':s1' => Users::STATUS_VERIFIED_INCOMPLETE,
':s2' => Users::STATUS_VERIFIED_COMPLETE,
':f' => $date->format('Y-m-d 00:00:00'),
':u' => $date->format('Y-m-d 23:59:59'),
];
https://slides.silverfire.me/2016/yii-di/#/1
Компонент нужен тогда, когда:
Класс может быть предварительно сконфигурирован
Класс актуален в течение всего runtime
Хочется сделать singleton
@MasterHans
MasterHans / .gitignore
Created August 1, 2021 08:07
Rules for .gitignore
1. Если исключаем папку например ajax обязательно указать
/ajax
чтобы брало от корня.
Если указать просто ajax - исключит изо всех подпапок по всему сайту этоу папку.
2. Исключить папку bitrix, но оставить подпапку aspro_max внутри.
/bitrix/*
!/bitrix/templates/