Skip to content

Commit

Permalink
Initialize project
Browse files Browse the repository at this point in the history
  • Loading branch information
burahimu committed Aug 18, 2017
0 parents commit ea855d4
Show file tree
Hide file tree
Showing 101 changed files with 6,942 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .docker/build/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG NODE_VERSION
FROM node:${NODE_VERSION}-stretch

RUN apt-get update
RUN apt-get install -y curl xvfb chromium chromium-l10n firefox-esr ruby ruby-dev
RUN gem install sass

RUN npm install --global gulp eslint bower && \
echo '{ "allow_root": true }' > /root/.bowerrc

# Add Chromium and Firefox with xvfb for karma tests

ADD xvfb-chromium /usr/bin/xvfb-chromium
RUN chmod +x /usr/bin/xvfb-chromium
ENV CHROMIUM_BIN=/usr/bin/xvfb-chromium

ADD xvfb-firefox /usr/bin/xvfb-firefox
RUN chmod +x /usr/bin/xvfb-firefox
ENV FIREFOX_BIN=/usr/bin/xvfb-firefox

WORKDIR /usr/src/app
3 changes: 3 additions & 0 deletions .docker/build/node/xvfb-chromium
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

xvfb-run -a chromium --no-sandbox $@
3 changes: 3 additions & 0 deletions .docker/build/node/xvfb-firefox
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

xvfb-run -a firefox $@
39 changes: 39 additions & 0 deletions .docker/build/php/Dockerfile-5.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM php:5.6-fpm

RUN apt-get update
RUN apt-get install -y git wget vim

# 3rd part libraries
# RUN apt-get install -y imagemagick

# extensions
RUN docker-php-ext-install iconv
RUN docker-php-ext-install mysql
RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install opcache
RUN docker-php-ext-install bcmath
RUN apt-get install zlib1g-dev -y && docker-php-ext-install zip
RUN apt-get install libxml2-dev -y && docker-php-ext-install soap
RUN apt-get install libmcrypt-dev -y && docker-php-ext-install mcrypt
RUN apt-get install libpng12-dev -y && docker-php-ext-install gd
RUN apt-get install libxml2-dev -y && docker-php-ext-install xml
RUN apt-get install libicu-dev -y && docker-php-ext-install intl
RUN apt-get install -y zlib1g-dev && pecl install memcache && docker-php-ext-enable memcache
RUN apt-get install pkg-config libssl-dev -y && pecl install mongo && docker-php-ext-enable mongo

# xdebug
RUN pecl install xdebug && docker-php-ext-enable xdebug

# php.ini
COPY php.ini /usr/local/etc/php/

# www.conf
COPY www.conf /usr/local/etc/php-fpm.d/

# install composer
COPY install-composer.sh /tmp/install-composer.sh
RUN chmod +x /tmp/install-composer.sh
RUN bash /tmp/install-composer.sh
VOLUME /root/.composer
18 changes: 18 additions & 0 deletions .docker/build/php/install-composer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")

if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi

php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
mv -f composer.phar /usr/local/bin/composer
exit $RESULT
18 changes: 18 additions & 0 deletions .docker/build/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.

date.timezone = 'Europe/Paris';
short_open_tag = Off;
magic_quotes_gpc = Off;
register_globals = Off;
session.auto_start = Off;
error_reporting = E_ALL;
log_errors = On;
display_errors = On;
error_log = /dev/stderr;
memory_limit = -1;
12 changes: 12 additions & 0 deletions .docker/build/php/www.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
user = www-data
group = www-data

listen = 9000

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

catch_workers_output = yes
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
VOLUME_ROOT_PATH=~/.docker

COMPANY_NAME=idci
PROJECT_NAME=task-bundle

# [dev | public]
NETWORK_NAME=dev

# [5.4 | 5.6 | 7.0]
PHP_VERSION=5.6

NODE_VERSION=8.4.0
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
phpunit.xml

# Gedit
*~
*swp

# Node modules
node_modules

# Tests
/Tests/cache
/Tests/logs

# vendor
/vendor
167 changes: 167 additions & 0 deletions Action/AbstractAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?php

/**
* @author: Brahim Boukoufallah <[email protected]>
*/

namespace IDCI\Bundle\TaskBundle\Action;

use Symfony\Component\OptionsResolver\OptionsResolver;
use Psr\Log\LoggerInterface;
use IDCI\Bundle\TaskBundle\Exception\InvalidActionDataException;
use IDCI\Bundle\TaskBundle\Document\Task;
use IDCI\Bundle\TaskBundle\Monolog\Processor\TaskLogProcessor;

abstract class AbstractAction implements ActionInterface
{
/** @var array */
protected $actionParameters = array();

/** @var ActionInterface */
protected $parent;

/** @var LoggerInterface */
protected $logger;

/** @var TaskLogProcessor */
protected $taskLogProcessor;

/**
* Do execute using parameters.
*
* @param array $options
*
* @return array
*/
abstract public function doExecute(array $options);

/**
* Set default parameters.
*
* @param OptionsResolver $resolver
*/
abstract protected function setDefaultParameters(OptionsResolver $resolver);

/**
* Configure returned data.
*
* @param OptionsResolver $resolver
*/
public function configureReturnedData(OptionsResolver $resolver)
{
$resolver
->setRequired(array('error'))
->setDefaults(array(
'data' => null,
'error_message' => '',
))
->setDefined(array('error_message'))
->setAllowedTypes('error', array('bool'))
->setAllowedTypes('data', array('null', 'array', 'string', 'bool'))
->setAllowedTypes('error_message', array('string'))
;
}

/**
* {@inheritdoc}
*/
public function execute(Task $task, array $parameters)
{
$this->taskLogProcessor->setTask($task);

$resolver = new OptionsResolver();
$this->setDefaultParameters($resolver);
$resolvedParameters = $resolver->resolve($parameters);

$data = $this->doExecute($resolvedParameters);

try {
$resolver = new OptionsResolver();
$this->configureReturnedData($resolver);
$data = $resolver->resolve($data);
} catch (\Exception $e) {
throw new InvalidActionDataException(get_called_class());
}

return $data;
}

/**
* {@inheritdoc}
*/
public function setActionParameters(array $parameters = array())
{
$this->actionParameters = $parameters;

return $this;
}

/**
* {@inheritdoc}
*/
public function getActionParameters()
{
if (null === $this->getParent()) {
return $this->actionParameters;
}

return array_replace_recursive(
$this->getParent()->getActionParameters(),
$this->actionParameters
);
}

/**
* {@inheritdoc}
*/
public function setParent(ActionInterface $parent)
{
$this->parent = $parent;

return $this;
}

/**
* {@inheritdoc}
*/
public function getParent()
{
return $this->parent;
}

/**
* {@inheritdoc}
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;

return $this;
}

/**
* {@inheritdoc}
*/
public function getLogger()
{
return $this->logger;
}

/**
* {@inheritdoc}
*/
public function setTaskLogProcessor(TaskLogProcessor $taskLogProcessor)
{
$this->taskLogProcessor = $taskLogProcessor;

return $this;
}

/**
* {@inheritdoc}
*/
public function getTaskLogProcessor()
{
return $this->taskLogProcessor;
}
}
73 changes: 73 additions & 0 deletions Action/ActionConfigurationRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/**
* @author: Brahim Boukoufallah <[email protected]>
*/

namespace IDCI\Bundle\TaskBundle\Action;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

class ActionConfigurationRule implements ConfigurationInterface
{
/** @var ActionRegistry */
protected $actionRegistry;

public function __construct(ActionRegistry $actionRegistry)
{
$this->actionRegistry = $actionRegistry;
}

/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('action');
$rootNode
->children()
->arrayNode('actions')
->prototype('array')
->children()
->scalarNode('name')->end()
->enumNode('action')
->isRequired()
->values(array_keys($this->actionRegistry->getActions()))
->end()
->arrayNode('parameters')
->prototype('variable')->end()
->end()
->end()
->end()
->end()
->arrayNode('workflow')
->children()
->scalarNode('name')->isRequired()->cannotBeEmpty()->end()
->scalarNode('first_action_name')->isRequired()->cannotBeEmpty()->end()
->arrayNode('actions')
->useAttributeAsKey('action_name')
->isRequired()
->prototype('array')
->children()
->arrayNode('next')
->prototype('array')
->children()
->scalarNode('name')->isRequired()->cannotBeEmpty()->end()
->scalarNode('condition')->isRequired()->cannotBeEmpty()->end()
->end()
->end()
->end()
->scalarNode('default_next')->isRequired()->end()
->end()
->end()
->end()
->end()
->end()
->end()
;

return $treeBuilder;
}
}
Loading

0 comments on commit ea855d4

Please sign in to comment.