-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
22 changed files
with
305 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: max | ||
* Name: Cherednyk Maxim | ||
* Phone: +380639960375 | ||
* Email: maks757q@gmail.com | ||
* Date: 16.02.2018 | ||
* Time: 15:26 | ||
*/ | ||
|
||
namespace maks757\articlesdata\components; | ||
|
||
|
||
use maks757\articlesdata\components\src\ArticleObject; | ||
use maks757\articlesdata\entities\Yii2DataArticleGallery; | ||
use maks757\articlesdata\entities\Yii2DataArticleImage; | ||
use maks757\articlesdata\entities\Yii2DataArticleText; | ||
use PHPUnit\Framework\MockObject\BadMethodCallException; | ||
use yii\base\InvalidParamException; | ||
use yii\helpers\ArrayHelper; | ||
|
||
class ArticleHelper extends ArticleObject | ||
{ | ||
const POSITION_UP = 0x0001; | ||
const POSITION_DOWN = 0x0002; | ||
|
||
/** | ||
* @param $field_id | ||
* @param $field_class Yii2DataArticleText|Yii2DataArticleGallery|Yii2DataArticleImage | ||
* @param int $type | ||
* @internal param $type :: POSITION_UP | ||
* @internal param $type :: POSITION_DOWN | ||
*/ | ||
public static function changeFieldPosition($field_id, $field_class, $type = ArticleHelper::POSITION_UP) | ||
{ | ||
$class = $field_class::findOne($field_id); | ||
switch ($type){ | ||
case ArticleHelper::POSITION_UP:{ | ||
$class->position = (integer)$class->position + 1; | ||
break; | ||
} | ||
case ArticleHelper::POSITION_DOWN:{ | ||
$class->position = (integer)$class->position > 1 ? (integer)$class->position - 1 : 1; | ||
break; | ||
} | ||
default:{ | ||
throw new InvalidParamException(); | ||
} | ||
} | ||
|
||
if(!$class->save()) { | ||
throw new BadMethodCallException(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: max | ||
* Name: Cherednyk Maxim | ||
* Phone: +380639960375 | ||
* Email: maks757q@gmail.com | ||
* Date: 16.02.2018 | ||
* Time: 15:27 | ||
*/ | ||
|
||
namespace maks757\articlesdata\components\src; | ||
|
||
|
||
use yii\base\BaseObject; | ||
|
||
abstract class ArticleObject extends BaseObject | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.