Skip to content

Commit

Permalink
WIP: Sf4 Compat
Browse files Browse the repository at this point in the history
  • Loading branch information
BadPixxel committed Sep 23, 2020
1 parent 654614d commit 4f9b887
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ services:
dockerfile: Dockerfile
container_name: widgets-php
volumes:
- './:/app'
- './:/project'
- ~/.composer:/home/docker/.composer
hostname: widgets.splashsync.local
command: ["php", "/app/bin/console", "server:run", "172.169.1.10:80"]
command: ["php", "/project/bin/console", "server:run", "-d/project/web", "172.169.1.10:80"]
networks:
widgets: { ipv4_address: 172.169.1.10 }

Expand Down
20 changes: 2 additions & 18 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

FROM php:7.4-alpine
EXPOSE 80
WORKDIR /app
WORKDIR /project

################################################################################
# Install Required Libs
Expand All @@ -32,21 +32,5 @@ RUN docker-php-ext-install zip
ENV COMPOSER_MEMORY_LIMIT: -1
ENV COMPOSER_HOME: '/home/docker/.composer'
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
#################################################################################
## Clone Project
#RUN git clone https://github.com/SplashSync/Toolkit.git --depth=1 /app
#################################################################################
## Configure Project
#COPY .env /app/.env
#COPY config/splash.yml /app/config/packages/splash.yml
#################################################################################
## Run Composer
#RUN cd /app && php -d memory_limit=-1 /usr/bin/composer update
##RUN cd /app && php -d memory_limit=-1 /usr/bin/composer install
#################################################################################
## Install Project
#RUN php /app/bin/console assets:install --no-debug
#RUN php /app/bin/console doctrine:schema:update --force
#RUN php /app/bin/console cache:clear

CMD ["php", "/app/bin/console", "server:run", "80"]
CMD ["php", "/project/bin/console", "server:run", "80"]
4 changes: 2 additions & 2 deletions docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ echo "** Configure Symfony ..."
echo "*************************************************************************"

docker-compose exec symfony composer install
docker-compose exec symfony php /app/bin/console doctrine:schema:update --force
docker-compose exec symfony php /app/bin/console cache:clear
docker-compose exec symfony php bin/console doctrine:schema:update --force
docker-compose exec symfony php bin/console cache:clear

echo "*************************************************************************"
echo "** Install Webpack "
Expand Down
4 changes: 2 additions & 2 deletions docker/restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ echo "*************************************************************************"
echo "** Configure the Demo ..."
echo "*************************************************************************"

docker-compose exec symfony php /app/bin/console doctrine:schema:update --force
docker-compose exec symfony php /app/bin/console cache:clear
docker-compose exec symfony php bin/console doctrine:schema:update --force
docker-compose exec symfony php bin/console cache:clear
9 changes: 5 additions & 4 deletions src/Resources/config/demo.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
services:

# Demo Widgets Factroy Service
# Demo Widgets Factory Service
splash.widgets.demo.factory:
class: Splash\Widgets\Services\Demo\SamplesFactoryService
arguments: ["@splash.widgets.factory"]
class: Splash\Widgets\Services\Demo\SamplesFactoryService
arguments: ["@splash.widgets.factory"]
public: true
tags:
- { name: kernel.event_listener, event: splash.widgets.list.demo, method: onListingAction }
- { name: kernel.event_listener, event: Splash\Widgets\Event\ListingEvent, method: onListingAction }

4 changes: 2 additions & 2 deletions src/Resources/config/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ services:

# Test Widgets Factory Service
splash.widgets.test.factory:
class: Splash\Widgets\Tests\Services\SamplesFactoryService
arguments: ["@splash.widgets.factory"]
class: Splash\Widgets\Tests\Services\SamplesFactoryService
arguments: ["@splash.widgets.factory"]
public: true
tags:
- { name: kernel.event_listener, event: Splash\Widgets\Event\ListingEvent, method: onListingAction }
Expand Down
8 changes: 8 additions & 0 deletions src/Services/Demo/SamplesFactoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class SamplesFactoryService implements WidgetProviderInterface
const PREFIX = "Splash\\Widgets\\Models\\Demo\\Blocks\\";
const SERVICE = "splash.widgets.demo.factory";
const ORIGIN = "<i class='fa fa-flask text-success' aria-hidden='true'>&nbsp;</i>Demo Factory";
const MODES = array(
"splash.widgets.list.demo",
);

/**
* WidgetFactory Service
Expand Down Expand Up @@ -60,6 +63,11 @@ public function __construct(FactoryService $widgetFactory)
*/
public function onListingAction(GenericEvent $event) : void
{
$mode = $event->getSubject();
if (!is_string($mode) || !in_array($mode, self::MODES, true)) {
return;
}

$event["Text"] = $this->buildWidgetDefinition("Text")->getWidget();
$event["Table"] = $this->buildWidgetDefinition("Table")->getWidget();
$event["Notifications"] = $this->buildWidgetDefinition("Notifications")->getWidget();
Expand Down
4 changes: 2 additions & 2 deletions src/Services/ManagerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function connect(string $service) : bool
public function read(string $type, array $parameters = array()) : bool
{
//==============================================================================
// Check Servive is Defined
// Check Service is Defined
if (!($this->service instanceof WidgetProviderInterface)) {
return false;
}
Expand All @@ -175,7 +175,7 @@ public function read(string $type, array $parameters = array()) : bool
}
$this->widget = $widget;
//==============================================================================
// Store Paremeter in Widget From Rendering
// Store Parameter in Widget From Rendering
if ($blockParameters) {
$this->widget->setParameters($parameters);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Controller/A001InitialisationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public function testCacheClear(string $environement) : void
//====================================================================//
// Clean Working Dir
$workingDirectory = (string) $process->getWorkingDirectory();
if (strrpos($workingDirectory, "/app") == (strlen($workingDirectory) - 4)) {
if (strrpos($workingDirectory, "/web") == (strlen($workingDirectory) - 4)) {
$process->setWorkingDirectory(substr($workingDirectory, 0, strlen($workingDirectory) - 4));
} elseif (strrpos($workingDirectory, "/app") == (strlen($workingDirectory) - 4)) {
$process->setWorkingDirectory(substr($workingDirectory, 0, strlen($workingDirectory) - 4));
}

Expand Down
7 changes: 6 additions & 1 deletion tests/Services/SamplesFactoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class SamplesFactoryService extends Base
const PREFIX = "Splash\\Widgets\\Tests\\Blocks\\";
const SERVICE = "splash.widgets.test.factory";
const ORIGIN = "<i class='fa fa-github text-success' aria-hidden='true'>&nbsp;</i>Tests Factory";
const MODES = array(
"splash.widgets.list.test",
"splash.widgets.list.tested",
"splash.widgets.list.demo",
);

/**
* Widgets Listing
Expand All @@ -35,7 +40,7 @@ class SamplesFactoryService extends Base
public function onListingAction(GenericEvent $event) : void
{
$mode = $event->getSubject();
if (!is_string($mode) || !in_array($mode, array("test", "tested", "demo"), true)) {
if (!is_string($mode) || !in_array($mode, self::MODES, true)) {
return;
}
$event["Test"] = $this->buildWidgetDefinition("Test")->getWidget();
Expand Down

0 comments on commit 4f9b887

Please sign in to comment.