Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Documentation
Docs Publisher
Commits
37863755
Commit
37863755
authored
Feb 28, 2017
by
Sean Madsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format code to pass civilint
parent
af957011
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
758 additions
and
754 deletions
+758
-754
app/AppCache.php
app/AppCache.php
+2
-2
app/AppKernel.php
app/AppKernel.php
+47
-55
app/autoload.php
app/autoload.php
+1
-1
src/AppBundle/AppBundle.php
src/AppBundle/AppBundle.php
+1
-2
src/AppBundle/Command/DocsListCommand.php
src/AppBundle/Command/DocsListCommand.php
+13
-17
src/AppBundle/Command/DocsPublishCommand.php
src/AppBundle/Command/DocsPublishCommand.php
+43
-34
src/AppBundle/Command/DocsServeCommand.php
src/AppBundle/Command/DocsServeCommand.php
+83
-73
src/AppBundle/Controller/DefaultController.php
src/AppBundle/Controller/DefaultController.php
+3
-3
src/AppBundle/Controller/PublishController.php
src/AppBundle/Controller/PublishController.php
+57
-62
src/AppBundle/Controller/ReadController.php
src/AppBundle/Controller/ReadController.php
+54
-49
src/AppBundle/Tests/Controller/NotifyControllerTest.php
src/AppBundle/Tests/Controller/NotifyControllerTest.php
+6
-7
src/AppBundle/Utils/BookLoader.php
src/AppBundle/Utils/BookLoader.php
+194
-197
src/AppBundle/Utils/GitHubHookProcessor.php
src/AppBundle/Utils/GitHubHookProcessor.php
+89
-86
src/AppBundle/Utils/Publisher.php
src/AppBundle/Utils/Publisher.php
+165
-166
No files found.
app/AppCache.php
View file @
37863755
...
...
@@ -2,6 +2,6 @@
use
Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache
;
class
AppCache
extends
HttpCache
{
class
AppCache
extends
HttpCache
{
}
app/AppKernel.php
View file @
37863755
...
...
@@ -3,68 +3,60 @@
use
Symfony\Component\HttpKernel\Kernel
;
use
Symfony\Component\Config\Loader\LoaderInterface
;
class
AppKernel
extends
Kernel
{
public
function
registerBundles
()
{
$bundles
=
[
new
Symfony\Bundle\FrameworkBundle\FrameworkBundle
(),
new
Symfony\Bundle\SecurityBundle\SecurityBundle
(),
new
Symfony\Bundle\TwigBundle\TwigBundle
(),
new
Symfony\Bundle\MonologBundle\MonologBundle
(),
new
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle
(),
new
Doctrine\Bundle\DoctrineBundle\DoctrineBundle
(),
new
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle
(),
new
AppBundle\AppBundle
(),
];
class
AppKernel
extends
Kernel
{
public
function
registerBundles
()
{
$bundles
=
[
new
Symfony\Bundle\FrameworkBundle\FrameworkBundle
(),
new
Symfony\Bundle\SecurityBundle\SecurityBundle
(),
new
Symfony\Bundle\TwigBundle\TwigBundle
(),
new
Symfony\Bundle\MonologBundle\MonologBundle
(),
new
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle
(),
new
Doctrine\Bundle\DoctrineBundle\DoctrineBundle
(),
new
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle
(),
new
AppBundle\AppBundle
(),
];
if
(
in_array
(
$this
->
getEnvironment
(),
[
'dev'
,
'test'
],
TRUE
))
{
$bundles
[]
=
new
Symfony\Bundle\DebugBundle\DebugBundle
();
$bundles
[]
=
new
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle
();
$bundles
[]
=
new
Sensio\Bundle\DistributionBundle\SensioDistributionBundle
();
$bundles
[]
=
new
Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle
();
}
if
(
in_array
(
$this
->
getEnvironment
(),
[
'dev'
,
'test'
],
true
))
{
$bundles
[]
=
new
Symfony\Bundle\DebugBundle\DebugBundle
();
$bundles
[]
=
new
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle
();
$bundles
[]
=
new
Sensio\Bundle\DistributionBundle\SensioDistributionBundle
();
$bundles
[]
=
new
Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle
();
}
return
$bundles
;
}
return
$bundles
;
}
public
function
getRootDir
()
{
return
__DIR__
;
}
public
function
getRootDir
()
{
return
__DIR__
;
}
public
function
getCacheDir
()
{
return
dirname
(
__DIR__
)
.
'/var/cache/'
.
$this
->
getEnvironment
();
}
public
function
getCacheDir
()
{
return
dirname
(
__DIR__
)
.
'/var/cache/'
.
$this
->
getEnvironment
();
}
public
function
getLogDir
()
{
return
dirname
(
__DIR__
)
.
'/var/logs'
;
}
public
function
getLogDir
()
{
return
dirname
(
__DIR__
)
.
'/var/logs'
;
}
public
function
registerContainerConfiguration
(
LoaderInterface
$loader
)
{
$loader
->
load
(
$this
->
getRootDir
()
.
'/config/config_'
.
$this
->
getEnvironment
()
.
'.yml'
);
}
public
function
registerContainerConfiguration
(
LoaderInterface
$loader
)
{
$loader
->
load
(
$this
->
getRootDir
()
.
'/config/config_'
.
$this
->
getEnvironment
()
.
'.yml'
);
protected
function
buildContainer
()
{
$container
=
parent
::
buildContainer
();
if
(
$container
->
hasParameter
(
'mkdocs_path'
))
{
$_ENV
[
'PATH'
]
=
$container
->
getParameter
(
'mkdocs_path'
)
.
PATH_SEPARATOR
.
getenv
(
'PATH'
);
putenv
(
"PATH="
.
$_ENV
[
'PATH'
]);
}
protected
function
buildContainer
()
{
$container
=
parent
::
buildContainer
();
if
(
$container
->
hasParameter
(
'mkdocs_path'
))
{
$_ENV
[
'PATH'
]
=
$container
->
getParameter
(
'mkdocs_path'
)
.
PATH_SEPARATOR
.
getenv
(
'PATH'
);
putenv
(
"PATH="
.
$_ENV
[
'PATH'
]);
}
if
(
!
$container
->
hasParameter
(
'publisher_repos_dir'
))
{
// This isn't really a good place to put it because it gets deleted
// whenever you clear the cache.
$container
->
setParameter
(
'publisher_repos_dir'
,
$container
->
getParameter
(
'kernel.cache_dir'
)
.
'/repos'
);
}
return
$container
;
if
(
!
$container
->
hasParameter
(
'publisher_repos_dir'
))
{
// This isn't really a good place to put it because it gets deleted
// whenever you clear the cache.
$container
->
setParameter
(
'publisher_repos_dir'
,
$container
->
getParameter
(
'kernel.cache_dir'
)
.
'/repos'
);
}
return
$container
;
}
}
app/autoload.php
View file @
37863755
...
...
@@ -6,7 +6,7 @@ use Composer\Autoload\ClassLoader;
/**
* @var ClassLoader $loader
*/
$loader
=
require
__DIR__
.
'/../vendor/autoload.php'
;
$loader
=
require
__DIR__
.
'/../vendor/autoload.php'
;
AnnotationRegistry
::
registerLoader
([
$loader
,
'loadClass'
]);
...
...
src/AppBundle/AppBundle.php
View file @
37863755
...
...
@@ -4,6 +4,5 @@ namespace AppBundle;
use
Symfony\Component\HttpKernel\Bundle\Bundle
;
class
AppBundle
extends
Bundle
{
class
AppBundle
extends
Bundle
{
}
src/AppBundle/Command/DocsListCommand.php
View file @
37863755
...
...
@@ -9,23 +9,19 @@ use Symfony\Component\Console\Input\InputInterface;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Output\OutputInterface
;
class
DocsListCommand
extends
ContainerAwareCommand
{
protected
function
configure
()
{
$this
->
setName
(
'docs:list'
)
->
setDescription
(
'List available books'
);
}
class
DocsListCommand
extends
ContainerAwareCommand
{
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
/** @var \AppBundle\BookLoader $books */
$books
=
$this
->
getContainer
()
->
get
(
'book.loader'
);
$table
=
new
Table
(
$output
);
$table
->
setHeaders
(
array
(
'book'
,
'lang'
,
'repo'
,
'branch'
));
$table
->
addRows
(
$books
->
findAsList
());
$table
->
render
();
}
protected
function
configure
()
{
$this
->
setName
(
'docs:list'
)
->
setDescription
(
'List available books'
);
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
/** @var \AppBundle\BookLoader $books */
$books
=
$this
->
getContainer
()
->
get
(
'book.loader'
);
$table
=
new
Table
(
$output
);
$table
->
setHeaders
(
array
(
'book'
,
'lang'
,
'repo'
,
'branch'
));
$table
->
addRows
(
$books
->
findAsList
());
$table
->
render
();
}
}
src/AppBundle/Command/DocsPublishCommand.php
View file @
37863755
...
...
@@ -8,47 +8,56 @@ use Symfony\Component\Console\Input\InputInterface;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Output\OutputInterface
;
class
DocsPublishCommand
extends
ContainerAwareCommand
{
protected
function
configure
()
{
$this
->
setName
(
'docs:publish'
)
->
setDescription
(
'...'
)
->
addArgument
(
'paths'
,
InputArgument
::
IS_ARRAY
,
'One or more book expressions ("book/lang/branch"). (Default: all)'
);
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
/** @var \AppBundle\BookLoader $books */
$books
=
$this
->
getContainer
()
->
get
(
'book.loader'
);
/** @var \AppBundle\Utils\Publisher $publisher */
$publisher
=
$this
->
getContainer
()
->
get
(
'publisher'
);
class
DocsPublishCommand
extends
ContainerAwareCommand
{
$rows
=
$books
->
findAsList
();
protected
function
configure
()
{
$this
->
setName
(
'docs:publish'
)
->
setDescription
(
'...'
)
->
addArgument
(
'paths'
,
InputArgument
::
IS_ARRAY
,
'One or more book expressions ("book/lang/branch"). (Default: all)'
);
}
if
(
empty
(
$rows
)
)
{
$output
->
writeln
(
"<error>No books found</error>"
);
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
/** @var \AppBundle\BookLoader $books */
$books
=
$this
->
getContainer
()
->
get
(
'book.loader'
);
$rowKeys
=
$input
->
getArgument
(
'paths'
)
?
$input
->
getArgument
(
'paths'
)
:
array_keys
(
$rows
);
/** @var \AppBundle\Utils\Publisher $publisher */
$publisher
=
$this
->
getContainer
()
->
get
(
'publisher'
);
foreach
(
$rowKeys
as
$rowKey
)
{
$row
=
$rows
[
$rowKey
];
$output
->
writeln
(
""
);
$output
->
writeln
(
sprintf
(
"Publish [%s/%s/%s] (from %s)"
,
$row
[
'book'
],
$row
[
'lang'
],
$row
[
'branch'
],
$row
[
'repo'
]));
$rows
=
$books
->
findAsList
();
$publisher
->
publish
(
$row
[
'book'
],
$row
[
'lang'
],
$row
[
'branch'
]);
if
(
empty
(
$rows
))
{
$output
->
writeln
(
"<error>No books found</error>"
);
}
foreach
(
$publisher
->
getMessages
()
as
$message
)
{
$output
->
writeln
(
$message
[
'label'
]
.
': '
.
$message
[
'content'
]);
}
$publisher
->
clearMessages
();
if
(
$input
->
getArgument
(
'paths'
))
{
$rowKeys
=
$input
->
getArgument
(
'paths'
);
}
else
{
$rowKeys
=
array_keys
(
$rows
);
}
}
foreach
(
$rowKeys
as
$rowKey
)
{
$row
=
$rows
[
$rowKey
];
$output
->
writeln
(
""
);
$output
->
writeln
(
sprintf
(
"Publish [%s/%s/%s] (from %s)"
,
$row
[
'book'
],
$row
[
'lang'
],
$row
[
'branch'
],
$row
[
'repo'
])
);
$publisher
->
publish
(
$row
[
'book'
],
$row
[
'lang'
],
$row
[
'branch'
]);
foreach
(
$publisher
->
getMessages
()
as
$message
)
{
$output
->
writeln
(
$message
[
'label'
]
.
': '
.
$message
[
'content'
]);
}
$publisher
->
clearMessages
();
}
}
}
src/AppBundle/Command/DocsServeCommand.php
View file @
37863755
...
...
@@ -16,83 +16,93 @@ use Symfony\Component\Console\Output\OutputInterface;
* This is a dumb wrapper around `mkdocs serve`. It basically just cd's into the
* appropriate folder and then passes-through the args.
*/
class
DocsServeCommand
extends
ContainerAwareCommand
{
protected
function
configure
()
{
$this
->
setName
(
'docs:serve'
)
->
setDescription
(
'Run the builtin docs development server'
)
->
addOption
(
'dev-addr'
,
'a'
,
InputOption
::
VALUE_OPTIONAL
,
'IP address and port to serve documentation'
)
->
addOption
(
'strict'
,
's'
,
InputOption
::
VALUE_NONE
,
'Enable strict mode. This will cause MkDocs to abort the build on any warnings.'
)
->
addOption
(
'theme'
,
't'
,
InputOption
::
VALUE_OPTIONAL
,
'The theme to use when building your documentation [cosmo|cyborg|readthedocs|yeti|journal|bootstrap|readable|united|simplex|flatly|spacelab|amelia|cerulean|slate|mkdocs'
)
->
addOption
(
'livereload'
,
null
,
InputOption
::
VALUE_NONE
,
'Enable the live reloading in the development server.'
)
->
addOption
(
'no-livereload'
,
null
,
InputOption
::
VALUE_NONE
,
'Enable the live reloading in the development server.'
)
->
addOption
(
'quiet'
,
'q'
,
InputOption
::
VALUE_NONE
,
'Silence warnings'
)
// ->addOption('verbose', 'v', InputOption::VALUE_NONE, 'Enable verbose output')
->
addArgument
(
'[book/lang/[branch]]'
,
InputArgument
::
REQUIRED
,
'A book expression (e.g. "dev/en/master" or "user/fr/4.6"). The [book] and [lang] are mandatory. If [branch] is specified, it will be checked out.'
)
;
class
DocsServeCommand
extends
ContainerAwareCommand
{
protected
function
configure
()
{
$this
->
setName
(
'docs:serve'
);
$this
->
setDescription
(
'Run the builtin docs development server'
);
$this
->
addOption
(
'dev-addr'
,
'a'
,
InputOption
::
VALUE_OPTIONAL
,
'IP address and port to serve documentation'
);
$this
->
addOption
(
'strict'
,
's'
,
InputOption
::
VALUE_NONE
,
'Enable strict mode. This will cause MkDocs to abort the build on any'
.
'warnings.'
);
$this
->
addOption
(
'theme'
,
't'
,
InputOption
::
VALUE_OPTIONAL
,
'The theme to use when building your documentation (e.g. readthedocs)'
);
$this
->
addOption
(
'livereload'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Enable the live reloading in the development server.'
);
$this
->
addOption
(
'no-livereload'
,
NULL
,
InputOption
::
VALUE_NONE
,
'Disable the live reloading in the development server.'
);
$this
->
addOption
(
'quiet'
,
'q'
,
InputOption
::
VALUE_NONE
,
'Silence warnings'
);
$this
->
addArgument
(
'[book/lang/[branch]]'
,
InputArgument
::
REQUIRED
,
'A book expression (e.g. "dev/en/master" or "user/fr/4.6"). '
.
'The [book] and [lang] are mandatory. '
.
'If [branch] is specified, it will be checked out.'
);
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
if
(
preg_match
(
';^(\w+)/(\w+)?$;'
,
$input
->
getArgument
(
'[book/lang/[branch]]'
),
$matches
))
{
$book
=
$matches
[
1
];
$lang
=
$matches
[
2
];
$branch
=
NULL
;
}
elseif
(
preg_match
(
';^(\w+)/(\w+)/(\w+)$;'
,
$input
->
getArgument
(
'[book/lang/[branch]]'
),
$matches
))
{
$book
=
$matches
[
1
];
$lang
=
$matches
[
2
];
$branch
=
$matches
[
3
];
}
else
{
$output
->
writeln
(
"<error>Malformed [book/lang/branch]</error>"
);
return
1
;
}
$repoDir
=
$this
->
getContainer
()
->
getParameter
(
'publisher_repos_dir'
)
.
"/
$book
/
$lang
"
;
if
(
file_exists
(
$repoDir
))
{
$output
->
writeln
(
"<info>Found git repo for
$book
/
$lang
in
\"
$repoDir
\"
</info>"
);
}
else
{
$output
->
writeln
(
"<error>Failed to find git repo for
$book
/
$lang
in
\"
$repoDir
\"
.</error>"
);
$output
->
writeln
(
"<error>Perhaps you should run
\"
docs:publish
\"
first?</error>"
);
return
1
;
}
$command
=
'mkdocs serve'
;
foreach
(
array
(
'dev-addr'
,
'theme'
)
as
$option
)
{
if
(
$input
->
getOption
(
$option
))
{
$command
.
=
" --
{
$option
}
"
.
escapeshellarg
(
$input
->
getOption
(
$option
));
}
}
foreach
(
array
(
'strict'
,
'livereload'
,
'no-livereload'
,
'quiet'
)
as
$option
)
{
if
(
$input
->
getOption
(
$option
))
{
$command
.
=
" --
{
$option
}
"
;
}
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
if
(
preg_match
(
';^(\w+)/(\w+)?$;'
,
$input
->
getArgument
(
'[book/lang/[branch]]'
),
$matches
))
{
$book
=
$matches
[
1
];
$lang
=
$matches
[
2
];
$branch
=
NULL
;
}
elseif
(
preg_match
(
';^(\w+)/(\w+)/(\w+)$;'
,
$input
->
getArgument
(
'[book/lang/[branch]]'
),
$matches
))
{
$book
=
$matches
[
1
];
$lang
=
$matches
[
2
];
$branch
=
$matches
[
3
];
}
else
{
$output
->
writeln
(
"<error>Malformed [book/lang/branch]</error>"
);
return
1
;
}
$repoDir
=
$this
->
getContainer
()
->
getParameter
(
'publisher_repos_dir'
)
.
"/
$book
/
$lang
"
;
if
(
file_exists
(
$repoDir
))
{
$output
->
writeln
(
"<info>Found git repo for
$book
/
$lang
in
\"
$repoDir
\"
</info>"
);
}
else
{
$output
->
writeln
(
"<error>Failed to find git repo for
$book
/
$lang
in
\"
$repoDir
\"
.</error>"
);
$output
->
writeln
(
"<error>Perhaps you should run
\"
docs:publish
\"
first?</error>"
);
return
1
;
}
$command
=
'mkdocs serve'
;
foreach
(
array
(
'dev-addr'
,
'theme'
)
as
$option
)
{
if
(
$input
->
getOption
(
$option
))
{
$command
.
=
" --
{
$option
}
"
.
escapeshellarg
(
$input
->
getOption
(
$option
));
}
}
foreach
(
array
(
'strict'
,
'livereload'
,
'no-livereload'
,
'quiet'
)
as
$option
)
{
if
(
$input
->
getOption
(
$option
)
)
{
$command
.
=
" --
{
$option
}
"
;
}
}
if
(
$branch
)
{
$output
->
writeln
(
"<info>Check out branch
\"
$branch
\"
</info>"
);
self
::
passthruOK
(
$repoDir
,
"git checkout
$branch
"
);
}
$output
->
writeln
(
"<info>Launch
\"
$command
\"
</info>"
);
self
::
passthruOK
(
$repoDir
,
$command
);
if
(
$branch
)
{
$output
->
writeln
(
"<info>Check out branch
\"
$branch
\"
</info>"
);
self
::
passthruOK
(
$repoDir
,
"git checkout
$branch
"
);
}
$output
->
writeln
(
"<info>Launch
\"
$command
\"
</info>"
);
self
::
passthruOK
(
$repoDir
,
$command
);
}
protected
function
passthruOK
(
$newcwd
,
$command
)
{
$oldcwd
=
getcwd
();
chdir
(
$newcwd
);
passthru
(
$command
,
$return
);
chdir
(
$oldcwd
);
if
(
$return
)
{
throw
new
\
RuntimeException
(
"Received error from command (
$command
)"
);
}
protected
function
passthruOK
(
$newcwd
,
$command
)
{
$oldcwd
=
getcwd
();
chdir
(
$newcwd
);
passthru
(
$command
,
$return
);
chdir
(
$oldcwd
);
if
(
$return
)
{
throw
new
\
RuntimeException
(
"Received error from command (
$command
)"
);
}
}
}
src/AppBundle/Controller/DefaultController.php
View file @
37863755
<?php
//
//
// namespace AppBundle\Controller;
//
//
// use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
// use Symfony\Bundle\FrameworkBundle\Controller\Controller;
// use Symfony\Component\HttpFoundation\Request;
//
//
// class DefaultController extends Controller
// {
// /**
...
...
src/AppBundle/Controller/PublishController.php
View file @
37863755
...
...
@@ -10,75 +10,70 @@ use Symfony\Component\Finder\Finder;
use
Symfony\Component\Yaml\Parser
;
//@TODO Make the errors that will occur if the slugs don't pass the regexp more obvious to the user
/**
* @TODO Make the errors that will occur if the slugs don't pass the regexp
* more obvious to the user
*/
class
PublishController
extends
Controller
{
class
PublishController
extends
Controller
{
/**
* @Route("/admin/publish")
*/
public
function
PublishInstructionsAction
()
{
return
$this
->
render
(
'AppBundle:Publish:publish.html.twig'
);
}
/**
* @Route("/admin/publish/{book}/{lang}/{branch}", requirements={
* "lang":"[[:alpha:]]{2}",
* "book":"[[:alpha:]\-]+",
* "branch":"[[:alnum:]\-\.]+",
* })
*/
public
function
PublishAction
(
Request
$request
,
$lang
,
$book
,
$branch
)
{
$publisher
=
$this
->
get
(
'publisher'
);
$publisher
->
publish
(
$book
,
$lang
,
$branch
);
$content
[
'messages'
]
=
$publisher
->
getMessages
();
return
$this
->
render
(
'AppBundle:Publish:publish.html.twig'
,
$content
);
}
/**
* @Route("/admin/listen")
*/
public
function
ListenAction
(
Request
$request
)
{
$body
=
$request
->
getContent
();
$event
=
$request
->
headers
->
get
(
'X-GitHub-Event'
);
$payload
=
json_decode
(
$body
);
/**
* @Route("/admin/publish")
*/
public
function
PublishInstructionsAction
()
{
return
$this
->
render
(
'AppBundle:Publish:publish.html.twig'
);
}
/**
* @Route("/admin/publish/{book}/{lang}/{branch}", requirements={
* "lang":"[[:alpha:]]{2}",
* "book":"[[:alpha:]\-]+",
* "branch":"[[:alnum:]\-\.]+",
* })
*/
public
function
PublishAction
(
Request
$request
,
$lang
,
$book
,
$branch
)
{
$publisher
=
$this
->
get
(
'publisher'
);
$publisher
->
publish
(
$book
,
$lang
,
$branch
);
$content
[
'messages'
]
=
$publisher
->
getMessages
();
return
$this
->
render
(
'AppBundle:Publish:publish.html.twig'
,
$content
);
}
/**
* @Route("/admin/listen")
*/
public
function
ListenAction
(
Request
$request
)
{
$body
=
$request
->
getContent
();
$event
=
$request
->
headers
->
get
(
'X-GitHub-Event'
);
$payload
=
json_decode
(
$body
);
$books
=
$this
->
get
(
'book.loader'
)
->
find
();
$books
=
$this
->
get
(
'book.loader'
)
->
find
();
$processor
=
$this
->
get
(
'github.hook.processor'
);
$processor
->
process
(
$event
,
$payload
);
if
(
!
$processor
->
published
){
return
new
Response
(
'Something went wrong during publishing.'
,
200
);
// @TODO Add more appropriate error code
}
$messages
=
$processor
->
getMessages
();
$subject
=
$processor
->
getSubject
();
$recipients
=
$processor
->
getRecipients
();
$mail
=
\
Swift_Message
::
newInstance
()
$processor
=
$this
->
get
(
'github.hook.processor'
);
$processor
->
process
(
$event
,
$payload
);
if
(
!
$processor
->
published
)
{
return
new
Response
(
'Something went wrong during publishing.'
,
200
);
// @TODO Add more appropriate error code
}
$messages
=
$processor
->
getMessages
();
$subject
=
$processor
->
getSubject
();
$recipients
=
$processor
->
getRecipients
();
$mail
=
\
Swift_Message
::
newInstance
()
->
setSubject
(
"[CiviCRM docs]
$subject
"
)
->
setFrom
(
'no-reply@civicrm.org'
)
->
setTo
(
$recipients
)
->
setBody
(
$this
->
renderView
(
'Emails/notify.html.twig'
,
array
(
'branch'
=>
$processor
->
publisher
->
branch
,
'book'
=>
$processor
->
publisher
->
b
ook
,
'lang'
=>
$processor
->
publisher
->
lang
,
'messages'
=>
$processor
->
publisher
->
getMessages
()
)
)
,
'text/html'
$this
->
renderView
(
'Emails/notify.html.twig'
,
array
(
'branch'
=>
$processor
->
publisher
->
b
ranch
,
'book'
=>
$processor
->
publisher
->
book
,
'lang'
=>
$processor
->
publisher
->
lang
,
'messages'
=>
$processor
->
publisher
->
getMessages
(),
)
),
'text/html'
);
$this
->
get
(
'mailer'
)
->
send
(
$mail
);
return
new
Response
(
$subject
,
200
);
$this
->
get
(
'mailer'
)
->
send
(
$mail
);
return
new
Response
(
$subject
,
200
);
}
}
}
src/AppBundle/Controller/ReadController.php
View file @
37863755
...
...
@@ -8,55 +8,60 @@ use Symfony\Component\Yaml\Parser;
use
Symfony\Component\Finder\Finder
;
use
Symfony\Component\Intl\ResourceBundle\RegionBundle
;
class
ReadController
extends
Controller
{
/**
* @Route("/{path}")
*/
public
function
RedirectAction
(
$path
)
{