Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4793281
TriggerDockerHubBuild.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
TriggerDockerHubBuild.php
View Options
<?php
namespace
Nasqueron\Notifications\Jobs
;
use
Nasqueron\Notifications\Actions\ActionError
;
use
Nasqueron\Notifications\Actions\TriggerDockerHubBuildAction
;
use
Nasqueron\Notifications\Events\ReportEvent
;
use
Nasqueron\Notifications\Facades\DockerHub
;
use
Exception
;
use
Illuminate\Support\Facades\Event
;
/**
* This class allows to trigger a new Docker Hub build.
*/
class
TriggerDockerHubBuild
extends
Job
{
///
/// Private members
///
/**
* @var string The Docker image to trigger a build for
*/
private
$image
;
/**
* @var TriggerDockerHubBuildAction
*/
private
$actionToReport
;
///
/// Constructor
///
/**
* Initializes a new instance of TriggerDockerHubBuild.
*/
public
function
__construct
(
$image
)
{
$this
->
image
=
$image
;
}
///
/// Task
///
/**
* Executes the job.
*
* @return void
*/
public
function
handle
()
:
void
{
$this
->
initializeReport
();
$this
->
triggerBuild
();
$this
->
sendReport
();
}
/**
* Initializes the actions report.
*/
private
function
initializeReport
()
:
void
{
$this
->
actionToReport
=
new
TriggerDockerHubBuildAction
(
$this
->
image
);
}
/**
* Triggers a new Docker Hub build.
*/
private
function
triggerBuild
()
:
void
{
try
{
DockerHub
::
build
(
$this
->
image
);
}
catch
(
Exception
$ex
)
{
$actionError
=
new
ActionError
(
$ex
);
$this
->
actionToReport
->
attachError
(
$actionError
);
}
}
/**
* Fires a report event with the actions report.
*/
private
function
sendReport
()
:
void
{
$event
=
new
ReportEvent
(
$this
->
actionToReport
);
Event
::
dispatch
(
$event
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 21:45 (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2445377
Default Alt Text
TriggerDockerHubBuild.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment