Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] integrate UpdaterBundle #1281

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions newscoop/application/AppKernel.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

/**
* @package Newscoop\Gimme
* @author Paweł Mikołajczuk <[email protected]>
* @copyright 2012 Sourcefabric o.p.s.
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*/

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

Expand All @@ -20,15 +19,16 @@ protected function initializeContainer()
if (!empty($timeZone)) {
date_default_timezone_set($timeZone);
}
} catch (\Exception $e) { }
} catch (\Exception $e) {
}

// Set temp dir for Newscoop to project cache directory
putenv(sprintf('TMPDIR=%s/../cache', __DIR__));
}

public function registerBundles()
{
$bundles = array(
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
Expand All @@ -53,7 +53,8 @@ public function registerBundles()
new Newscoop\ArticlesBundle\NewscoopArticlesBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(),
new Newscoop\PluginGeneratorBundle\NewscoopPluginGeneratorBundle()
new Newscoop\PluginGeneratorBundle\NewscoopPluginGeneratorBundle(),
new SWP\UpdaterBundle\SWPUpdaterBundle(),
);

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
Expand All @@ -63,7 +64,7 @@ public function registerBundles()
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
}

$cachedPlugins = __DIR__ . '/../plugins/available_plugins.json';
$cachedPlugins = __DIR__.'/../plugins/available_plugins.json';
if (file_exists($cachedPlugins)) {
$plugins = json_decode(file_get_contents($cachedPlugins));
foreach ($plugins as $plugin) {
Expand All @@ -81,12 +82,12 @@ public function registerContainerConfiguration(LoaderInterface $loader)

public function getCacheDir()
{
return $this->truepath($this->rootDir . '/../cache/' . $this->environment);
return $this->truepath($this->rootDir.'/../cache/'.$this->environment);
}

public function getLogDir()
{
return $this->truepath($this->rootDir . '/../log');
return $this->truepath($this->rootDir.'/../log');
}

/**
Expand All @@ -103,33 +104,41 @@ protected function getContainerBaseClass()

/**
* This function is to replace PHP's extremely buggy realpath().
*
* @param string The original path, can be relative etc.
*
* @return string The resolved path, it might not exist.
*/
public function truepath($path)
{
// whether $path is unix or not
$unipath=strlen($path)==0 || $path{0}!='/';
$unipath = strlen($path) == 0 || $path{0}
!= '/';
// attempts to detect if path is relative in which case, add cwd
if(strpos($path,':')===false && $unipath)
$path=getcwd().DIRECTORY_SEPARATOR.$path;
if (strpos($path, ':') === false && $unipath) {
$path = getcwd().DIRECTORY_SEPARATOR.$path;
}
// resolve path parts (single dot, double dot and double delimiters)
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutes = array();
foreach ($parts as $part) {
if ('.' == $part) continue;
if ('.' == $part) {
continue;
}
if ('..' == $part) {
array_pop($absolutes);
} else {
$absolutes[] = $part;
}
}
$path=implode(DIRECTORY_SEPARATOR, $absolutes);
$path = implode(DIRECTORY_SEPARATOR, $absolutes);
// resolve any symlinks
if(file_exists($path) && linkinfo($path)>0)$path=readlink($path);
if (file_exists($path) && linkinfo($path) > 0) {
$path = readlink($path);
}
// put initial separator that could have been lost
$path=!$unipath ? '/'.$path : $path;
$path = !$unipath ? '/'.$path : $path;

return $path;
}
Expand Down
3 changes: 2 additions & 1 deletion newscoop/application/configs/parameters/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ parameters:
scheduler:
environment: 'prod'
simple_security:
users_file: "%application_path%/configs/security/users.json"
users_file: "%application_path%/configs/security/users.json"
swp_updater.version.class: "Newscoop\Version"
15 changes: 8 additions & 7 deletions newscoop/application/configs/symfony/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ fos_rest:
decoders:
json: fos_rest.decoder.json
format_listener:
default_priorities:
- json
- html
fallback_format: json
prefer_extension: true
rules:
- { path: '^/(api|content\-api)', priorities: ['json'], fallback_format: json, prefer_extension: true }
- { path: '^/', stop: true }
exception:
codes:
'Newscoop\Exception\ResourcesConflictException': 409
Expand All @@ -83,7 +81,6 @@ fos_rest:
'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
'Doctrine\ORM\EntityNotFoundException': 404
'Symfony\Component\Form\Exception\InvalidArgumentException': 500
'Symfony\Component\HttpKernel\Exception\FlattenException': 404
'Symfony\Component\Routing\Exception\MethodNotAllowedException': 404
'Newscoop\Exception\ResourceNotModifiedException': 304
'Newscoop\NewscoopException': 500
Expand All @@ -97,7 +94,6 @@ fos_rest:
'Doctrine\ORM\EntityNotFoundException': true
'Symfony\Component\Form\Exception\InvalidArgumentException' : true
'Symfony\Component\Routing\Exception\MethodNotAllowedException': true
'Symfony\Component\HttpKernel\Exception\FlattenException': true
'Newscoop\Exception\ResourceNotModifiedException': false
'OAuth2\OAuth2AuthenticateException': true
'Newscoop\NewscoopException': true
Expand Down Expand Up @@ -206,3 +202,8 @@ stof_doctrine_extensions:
translatable: true
sortable: true
loggable: false

swp_updater:
version_class: %swp_updater.version.class%
client:
base_uri: http://rafal.sourcefabric.net
5 changes: 4 additions & 1 deletion newscoop/application/configs/symfony/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ NewscoopGimmeBundleConfigureApi:
resource: "@NewscoopGimmeBundle/Controller/ConfigureApiController.php"
prefix: /
type: annotation
swp_updater:
resource: "@NewscoopGimmeBundle/Resources/config/updater_routing.yml"
prefix: /
newscoop:
prefix: /
resource: "@NewscoopNewscoopBundle/Resources/config/routing.yml"
Expand All @@ -51,4 +54,4 @@ plugins:
type: plugins
zendBridge:
prefix: /
resource: "@NewscoopZendBridgeBundle/Resources/config/routing.yml"
resource: "@NewscoopZendBridgeBundle/Resources/config/routing.yml"

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions newscoop/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
"sensio\/generator-bundle":"2.4.*@dev",
"incenteev\/composer-parameter-handler":"~2.0",
"bombayworks\/zendframework1":"1.11.*",
"friendsofsymfony\/rest-bundle":"0.13.*@dev",
"friendsofsymfony\/rest-bundle":"^1.7.1",
"kriswallsmith\/buzz":">=0.7",
"knplabs\/knp-paginator-bundle":"2.4.0",
"knplabs\/knp-components":"1.2.4",
"jms\/serializer-bundle":"0.13.0",
"jms\/serializer":"0.16.0",
"jms\/serializer-bundle":"^1.0",
"hybridauth\/hybridauth":"v2.4.1",
"smarty\/smarty":"3.1.21",
"knplabs\/knp-menu-bundle":"2.0.*@dev",
Expand All @@ -58,7 +57,8 @@
"dflydev\/doctrine-orm-service-provider":"1.0.4",
"pimple\/pimple":"1.1.*@dev",
"raven\/raven":"0.9.0",
"stof\/doctrine-extensions-bundle":"1.2.*@dev"
"stof\/doctrine-extensions-bundle":"1.2.*@dev",
"swp\/updater-bundle":"1.0.x-dev"
},
"require-dev":{
"phpunit\/phpunit":"~4.0",
Expand Down
Loading