Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Add factory for toolz controller
Browse files Browse the repository at this point in the history
  • Loading branch information
neilime committed Nov 7, 2016
1 parent 5b854ea commit 64a1b2a
Show file tree
Hide file tree
Showing 8 changed files with 10,942 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/.project
/vendor
/nbproject/
/.composer.lock
/composer.lock
27 changes: 17 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
language: php

sudo: false

env:
global:
- secure: PENfjgcItjkcdkDjZZABlQzrcSDDgtAR5uJ/bTFJ+lryS675X5V/2nzSikxkpx0NvIBvj4N6ooQZDG/WsDNsNL9SYPjeEcmW60ADxs8SBU3+SczBIEIK3IN/5Cdmfrx0HrmuShMe6gkV07ZT1/Jhch1WExapfssZ9eniPqDkECE=

matrix:
include:
- php: '5.3'
Expand All @@ -13,28 +19,29 @@ addons:
apt:
packages:
- graphviz

env:
global:
- secure: mZnk+Ub659qODl3u7oGo1wNEwHBk35VXRaXO9mqkeaswfhasb33qVKnBUeGBAY6UIhKlFPRvljTYb/AryA5X7+tgjmRCi9oY5Yr+vQMVw9vc7R+tr5lNEJEZjyGKA3My6LoWI/zUtszkW1j1zTvY7THejBIiVB/HZ7w6FosSh7U=
sudo: false

cache:
directories:
- "$HOME/.composer/cache"

before_install:
- mkdir -p ~/.composer
- cp .travis.composer.json ~/.composer/config.json
- composer self-update
- composer install --prefer-dist --dev
- pear channel-discover pear.phpdoc.org
- pear install phpdoc/phpDocumentor
- phpenv rehash

before_script:
- mkdir -p build/logs
- mkdir -p build/coverage
- mkdir -p build/phpdoc
- mkdir -p build/{logs,coverage,phpdoc}

script:
- cd tests
- phpunit -d max_execution_time=0 --coverage-text --coverage-clover ../build/logs/clover.xml --coverage-html ../build/coverage/
- cd ..

after_script:
- if [[ $EXECUTE_AFTER_SCRIPT == 'true' ]]; then php vendor/bin/coveralls --verbose --config;fi
- if [[ $EXECUTE_AFTER_SCRIPT == 'true' ]]; then vendor/bin/phpdoc -d "./src" -t "./build/phpdoc" --template="responsive-twig";fi
- if [[ $EXECUTE_AFTER_SCRIPT == 'true' ]]; then bash <(curl -s https://gist.githubusercontent.com/neilime/769d733c52acdecea8d2548fb3aca3ff/raw/853d54289f5c449ea9af6a4d8ca92e1f9fc80980/travis_ci_php_publish_build.sh);fi
- if [[ $EXECUTE_AFTER_SCRIPT == 'true' ]]; then phpdoc -d "./src" -t "./build/phpdoc" --template="responsive-twig";fi
- if [[ $EXECUTE_AFTER_SCRIPT == 'true' ]]; then bash <(curl -s https://gist.githubusercontent.com/neilime/769d733c52acdecea8d2548fb3aca3ff/raw/travis_ci_php_publish_build.sh);fi
1 change: 1 addition & 0 deletions autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'AssetsBundle\Factory\ServiceFactory' => __DIR__ . '/src/AssetsBundle/Factory/ServiceFactory.php',
'AssetsBundle\Factory\ServiceOptionsFactory' => __DIR__ . '/src/AssetsBundle/Factory/ServiceOptionsFactory.php',
'AssetsBundle\Factory\ToolsServiceFactory' => __DIR__ . '/src/AssetsBundle/Factory/ToolsServiceFactory.php',
'AssetsBundle\Factory\ToolsControllerFactory' => __DIR__ . '/src/AssetsBundle/Factory/ToolsControllerFactory.php',
'AssetsBundle\Mvc\Controller\AbstractActionController' => __DIR__ . '/src/AssetsBundle/Mvc/Controller/AbstractActionController.php',
'AssetsBundle\Service\Service' => __DIR__ . '/src/AssetsBundle/Service/Service.php',
'AssetsBundle\Service\ServiceOptions' => __DIR__ . '/src/AssetsBundle/Service/ServiceOptions.php',
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@
},
"require-dev": {
"zendframework/zend-test": "2.*.*",
"phpunit/phpunit": "4.*.*",
"phpunit/phpunit": "5.*.*",
"satooshi/php-coveralls": "1.*.*",
"neilime/lessphp": "0.*.*",
"phpdocumentor/phpdocumentor": "2.*.*"
"neilime/lessphp": "0.*.*"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 6 additions & 5 deletions config/module.config.controllers.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

//Controllers module config

// Controllers module config
return array(
'invokables' => array(
'AssetsBundle\Controller\Tools' => 'AssetsBundle\Controller\ToolsController'
)
);
'factories' => array(
'AssetsBundle\Controller\Tools' => 'AssetsBundle\Factory\ToolsControllerFactory'
),
);
50 changes: 34 additions & 16 deletions src/AssetsBundle/Controller/ToolsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,49 @@

namespace AssetsBundle\Controller;

class ToolsController extends \Zend\Mvc\Controller\AbstractActionController {
class ToolsController extends \Zend\Mvc\Controller\AbstractActionController
{

/**
* Process render all assets action
* @var \AssetsBundle\Service\ToolsService
*/
public function renderAssetsAction() {
// Retrieve service manager
$oServiceManager = $this->getEvent()->getApplication()->getServiceManager();

//Retrieve configuration
$aConfiguration = $oServiceManager->get('Config');
if (!isset($aConfiguration['assets_bundle'])) {
$oView = new \Zend\View\Model\ConsoleModel();
$oView->setErrorLevel(1);
return $oView->setResult('AssetsBundle configuration is undefined' . PHP_EOL);
}
protected $assetsBundleToolsService;

$oServiceManager->get('AssetsBundleToolsService')->renderAllAssets();
/**
* Process render all assets action
*/
public function renderAssetsAction()
{
$this->getAssetsBundleToolsService()->renderAllAssets();
}

/**
* Process empty cache action
*/
public function emptyCacheAction() {
$this->getEvent()->getApplication()->getServiceManager()->get('AssetsBundleToolsService')->emptyCache();
public function emptyCacheAction()
{
$this->getAssetsBundleToolsService()->emptyCache();
}

/**
* @return \AssetsBundle\Service\ToolsService
* @throws \LogicException
*/
public function getAssetsBundleToolsService()
{
if ($this->assetsBundleToolsService instanceof \AssetsBundle\Service\ToolsService) {
return $this->assetsBundleToolsService;
}
throw new \LogicException('Property "assetsBundleService" expects an instance of "\AssetsBundle\Service\ToolsService", "' . (is_object($this->assetsBundleToolsService) ? get_class($this->assetsBundleToolsService) : gettype($this->assetsBundleToolsService)) . '" defined');
}

/**
* @param \AssetsBundle\Service\ToolsService $oAssetsBundleToolsService
* @return \AssetsBundle\Controller\ToolsController
*/
public function setAssetsBundleToolsService(\AssetsBundle\Service\ToolsService $oAssetsBundleToolsService)
{
$this->assetsBundleToolsService = $oAssetsBundleToolsService;
return $this;
}
}
18 changes: 18 additions & 0 deletions src/AssetsBundle/Factory/ToolsControllerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace AssetsBundle\Factory;

class ToolsControllerFactory implements \Zend\ServiceManager\FactoryInterface
{

/**
* @see \Zend\ServiceManager\FactoryInterface::createService()
* @param \Zend\ServiceManager\ServiceLocatorInterface $oServiceLocator
* @return \AssetsBundle\Controller\ToolsController
*/
public function createService(\Zend\ServiceManager\ServiceLocatorInterface $oServiceLocator)
{
$oToolsController = new \AssetsBundle\Controller\ToolsController();
return $oToolsController->setAssetsBundleToolsService($oServiceLocator->getServiceLocator()->get('AssetsBundleToolsService'));
}
}
Loading

0 comments on commit 64a1b2a

Please sign in to comment.