File tree Expand file tree Collapse file tree 9 files changed +227
-0
lines changed Expand file tree Collapse file tree 9 files changed +227
-0
lines changed Original file line number Diff line number Diff line change
1
+ .idea /
2
+ vendor /
3
+ composer.phar
4
+ composer.lock
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Author: Łukasz Barulski
4
+ * Date: 23.04.14 16:07
5
+ */
6
+
7
+ namespace GateKeeperBundle \Access ;
8
+
9
+ use GateKeeper \Access \AbstractAccess ;
10
+
11
+ class Allow extends AbstractAccess
12
+ {
13
+ /**
14
+ * @return string
15
+ */
16
+ public function getName ()
17
+ {
18
+ return 'allow-all ' ;
19
+ }
20
+
21
+ /**
22
+ * @return bool
23
+ */
24
+ public function hasAccess ()
25
+ {
26
+ return true ;
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Author: Łukasz Barulski
4
+ * Date: 23.04.14 16:07
5
+ */
6
+
7
+ namespace GateKeeperBundle \Access ;
8
+
9
+ use GateKeeper \Access \AbstractAccess ;
10
+
11
+ class Deny extends AbstractAccess
12
+ {
13
+ /**
14
+ * @return string
15
+ */
16
+ public function getName ()
17
+ {
18
+ return 'deny-all ' ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Author: Łukasz Barulski
4
+ * Date: 23.04.14 16:30
5
+ */
6
+
7
+ namespace GateKeeperBundle \DependencyInjection \Compiler ;
8
+
9
+
10
+ use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
11
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
12
+ use Symfony \Component \DependencyInjection \Reference ;
13
+
14
+ class GateKeeperCompilerPass implements CompilerPassInterface
15
+ {
16
+ /**
17
+ * You can modify the container here before it is dumped to PHP code.
18
+ *
19
+ * @param ContainerBuilder $container
20
+ *
21
+ * @api
22
+ */
23
+ public function process (ContainerBuilder $ container )
24
+ {
25
+ if (!$ container ->hasDefinition ('gatekeeper ' ))
26
+ {
27
+ return ;
28
+ }
29
+
30
+ $ definition = $ container ->getDefinition ('gatekeeper ' );
31
+ $ taggedServices = $ container ->findTaggedServiceIds ('gatekeeper.access ' );
32
+
33
+ foreach ($ taggedServices as $ id => $ attributes )
34
+ {
35
+ $ definition ->addMethodCall ('addAccess ' , [
36
+ new Reference ($ id )
37
+ ]);
38
+ }
39
+ }
40
+
41
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace ZL \GateKeeperBundle \DependencyInjection ;
4
+
5
+ use Symfony \Component \Config \Definition \Builder \TreeBuilder ;
6
+ use Symfony \Component \Config \Definition \ConfigurationInterface ;
7
+
8
+ /**
9
+ * This is the class that validates and merges configuration from your app/config files
10
+ *
11
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12
+ */
13
+ class Configuration implements ConfigurationInterface
14
+ {
15
+ /**
16
+ * {@inheritDoc}
17
+ */
18
+ public function getConfigTreeBuilder ()
19
+ {
20
+ $ treeBuilder = new TreeBuilder ();
21
+ /** @noinspection PhpUndefinedMethodInspection */
22
+ $ treeBuilder ->root ('gatekeeper ' )
23
+ ->children ()
24
+ ->scalarNode ('repository_service ' )
25
+ ->defaultValue ('gatekeeper.repository.dummy ' )
26
+ ->isRequired ()
27
+ ->end ()
28
+ ->end ();
29
+
30
+ return $ treeBuilder ;
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace GateKeeperBundle \DependencyInjection ;
4
+
5
+ use Symfony \Bundle \FrameworkBundle \DependencyInjection \Configuration ;
6
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
7
+ use Symfony \Component \Config \FileLocator ;
8
+ use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
9
+ use Symfony \Component \DependencyInjection \Loader ;
10
+
11
+ /**
12
+ * This is the class that loads and manages your bundle configuration
13
+ *
14
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
15
+ */
16
+ class GateKeeperExtension extends Extension
17
+ {
18
+ /**
19
+ * {@inheritDoc}
20
+ */
21
+ public function load (array $ configs , ContainerBuilder $ container )
22
+ {
23
+ $ configuration = new Configuration ();
24
+ $ config = $ this ->processConfiguration ($ configuration , $ configs );
25
+
26
+ $ container ->setParameter ('gatekeeper.repository.service ' , $ config ['repository_service ' ]);
27
+
28
+ $ loader = new Loader \YamlFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
29
+ $ loader ->load ('services.yml ' );
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace GateKeeperBundle ;
4
+
5
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
6
+ use Symfony \Component \HttpKernel \Bundle \Bundle ;
7
+ use GateKeeperBundle \DependencyInjection \Compiler \GateKeeperCompilerPass ;
8
+
9
+ class GateKeeperBundle extends Bundle
10
+ {
11
+ /**
12
+ * @param ContainerBuilder $container
13
+ */
14
+ public function build (ContainerBuilder $ container )
15
+ {
16
+ $ container ->addCompilerPass (new GateKeeperCompilerPass ());
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ parameters :
2
+ gatekeeper.class : GateKeeper\Keeper
3
+ gatekeeper.access.allow.class : GateKeeperBundle\Access\Allow
4
+ gatekeeper.access.deny.class : GateKeeperBundle\Access\Deny
5
+
6
+ services :
7
+ gatekeeper :
8
+ class : %gatekeeper.class%
9
+ arguments : [@gatekeeper.repository]
10
+
11
+ gatekeeper.repository.dummy :
12
+ class : GateKeeper\Repository\DummyRepository
13
+
14
+ gatekeeper.repository :
15
+ alias : %gatekeeper.repository.service%
16
+
17
+ gatekeeper.access.allow :
18
+ public : false
19
+ class : %gatekeeper.access.allow.class%
20
+ tags :
21
+ - { name: gatekeeper.access }
22
+
23
+ gatekeeper.access.deny :
24
+ public : false
25
+ class : %gatekeeper.access.deny.class%
26
+ tags :
27
+ - { name: gatekeeper.access }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " docplanner/gatekeeper-bundle" ,
3
+ "description" : " GateKeeper Bundle" ,
4
+ "minimum-stability" : " stable" ,
5
+ "license" : " proprietary" ,
6
+ "authors" : [
7
+ {
8
+ "name" : " Łukasz Barulski" ,
9
+
10
+ },
11
+ {
12
+ "name" : " Bartłomiej Kuleszewicz" ,
13
+
14
+ }
15
+ ],
16
+ "require" : {
17
+ "php" : " >=5.3.3" ,
18
+ "symfony/symfony" : " >=2.3" ,
19
+ "docplanner/gatekeeper" : " dev-master"
20
+ },
21
+ "autoload" : {
22
+ "psr-4" : {
23
+ "GateKeeperBundle\\ " : " "
24
+ }
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments