-
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.
- Loading branch information
Showing
8 changed files
with
268 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# extas-bv-profiles | ||
|
||
BV profiles for Extas | ||
|
||
# install | ||
|
||
`# vendor/bin/extas i` |
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,13 @@ | ||
{ | ||
"name": "jeyroik/extas-bv-profiles", | ||
"description": "Extas bv profiles package", | ||
"require": { | ||
"jeyroik/extas-base": "*", | ||
"jeyroik/extas-bv": "*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"extas\\": "src/" | ||
} | ||
} | ||
} |
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,92 @@ | ||
{ | ||
"name": "extas/bv-api", | ||
"plugins": [ | ||
{ | ||
"class": "extas\\components\\plugins\\PluginInstallBVProfiles", | ||
"stage": "expand.install" | ||
} | ||
], | ||
"bv_profiles": [ | ||
{ | ||
"name": "default", | ||
"title": "По умолчанию", | ||
"description": "Профиль по умолчанию: все веса равны единице", | ||
"weights": { | ||
"more_buyers": 1, | ||
"more_products": 1, | ||
"higher_price": 1, | ||
"too_hard_to_deny": 1, | ||
"happiness": 1, | ||
"fans": 1, | ||
"education": 1, | ||
"hold_users": 1, | ||
"active_users": 1, | ||
"fewer_bugs": 1, | ||
"deploy": 1, | ||
"new_development": 1, | ||
"support": 1, | ||
"marketing": 1, | ||
"new_possibilities": 1, | ||
"promise": 1, | ||
"law": 1, | ||
"align_with_plans": 1, | ||
"economy": 1, | ||
"help": 1 | ||
} | ||
}, | ||
{ | ||
"name": "support", | ||
"title": "Поддержка", | ||
"description": "Веса повышают значимость категорий, удешевляющих поддержку", | ||
"weights": { | ||
"more_buyers": 1, | ||
"more_products": 1, | ||
"higher_price": 1, | ||
"too_hard_to_deny": 2, | ||
"happiness": 1, | ||
"fans": 1, | ||
"education": 1, | ||
"hold_users": 3, | ||
"active_users": 2, | ||
"fewer_bugs": 3, | ||
"deploy": 3, | ||
"new_development": 1, | ||
"support": 3, | ||
"marketing": 1, | ||
"new_possibilities": 1, | ||
"promise": 1, | ||
"law": 1, | ||
"align_with_plans": 1, | ||
"economy": 3, | ||
"help": 1 | ||
} | ||
}, | ||
{ | ||
"name": "startup", | ||
"title": "Стартап", | ||
"description": "Веса повышают значимость категорий, привлекающих пользователей", | ||
"weights": { | ||
"more_buyers": 3, | ||
"more_products": 3, | ||
"higher_price": 3, | ||
"too_hard_to_deny": 3, | ||
"happiness": 2, | ||
"fans": 3, | ||
"education": 3, | ||
"hold_users": 1, | ||
"active_users": 3, | ||
"fewer_bugs": 1, | ||
"deploy": 3, | ||
"new_development": 3, | ||
"support": 1, | ||
"marketing": 3, | ||
"new_possibilities": 3, | ||
"promise": 1, | ||
"law": 1, | ||
"align_with_plans": 2, | ||
"economy": 1, | ||
"help": 1 | ||
} | ||
} | ||
] | ||
} |
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,62 @@ | ||
<?php | ||
namespace extas\components\bv\profiles; | ||
|
||
use extas\components\Item; | ||
use extas\components\THasDescription; | ||
use extas\components\THasName; | ||
use extas\interfaces\bv\profiles\IProfile; | ||
|
||
/** | ||
* Class Profile | ||
* | ||
* @package extas\components\bv\profiles | ||
* @author jeyroik@gmail.com | ||
*/ | ||
class Profile extends Item implements IProfile | ||
{ | ||
use THasName; | ||
use THasDescription; | ||
|
||
/** | ||
* @param array $default | ||
* | ||
* @return array | ||
*/ | ||
public function getWeights(array $default = []): array | ||
{ | ||
return $this->config[static::FIELD__WEIGHTS] ?? $default; | ||
} | ||
|
||
/** | ||
* @param array $weights | ||
* | ||
* @return IProfile | ||
*/ | ||
public function setWeights(array $weights): IProfile | ||
{ | ||
$this->config[static::FIELD__WEIGHTS] = $weights; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param string $subcategoryName | ||
* @param int $defaultWeight | ||
* | ||
* @return int | ||
*/ | ||
public function getSubcategoryWeight(string $subcategoryName, int $defaultWeight = 1): int | ||
{ | ||
$weights = $this->getWeights(); | ||
|
||
return $weights[$subcategoryName] ?? $defaultWeight; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getSubjectForExtension(): string | ||
{ | ||
return static::SUBJECT; | ||
} | ||
} |
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 extas\components\bv\profiles; | ||
|
||
use extas\components\repositories\Repository; | ||
use extas\interfaces\bv\profiles\IProfileRepository; | ||
|
||
/** | ||
* Class ProfileRepository | ||
* | ||
* @package extas\components\bv\profiles | ||
* @author jeyroik@gmail.com | ||
*/ | ||
class ProfileRepository extends Repository implements IProfileRepository | ||
{ | ||
protected $itemClass = Profile::class; | ||
protected $name = 'bv_profiles'; | ||
protected $pk = Profile::FIELD__NAME; | ||
protected $scope = 'extas'; | ||
protected $idAs = ''; | ||
} |
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 extas\components\plugins; | ||
|
||
use extas\components\bv\profiles\Profile; | ||
use extas\interfaces\bv\profiles\IProfileRepository; | ||
|
||
/** | ||
* Class PluginInstallBVProfiles | ||
* | ||
* @package extas\components\plugins | ||
* @author jeyroik@gmail.com | ||
*/ | ||
class PluginInstallBVProfiles extends PluginInstallDefault | ||
{ | ||
protected $selfItemClass = Profile::class; | ||
protected $selfName = 'business value profile'; | ||
protected $selfSection = 'bv_profiles'; | ||
protected $selfUID = Profile::FIELD__NAME; | ||
protected $selfRepositoryClass = IProfileRepository::class; | ||
} |
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,41 @@ | ||
<?php | ||
namespace extas\interfaces\bv\profiles; | ||
|
||
use extas\interfaces\IHasDescription; | ||
use extas\interfaces\IHasName; | ||
use extas\interfaces\IItem; | ||
|
||
/** | ||
* Interface IProfile | ||
* | ||
* @package extas\interfaces\bv\profiles | ||
* @author jeyroik@gmail.com | ||
*/ | ||
interface IProfile extends IItem, IHasName, IHasDescription | ||
{ | ||
const SUBJECT = 'extas.bv.profile'; | ||
|
||
const FIELD__WEIGHTS = 'weights'; | ||
|
||
/** | ||
* @param array $default | ||
* | ||
* @return array [subCat0 => weight0, ...] | ||
*/ | ||
public function getWeights(array $default = []): array; | ||
|
||
/** | ||
* @param array $weights | ||
* | ||
* @return IProfile | ||
*/ | ||
public function setWeights(array $weights): IProfile; | ||
|
||
/** | ||
* @param string $subcategoryName | ||
* @param int $defaultWeight | ||
* | ||
* @return int | ||
*/ | ||
public function getSubcategoryWeight(string $subcategoryName, int $defaultWeight = 1): int; | ||
} |
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,15 @@ | ||
<?php | ||
namespace extas\interfaces\bv\profiles; | ||
|
||
use extas\interfaces\repositories\IRepository; | ||
|
||
/** | ||
* Interface IProfileRepository | ||
* | ||
* @package extas\interfaces\bv\profiles | ||
* @author jeyroik@gmail.com | ||
*/ | ||
interface IProfileRepository extends IRepository | ||
{ | ||
|
||
} |