Skip to content

Instantly share code, notes, and snippets.

View nyangkul's full-sized avatar

Ash-Shiddiqul Akbar Hidayat nyangkul

View GitHub Profile
@nyangkul
nyangkul / NewsFeedServiceProvider.php
Created November 18, 2015 07:15
News Feed Service Provider
<?php
class NewsFeedServiceProvider extends ServiceProvider
{
public function register()
{
// Ketika seluruh event dari Domain Challenge dibangkitkan, maka kita jalankan ChallengeFeedListener
// untuk menangani event tersebut.
\Event::listen('Dicoding.Domain.Challenge.*', 'Dicoding\Infrastructure\Feeds\Challenges\ChallengeFeedListener');
}
@nyangkul
nyangkul / EventMailerServiceProvider.php
Created November 18, 2015 07:09
Event Mailer Service Provider
<?php
class EventMailerServiceProvider extends ServiceProvider
{
public function register()
{
// Ketika seluruh event dari Domain Challenge dibangkitkan, maka kita jalankan ChallengeEventMailer
// untuk menangani event tersebut.
\Event::listen('Dicoding.Domain.Challenge.*', 'Dicoding\Infrastructure\Emailing\Challenge\ChallengeEventMailer');
}
@nyangkul
nyangkul / ChallengePublicationContext.php
Last active November 18, 2015 07:01
Contoh Mempublikasikan sebuah unpublished challenge
<?php
class ChallengePublicationContext
{
public function publishUnpublishedChallenge($challengeId)
{
// Jalankan logika bisnis yang berhubungan dengan
// proses mempublikasikan unpublised challenge
// Bila sukses, maka kita tambahkan Challenge ini ke
@nyangkul
nyangkul / PublishUnpublishedChallengeHandler.php
Created November 18, 2015 06:52
PublishUnpublishedChallengeHandler.php tanpa tugas sekunder
<?php
class PublishUnpublishedChallengeHandler
{
public function handle(PublishUnpublishedChallenge $command)
{
try {
DB::beginTransaction();
$publishedChallenge = $this->challengePublicationContext->publishUnpublishedChallenge($command->challenge_id);
@nyangkul
nyangkul / PublishUnpublishedChallengeHandler.php
Created November 18, 2015 06:38
Publishing Unpublished Challenge
<?php
class PublishUnpublishedChallengeHandler
{
public function handle(PublishUnpublishedChallenge $command)
{
try {
DB::beginTransaction();
@nyangkul
nyangkul / CreateUnpublishedChallengeHandler.php
Last active November 17, 2015 08:07
Create Unpublished Challenge Command Handler
<?php
use Dicoding\ApplicationService\Challenges;
class CreateUnpublishedChallengeHandler
{
public function handle(CreateUnpublishedChallenge $command)
{
try {
@nyangkul
nyangkul / RegistrationExample.php
Created November 17, 2015 08:00
Register Developer
<?php
class EmailMembershipController
{
public function store()
{
try {
$this->execute(RegisterDeveloper::class);
@nyangkul
nyangkul / DailyTaskNotifier.php
Created November 17, 2015 07:17
Menjalankan Command di luar controller
<?php
use Dicoding\ApplicationService\Administration\NotifyPendingTaskCommand;
use Illuminate\Console\Command;
class DailyTaskNotifier extends Command
{
// code lain disembunyikan agar contoh ini menjadi lebih ringkas
public function fire()
@nyangkul
nyangkul / ChallengeController.php
Last active November 17, 2015 07:11
SimpleBus
<?php
class ChallengeController
{
public function store()
{
try {
$this->commandBus()->handle(new CreateUnpublishedChallenge(
'Nama',
@nyangkul
nyangkul / ChallengeController.php
Created November 17, 2015 07:05
Excecuting Create Unpublished Command
<?php
class ChallengeController
{
public function store()
{
try {
// Mengeksekusi Command
$this->execute(CreateUnpublishedChallenge::class);