-
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.
Interfaces and style rework in an attempt to make Scribbles look good
Concerns #253
- Loading branch information
Showing
15 changed files
with
151 additions
and
61 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
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
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
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
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,10 @@ | ||
<?php | ||
|
||
namespace common\models\core; | ||
|
||
use yii\db\ActiveQuery; | ||
|
||
interface HasEpic | ||
{ | ||
public function getEpic(): ActiveQuery; | ||
} |
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,7 @@ | ||
<?php | ||
|
||
namespace common\models\core; | ||
|
||
interface HasScribbles | ||
{ | ||
} |
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 | ||
|
||
namespace common\models\core; | ||
|
||
/** | ||
* Interface IsEditablePack | ||
* @package common\models\core | ||
*/ | ||
interface IsEditablePack extends IsPack | ||
{ | ||
/** | ||
* @return bool | ||
*/ | ||
public function canUserReadYou(): bool; | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function canUserControlYou(): bool; | ||
} |
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,11 @@ | ||
<?php | ||
|
||
namespace common\models\core; | ||
|
||
/** | ||
* Interface for packs that self-fill if empty | ||
*/ | ||
interface IsSelfFillingPack extends IsPack | ||
{ | ||
public function createEmptyContent(int $userId); | ||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace common\models\tools; | ||
|
||
use common\models\core\IsSelfFillingPack; | ||
use common\models\Epic; | ||
|
||
trait ToolsForSelfFillingPacks | ||
{ | ||
private function createAbsentRecords(Epic $epic, IsSelfFillingPack $pack, array $objectsRaw): bool | ||
{ | ||
$users = $epic->participants; | ||
$objectsOrdered = []; | ||
|
||
foreach ($objectsRaw as $object) { | ||
$objectsOrdered[$object->user_id] = $object; | ||
} | ||
|
||
$result = true; | ||
|
||
foreach ($users as $user) { | ||
if (!isset($objectsOrdered[$user->user_id])) { | ||
$scribbleObject = $pack->createEmptyContent($user->user_id); | ||
$saveResult = $scribbleObject->save(); | ||
$result = $result && $saveResult; | ||
} | ||
} | ||
return $result; | ||
} | ||
} |