Commit 16e2d7fc authored by Sean Madsen's avatar Sean Madsen

code formatting changes to pass civilint

parent 6f32daa8
......@@ -98,9 +98,9 @@ class PublishController extends Controller {
->setBody(
$this->renderView('AppBundle:Emails:notify.html.twig',
array(
'publishURLBase' => $this->publisher->publishURLBase,
'status' => $this->publisher->status,
'messages' => $this->publisher->messages,
'publishURLBase' => $this->publisher->publishURLBase,
'status' => $this->publisher->status,
'messages' => $this->publisher->messages,
)
), 'text/html'
);
......
......@@ -42,9 +42,9 @@ class Book {
public function __construct($confFile) {
$parser = new Parser();
$yaml = $parser->parse(file_get_contents($confFile));
$this->slug = StringTools::urlSafe(basename($confFile, '.yml'));
$this->name = $yaml['name'];
$this->weight = isset($yaml['weight']) ? $yaml['weight'] : 0;
$this->slug = StringTools::urlSafe(basename($confFile, '.yml'));
$this->name = $yaml['name'];
$this->weight = isset($yaml['weight']) ? $yaml['weight'] : 0;
$this->description = isset($yaml['description']) ? $yaml['description'] : "";
foreach ($yaml['langs'] as $code => $languageData) {
$this->languages[] = new Language($code, $languageData);
......@@ -54,7 +54,7 @@ class Book {
/**
* @return bool True when the book contains multiple languages.
*/
public function isMultiLanguage(){
public function isMultiLanguage() {
return count($this->languages) > 1;
}
......@@ -67,8 +67,8 @@ class Book {
*/
public function getLanguageByCode($code) {
$chosen = NULL;
foreach($this->languages as $language) {
if($language->code == $code) {
foreach ($this->languages as $language) {
if ($language->code == $code) {
$chosen = $language;
break;
}
......
......@@ -35,7 +35,7 @@ class Language {
* Initialize a language with values in it.
*
* @param string $code two letter language code
* @param array $yaml language data from a book's yaml file
* @param array $yaml language data from a book's yaml file
*/
public function __construct($code, $yaml) {
$this->code = $code;
......@@ -130,7 +130,7 @@ class Language {
$descriptors = array_merge($descriptors, $version->allDescriptors());
}
$duplicateDescriptors
= array_diff_assoc($descriptors, array_unique($descriptors));
= array_diff_assoc($descriptors, array_unique($descriptors));
if ($duplicateDescriptors) {
throw new \Exception(
"Duplicate descriptors '" . implode(", ", $duplicateDescriptors)
......@@ -157,7 +157,7 @@ class Language {
}
public function descriptiveName() {
if($this->code == 'en') {
if ($this->code == 'en') {
return $this->englishName();
}
else {
......@@ -183,8 +183,8 @@ class Language {
*/
public function getVersionByBranch($branch) {
$chosen = NULL;
foreach($this->versions as $version) {
if($version->branch == $branch) {
foreach ($this->versions as $version) {
if ($version->branch == $branch) {
$chosen = $version;
break;
}
......@@ -202,7 +202,7 @@ class Language {
*/
public function getVersionByDescriptor($descriptor) {
$chosen = NULL;
foreach($this->versions as $version) {
foreach ($this->versions as $version) {
if (in_array($descriptor, $version->allDescriptors())) {
$chosen = $version;
break;
......
......@@ -136,11 +136,11 @@ class Library {
* "versionDescriptor" => (string/NULL)
*/
public static function parseIdentifier($identifier) {
$identifier = preg_replace("#/+#", "/", trim($identifier)) ;
$identifier = preg_replace("#/+#", "/", trim($identifier));
$identifier = trim($identifier, "/");
$parts = explode("/", $identifier);
$result['bookSlug'] = ($parts[0]) ? $parts[0] : NULL;
$result['languageCode'] = isset($parts[1]) ? $parts[1] : NULL;
$result['bookSlug'] = ($parts[0]) ? $parts[0] : NULL;
$result['languageCode'] = isset($parts[1]) ? $parts[1] : NULL;
$result['versionDescriptor'] = isset($parts[2]) ? $parts[2] : NULL;
return $result;
}
......
......@@ -101,7 +101,7 @@ class GitHubHookProcessor {
* @param array $recipients Array of strings for emails of people to notify
*/
public function addRecipients($recipients) {
if (!is_array($recipients)){
if (!is_array($recipients)) {
$recipients = array($recipients);
}
$this->recipients = array_unique(array_merge($this->recipients, $recipients));
......
......@@ -2,7 +2,7 @@
namespace AppBundle\Utils;
define('locales_dir', __DIR__ . '/../../../vendor/symfony/symfony/src/Symfony/Component/Intl/Resources/data/locales');
define('LOCALES_DIR_CONST', __DIR__ . '/../../../vendor/symfony/symfony/src/Symfony/Component/Intl/Resources/data/locales');
/**
* A set of helper tools for dealing with different locales
......@@ -10,15 +10,15 @@ define('locales_dir', __DIR__ . '/../../../vendor/symfony/symfony/src/Symfony/Co
*/
class LocaleTools {
const LOCALES_DIR = locales_dir;
const LOCALES_DIR = LOCALES_DIR_CONST;
/**
* Returns the name of a language, in another language. For example, if
* $languageCode = 'en' and $localeCode = 'es' this function would answer the
* question "what word do Spanish-speaking people use to refer to English?"
*
* @param type $languageCode The language we're asking about
* @param type $localeCode The language in which we want our answer
* @param string $languageCode The language we're asking about
* @param string $localeCode The language in which we want our answer
*
* @return string
*/
......
......@@ -125,7 +125,7 @@ class Publisher {
$this->publishPathRoot = realpath($publishPathRoot);
if ($requestStack->getCurrentRequest()) {
$this->publishURLBase
= $requestStack->getCurrentRequest()->getUriForPath('');
= $requestStack->getCurrentRequest()->getUriForPath('');
}
else {
$this->publishURLBase = '/';
......@@ -218,7 +218,7 @@ class Publisher {
*/
private function initializeVersion($versionDescriptor) {
$this->version
= $this->language->getVersionByDescriptor($versionDescriptor);
= $this->language->getVersionByDescriptor($versionDescriptor);
if (!$this->version) {
$this->addMessage('CRITICAL',
"Descriptor '{$versionDescriptor}' does not map to a version defined "
......@@ -232,13 +232,14 @@ class Publisher {
catch (\Exception $e) {
$this->addMessage('CRITICAL', "The settings for version "
. "'{$this->version->name}' could not be validated. Validation error"
. "is: ". $e->getMessage());
. "is: " . $e->getMessage());
return FALSE;
}
if ($this->version->aliases) {
$aliasText = " with aliases: "
. implode(', ', array_map(function ($s) {return "'".$s."'";},
$this->version->aliases));
. implode(', ', array_map(function ($s) {
return "'$s'";
}, $this->version->aliases));
}
else {
$aliasText = "";
......@@ -279,7 +280,7 @@ class Publisher {
*
* @return boolean TRUE if success
*/
private function gitCheckout(){
private function gitCheckout() {
$gitCheckCurrentBranch = new Process(
'git rev-parse --abbrev-ref HEAD', $this->repoPath);
$gitCheckCurrentBranch->run();
......@@ -380,7 +381,7 @@ class Publisher {
$purgeExisting->run();
// Add new symlinks
foreach($this->version->aliases as $alias) {
foreach ($this->version->aliases as $alias) {
$this->fs->symlink($this->publishPath, "$path/$alias");
$url = "{$this->publishURLBase}/{$this->book->slug}/"
. "{$this->language->code}/$alias";
......@@ -407,18 +408,16 @@ class Publisher {
$this->suppliedIdentifier = $identifier;
$this->addMessage('NOTICE', "PUBLISHING $identifier");
$parts = Library::parseIdentifier($identifier);
$bookSlug = $parts['bookSlug'];
$languageCode = $parts['languageCode'];
$bookSlug = $parts['bookSlug'];
$languageCode = $parts['languageCode'];
$versionDescriptor = $parts['versionDescriptor'];
if ($versionDescriptor) {
$success =
$this->initializeBook($bookSlug) &&
$success = $this->initializeBook($bookSlug) &&
$this->initializeLanguage($languageCode) &&
$this->publishVersion($versionDescriptor);
}
elseif ($languageCode) {
$success =
$this->initializeBook($bookSlug) &&
$success = $this->initializeBook($bookSlug) &&
$this->publishLanguage($languageCode);
}
elseif ($bookSlug) {
......@@ -492,8 +491,7 @@ class Publisher {
* @return bool TRUE if book was published, FALSE if there were errors
*/
private function publishVersion($versionDescriptor) {
$success =
$this->initializeVersion($versionDescriptor) &&
$success = $this->initializeVersion($versionDescriptor) &&
$this->initializeLocations() &&
$this->initializeRepo() &&
$this->gitCheckout() &&
......@@ -562,4 +560,4 @@ class Publisher {
$this->messages = array();
}
}
\ No newline at end of file
}
......@@ -2,12 +2,6 @@
namespace AppBundle\Utils;
/**
* Description of StringTools
*
* @author sean
*/
class StringTools {
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment