-
-
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
5 changed files
with
98 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Command; | ||
|
||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
use function sprintf; | ||
|
||
#[AsCommand( | ||
name: 'app:social-builder', | ||
description: 'This allow automate your social publications', | ||
)] | ||
class SocialBuilderCommand extends Command | ||
{ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
$arg1 = $input->getArgument('arg1'); | ||
|
||
if ($arg1) { | ||
$io->note(sprintf('You passed an argument: %s', $arg1)); | ||
} | ||
|
||
if ($input->getOption('option1')) { | ||
// ... | ||
} | ||
|
||
$io->success('You have a new command! Now make it your own! Pass --help to see your options.'); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
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,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Job\FlowExamples\SocialBuilder; | ||
|
||
use Exception; | ||
use Flow\JobInterface; | ||
|
||
/** | ||
* @implements JobInterface<string, bool> | ||
*/ | ||
class SocialBuilderThumbnailJob implements JobInterface | ||
{ | ||
public function __invoke($data): bool | ||
{ | ||
// Define the path where the generated image will be saved | ||
$imagePath = __DIR__ . '/thumbnail.png'; | ||
|
||
// Create an image with width 400px and height 300px | ||
$width = 400; | ||
$height = 300; | ||
$image = imagecreatetruecolor($width, $height); | ||
|
||
// Set background color (white) | ||
$backgroundColor = imagecolorallocate($image, 255, 255, 255); | ||
imagefilledrectangle($image, 0, 0, $width, $height, $backgroundColor); | ||
|
||
// Set text color (black) | ||
$textColor = imagecolorallocate($image, 0, 0, 0); | ||
|
||
// Add the input string text to the image | ||
$fontPath = __DIR__ . '/arial.ttf'; // Ensure this is a valid font path | ||
$fontSize = 12; | ||
$angle = 0; | ||
$x = 10; | ||
$y = 50; | ||
|
||
// If a TTF font file exists, use it; otherwise, fall back to a built-in font | ||
if (file_exists($fontPath)) { | ||
imagettftext($image, $fontSize, $angle, $x, $y, $textColor, $fontPath, $data); | ||
} else { | ||
imagestring($image, 5, $x, $y, $data, $textColor); | ||
} | ||
|
||
// Save the image to the defined path | ||
if (!imagepng($image, $imagePath)) { | ||
throw new Exception('Failed to save the generated image.'); | ||
} | ||
|
||
// Free up memory | ||
imagedestroy($image); | ||
|
||
return true; | ||
} | ||
} |