atm/competitionbundle
Composer 安装命令:
composer require atm/competitionbundle
包简介
Competition bundle
README 文档
README
Install through composer:
php -d memory_limit=-1 composer.phar require atm/competitionbundle
In your AppKernel
public function registerbundles()
{
return [
...
...
new ATM\CompetitionBundle\ATMCompetitionBundle(),
];
}
Configuration sample
# app/config/config.yml
atm_competition:
user: User namespace
media_folder: path to media folder
contestant_role: role for the contestants
froala_key: froala key
main_picture_width: width for images
main_picture_height: height for images
watermark_image_small: 'watermark_small.png'
watermark_image_medium: 'watermark_medium.png'
watermark_image_big: 'watermark_big.png'
email_from_name: Name for the from email address
email_from_address: from email address
email_subject: Subject for the email when a anonymous user vote
site_domain: site domain
messages:
not_allowed: message when a contestant is not allowed to join a competition
vote_link_sent: message when a link sent to an anonymous user for voting
already_voted: message shown when a user already voted
email_not_validated: message when the email of an anonymous user is not validated
voted_successfully: message shown when a user votes
media_entity:
namespace: media entity namespace
order_by_field: field for sorting results
order_by_direction: sorting direction
Routing
Append to the main routing file:
# app/config/routing.yml
atm_competition:
resource: "@ATMCompetitionBundle/Controller/CompetitionController.php"
type: annotation
prefix: /
# The frontend routing should be not protected by the firewall
atm_competition_frontend:
resource: "@ATMCompetitionBundle/Controller/FrontendController.php"
type: annotation
prefix: /
Usage
After creating a new competition you can customize the landing page of it by creating a twig file using competition's canonical in the following path.(Imagine that the competition is called spring competition it's canonical will be springcompetition): ATMCompetitionBundle\views\Frontend\competitioncanonical.html.twig
These are the variables that are used in that view:
- competition: competition data as an array
- contestant_role: role from the configuration that the contestant have to had in order to join the competition
- page: needed in case to show a list of contestants.
For showing the contestants of a competition you can use the following function:
{{ render(controller('ATMCompetitionBundle:Frontend:searchContestants',{
'params' : {
'page': page,
'competition_id': competition.id,
'order_by_field': 'name',
'order_by_direction': 'DESC',
'max_results' : 10
}
})) }}
Services
There are 3 services for searching.
SearchCompetition
This service accept the following parameters for searching competitions:
$defaultOptions = array(
'name' => null,
'date' => null,
'ids' => null,
'pagination' => null,
'page' => 1,
'order_by_field' => 'name',
'order_by_direction' => 'DESC',
'max_results' => null
);
It will return an array with 2 keys:
- results: results from the query
- pagination: pagination object in case that pagination is true
SearchContestants
This service accept the following parameters for searching contestants:
$defaultOptions = array(
'name' => null,
'date' => null,
'ids' => null,
'competition' => null,
'pagination' => null,
'page' => 1,
'order_by_field' => 'name',
'order_by_direction' => 'DESC',
'max_results' => null
);
It will return an array with 2 keys:
- results: results from the query
- pagination: pagination object in case that pagination is true
_If you put order_byfield = 'votes' you will get the contestants sorted by it's total votes.
SearchVotes
This service accept the following parameters for searching votes:
$defaultOptions = array(
'email' => null,
'competition_id' => null,
'contestant_id' => null,
'creation_date' => null,
'ids' => null,
'sorting' => 'DESC',
'sorting_field' => null,
'date_limit' => array(
'min' => null,
'max' => null
),
'limit' => null,
'hydrate' => true,
'page' => 1,
'max_results' => null,
'pagination' => null,
'count' => null
);
It will return an array with 2 keys:
- results: results from the query
- pagination: pagination object in case that pagination is true
If count is true it will return an array with only 1 key:
- count: total amount of votes of a contestant
Twig Extensions
These are the following functions that you can use in twig:
- ATMCompIsContestant($competitionId,$userId): checks if a user is a contestant of a competition.
- ATMCompGetLastUserMedia($maxResults,$userId): gets the media based on the media namespace in the configuration.
- ATMCompIsRegisterPeriod($competitionId): checks if it's the register period of a competition.
- ATMCompIsCompetitionActive($competitionId): checks if a competition is active.
- ATMCompContestantTotalVotes($contestantId): get contestant total votes.
Mail sent to anonymous user
If the user that votes is not logged in the system sends an email to it with a link for voting. You can customize the mail template creating a twig file in the views/Mail called competitioncanonical_vote_link.html.twig. The system passes a variable called {{ vote_link }}.
In the views/Mail folder there is an example template called thegoodone_vote_link.html.twig.
Example
In the views/Frontend you can see an example of a competition landing page called thegoodone.html.twig.
atm/competitionbundle 适用场景与选型建议
atm/competitionbundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 296 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「atm competition bundle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 atm/competitionbundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 atm/competitionbundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 atm/competitionbundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
Bundle Symfony DaplosBundle
Provides a Data Grid tables for your Symfony project.
统计信息
- 总下载量: 296
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-11