Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
14dcce89
Commit
14dcce89
authored
Jan 30, 2016
by
Shakarim Sapa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Добавлена проверка на уникальность идентификатора
parent
9f22bddf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
common/modules/triggers/components/conditions/Conditions.php
common/modules/triggers/components/conditions/Conditions.php
+10
-1
No files found.
common/modules/triggers/components/conditions/Conditions.php
View file @
14dcce89
...
@@ -28,10 +28,12 @@ class Conditions {
...
@@ -28,10 +28,12 @@ class Conditions {
}
}
/**
/**
* Метод проверяет конфиг на наличие ошибок. Так же дополнительно производится проверка на обязательную константу ID
* @return bool
* @return bool
* @throws \yii\web\ServerErrorHttpException
* @throws \yii\web\ServerErrorHttpException
*/
*/
public
static
function
createConditions
(){
public
static
function
createConditions
(){
$uniqueId
=
array
();
// Перебираем все условия что указаны в конфиге
// Перебираем все условия что указаны в конфиге
foreach
(
self
::
$config
as
$condition
)
{
foreach
(
self
::
$config
as
$condition
)
{
// Если путь к классу указан, и файл по этому пути существует
// Если путь к классу указан, и файл по этому пути существует
...
@@ -40,7 +42,14 @@ class Conditions {
...
@@ -40,7 +42,14 @@ class Conditions {
$class
=
$condition
[
'class'
]
::
init
();
$class
=
$condition
[
'class'
]
::
init
();
// Проверяем наличие обязательных констант
// Проверяем наличие обязательных констант
// Проверили существование идентификатора
// Проверили существование идентификатора
if
(
$class
::
defined
(
'CONDITION_ID'
)
===
false
)
if
(
$class
::
defined
(
'CONDITION_ID'
)
===
true
)
{
// Если с идентификатором все в порядке, проверяем его на уникальность.
// В системе не должно быть два или более классов с условиями имеющие одинаковые идентификаторы
if
(
!
in_array
(
$class
::
CONDITION_ID
,
$uniqueId
))
$uniqueId
[]
=
$class
::
CONDITION_ID
;
else
throw
new
ServerErrorHttpException
(
'Condition ID have to be unique'
,
500
);
}
else
throw
new
ServerErrorHttpException
(
'Condition ID in class "'
.
get_class
(
$class
)
.
'" has not found'
,
500
);
throw
new
ServerErrorHttpException
(
'Condition ID in class "'
.
get_class
(
$class
)
.
'" has not found'
,
500
);
}
else
{
}
else
{
throw
new
ServerErrorHttpException
(
'Condition class file or path not found. Please check configuration file'
,
500
);
throw
new
ServerErrorHttpException
(
'Condition class file or path not found. Please check configuration file'
,
500
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment