@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | class StingerSoftPlatformBundle extends Bundle { |
17 | 17 | |
18 | - public static function getRequiredBundle($env) { |
|
18 | + public static function getRequiredBundle($env){ |
|
19 | 19 | $bundles = []; |
20 | 20 | $bundles['FrameworkBundle'] = '\Symfony\Bundle\FrameworkBundle\FrameworkBundle'; |
21 | 21 | $bundles['SecurityBundle'] = '\Symfony\Bundle\SecurityBundle\SecurityBundle'; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if(in_array($env, [ |
29 | 29 | 'dev', |
30 | 30 | 'test' |
31 | - ], true)) { |
|
31 | + ], true)){ |
|
32 | 32 | $bundles['DebugBundle'] = '\Symfony\Bundle\DebugBundle\DebugBundle'; |
33 | 33 | $bundles['WebProfilerBundle'] = '\Symfony\Bundle\WebProfilerBundle\WebProfilerBundle'; |
34 | 34 | $bundles['SensioDistributionBundle'] = '\Sensio\Bundle\DistributionBundle\SensioDistributionBundle'; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | class StingerSoftPlatformBundle extends Bundle { |
17 | 17 | |
18 | - public static function getRequiredBundle($env) { |
|
18 | + public static function getRequiredBundle($env){ |
|
19 | 19 | $bundles = []; |
20 | 20 | $bundles['FrameworkBundle'] = '\Symfony\Bundle\FrameworkBundle\FrameworkBundle'; |
21 | 21 | $bundles['SecurityBundle'] = '\Symfony\Bundle\SecurityBundle\SecurityBundle'; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if(in_array($env, [ |
29 | 29 | 'dev', |
30 | 30 | 'test' |
31 | - ], true)) { |
|
31 | + ], true)){ |
|
32 | 32 | $bundles['DebugBundle'] = '\Symfony\Bundle\DebugBundle\DebugBundle'; |
33 | 33 | $bundles['WebProfilerBundle'] = '\Symfony\Bundle\WebProfilerBundle\WebProfilerBundle'; |
34 | 34 | $bundles['SensioDistributionBundle'] = '\Sensio\Bundle\DistributionBundle\SensioDistributionBundle'; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | const SERVICE_ID = 'stinger_soft_platform.doctrine.table_prefix'; |
28 | 28 | |
29 | - public function getSubscribedEvents() { |
|
29 | + public function getSubscribedEvents(){ |
|
30 | 30 | return array( |
31 | 31 | 'loadClassMetadata' |
32 | 32 | ); |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param LoadClassMetadataEventArgs $args |
38 | 38 | */ |
39 | - public function loadClassMetadata(LoadClassMetadataEventArgs $args) { |
|
39 | + public function loadClassMetadata(LoadClassMetadataEventArgs $args){ |
|
40 | 40 | $classMetadata = $args->getClassMetadata(); |
41 | 41 | |
42 | 42 | // Do not re-apply the prefix in an inheritance hierarchy. |
43 | - if($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()) { |
|
43 | + if($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()){ |
|
44 | 44 | return; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $prefix = $classMetadata->namespace; |
48 | - if(!preg_match('/([^\\\\]+)Bundle/i', $classMetadata->namespace, $prefix)) { |
|
48 | + if(!preg_match('/([^\\\\]+)Bundle/i', $classMetadata->namespace, $prefix)){ |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | // Can this happen?? |
52 | 52 | // if(count($prefix)!=2){ |
53 | 53 | // return; |
54 | 54 | // } |
55 | - $prefix = strtolower($prefix[1]) . '_'; |
|
55 | + $prefix = strtolower($prefix[1]).'_'; |
|
56 | 56 | |
57 | 57 | $classMetadata->setPrimaryTable(array( |
58 | - 'name' => $prefix . $classMetadata->getTableName() |
|
58 | + 'name' => $prefix.$classMetadata->getTableName() |
|
59 | 59 | )); |
60 | 60 | |
61 | - foreach($classMetadata->getAssociationMappings() as $fieldName => $mapping) { |
|
62 | - if($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) { |
|
63 | - if(isset($classMetadata->associationMappings[$fieldName]['joinTable']['prefixed']) && $classMetadata->associationMappings[$fieldName]['joinTable']['prefixed']) { |
|
61 | + foreach($classMetadata->getAssociationMappings() as $fieldName => $mapping){ |
|
62 | + if($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])){ |
|
63 | + if(isset($classMetadata->associationMappings[$fieldName]['joinTable']['prefixed']) && $classMetadata->associationMappings[$fieldName]['joinTable']['prefixed']){ |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | |
67 | 67 | $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; |
68 | - $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $prefix . $mappedTableName; |
|
68 | + $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $prefix.$mappedTableName; |
|
69 | 69 | $classMetadata->associationMappings[$fieldName]['joinTable']['prefixed'] = true; |
70 | 70 | } |
71 | 71 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | const SERVICE_ID = 'stinger_soft_platform.doctrine.table_prefix'; |
28 | 28 | |
29 | - public function getSubscribedEvents() { |
|
29 | + public function getSubscribedEvents(){ |
|
30 | 30 | return array( |
31 | 31 | 'loadClassMetadata' |
32 | 32 | ); |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param LoadClassMetadataEventArgs $args |
38 | 38 | */ |
39 | - public function loadClassMetadata(LoadClassMetadataEventArgs $args) { |
|
39 | + public function loadClassMetadata(LoadClassMetadataEventArgs $args){ |
|
40 | 40 | $classMetadata = $args->getClassMetadata(); |
41 | 41 | |
42 | 42 | // Do not re-apply the prefix in an inheritance hierarchy. |
43 | - if($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()) { |
|
43 | + if($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()){ |
|
44 | 44 | return; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $prefix = $classMetadata->namespace; |
48 | - if(!preg_match('/([^\\\\]+)Bundle/i', $classMetadata->namespace, $prefix)) { |
|
48 | + if(!preg_match('/([^\\\\]+)Bundle/i', $classMetadata->namespace, $prefix)){ |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | // Can this happen?? |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | 'name' => $prefix . $classMetadata->getTableName() |
59 | 59 | )); |
60 | 60 | |
61 | - foreach($classMetadata->getAssociationMappings() as $fieldName => $mapping) { |
|
62 | - if($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) { |
|
63 | - if(isset($classMetadata->associationMappings[$fieldName]['joinTable']['prefixed']) && $classMetadata->associationMappings[$fieldName]['joinTable']['prefixed']) { |
|
61 | + foreach($classMetadata->getAssociationMappings() as $fieldName => $mapping){ |
|
62 | + if($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])){ |
|
63 | + if(isset($classMetadata->associationMappings[$fieldName]['joinTable']['prefixed']) && $classMetadata->associationMappings[$fieldName]['joinTable']['prefixed']){ |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | * $name |
39 | 39 | * @param array $roles |
40 | 40 | */ |
41 | - public function __construct($name, $roles = array()) { |
|
41 | + public function __construct($name, $roles = array()){ |
|
42 | 42 | $this->users = new ArrayCollection(); |
43 | 43 | parent::__construct($name, $roles); |
44 | 44 | } |
45 | 45 | |
46 | - public function addRoles(array $roles) { |
|
47 | - foreach($roles as $role) { |
|
46 | + public function addRoles(array $roles){ |
|
47 | + foreach($roles as $role){ |
|
48 | 48 | $this->addRole($role); |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - public function removeRoles(array $roles) { |
|
53 | - foreach($roles as $role) { |
|
52 | + public function removeRoles(array $roles){ |
|
53 | + foreach($roles as $role){ |
|
54 | 54 | $this->removeRole($role); |
55 | 55 | } |
56 | 56 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return Group |
64 | 64 | */ |
65 | - public function addUser(User $user) { |
|
65 | + public function addUser(User $user){ |
|
66 | 66 | $this->users[] = $user; |
67 | 67 | |
68 | 68 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param User $user |
75 | 75 | */ |
76 | - public function removeUser(User $user) { |
|
76 | + public function removeUser(User $user){ |
|
77 | 77 | $this->users->removeElement($user); |
78 | 78 | } |
79 | 79 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return \Doctrine\Common\Collections\Collection |
84 | 84 | */ |
85 | - public function getUsers() { |
|
85 | + public function getUsers(){ |
|
86 | 86 | return $this->users; |
87 | 87 | } |
88 | 88 | |
89 | - public function getUsersCount() { |
|
89 | + public function getUsersCount(){ |
|
90 | 90 | return $this->users->count(); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | * $name |
39 | 39 | * @param array $roles |
40 | 40 | */ |
41 | - public function __construct($name, $roles = array()) { |
|
41 | + public function __construct($name, $roles = array()){ |
|
42 | 42 | $this->users = new ArrayCollection(); |
43 | 43 | parent::__construct($name, $roles); |
44 | 44 | } |
45 | 45 | |
46 | - public function addRoles(array $roles) { |
|
47 | - foreach($roles as $role) { |
|
46 | + public function addRoles(array $roles){ |
|
47 | + foreach($roles as $role){ |
|
48 | 48 | $this->addRole($role); |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - public function removeRoles(array $roles) { |
|
53 | - foreach($roles as $role) { |
|
52 | + public function removeRoles(array $roles){ |
|
53 | + foreach($roles as $role){ |
|
54 | 54 | $this->removeRole($role); |
55 | 55 | } |
56 | 56 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return Group |
64 | 64 | */ |
65 | - public function addUser(User $user) { |
|
65 | + public function addUser(User $user){ |
|
66 | 66 | $this->users[] = $user; |
67 | 67 | |
68 | 68 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param User $user |
75 | 75 | */ |
76 | - public function removeUser(User $user) { |
|
76 | + public function removeUser(User $user){ |
|
77 | 77 | $this->users->removeElement($user); |
78 | 78 | } |
79 | 79 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return \Doctrine\Common\Collections\Collection |
84 | 84 | */ |
85 | - public function getUsers() { |
|
85 | + public function getUsers(){ |
|
86 | 86 | return $this->users; |
87 | 87 | } |
88 | 88 | |
89 | - public function getUsersCount() { |
|
89 | + public function getUsersCount(){ |
|
90 | 90 | return $this->users->count(); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -25,13 +25,13 @@ |
||
25 | 25 | */ |
26 | 26 | class TestCase extends \PHPUnit_Framework_TestCase { |
27 | 27 | |
28 | - public function createContainer() { |
|
28 | + public function createContainer(){ |
|
29 | 29 | $container = new ContainerBuilder(new ParameterBag(array( |
30 | 30 | 'kernel.debug' => false, |
31 | 31 | // 'kernel.bundles' => array('YamlBundle' => 'Fixtures\Bundles\YamlBundle\YamlBundle'), |
32 | 32 | 'kernel.cache_dir' => sys_get_temp_dir(), |
33 | 33 | 'kernel.environment' => 'test', |
34 | - 'kernel.root_dir' => __DIR__ . '/../../../../' |
|
34 | + 'kernel.root_dir' => __DIR__.'/../../../../' |
|
35 | 35 | ) // src dir |
36 | 36 | )); |
37 | 37 | $extension = new StingerSoftPlatformExtension(); |
@@ -71,21 +71,21 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected $prefixService; |
73 | 73 | |
74 | - public function setUp() { |
|
74 | + public function setUp(){ |
|
75 | 75 | $this->prefixService = $this->createContainer()->get(TablePrefixService::SERVICE_ID); |
76 | 76 | } |
77 | 77 | |
78 | - public function testService() { |
|
78 | + public function testService(){ |
|
79 | 79 | $this->assertInstanceOf('StingerSoft\PlatformBundle\Service\Doctrine\TablePrefixService', $this->prefixService); |
80 | 80 | } |
81 | 81 | |
82 | - public function testSubscribedEvents() { |
|
82 | + public function testSubscribedEvents(){ |
|
83 | 83 | $this->assertArraySubset(array( |
84 | 84 | 'loadClassMetadata' |
85 | 85 | ), $this->prefixService->getSubscribedEvents()); |
86 | 86 | } |
87 | 87 | |
88 | - public function testSingleInheritanceWithoutRoot() { |
|
88 | + public function testSingleInheritanceWithoutRoot(){ |
|
89 | 89 | $cm = $this->mockEventArgs(); |
90 | 90 | $cm->method('isInheritanceTypeSingleTable')->will($this->returnValue(true)); |
91 | 91 | $cm->method('isRootEntity')->will($this->returnValue(false)); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $this->assertEquals($cm->associationMappings, self::$assocMappingBefore); |
97 | 97 | } |
98 | 98 | |
99 | - public function testloadClassMetadata() { |
|
99 | + public function testloadClassMetadata(){ |
|
100 | 100 | $cm = $this->mockEventArgs(); |
101 | 101 | $cm->method('isInheritanceTypeSingleTable')->will($this->returnValue(true)); |
102 | 102 | $cm->method('isRootEntity')->will($this->returnValue(true)); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $this->assertEquals($cm->associationMappings, self::$assocMappingAfter); |
108 | 108 | } |
109 | 109 | |
110 | - public function testInvalidNamespace() { |
|
110 | + public function testInvalidNamespace(){ |
|
111 | 111 | $cm = $this->mockEventArgs(); |
112 | 112 | $cm->method('isInheritanceTypeSingleTable')->will($this->returnValue(true)); |
113 | 113 | $cm->method('isRootEntity')->will($this->returnValue(true)); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $this->assertEquals($cm->associationMappings, self::$assocMappingBefore); |
120 | 120 | } |
121 | 121 | |
122 | - protected function mockEventArgs() { |
|
122 | + protected function mockEventArgs(){ |
|
123 | 123 | $cm = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->setConstructorArgs(array( |
124 | 124 | 'StingerSoftPlatform:User' |
125 | 125 | ))->getMock(); |
@@ -71,21 +71,21 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected $prefixService; |
73 | 73 | |
74 | - public function setUp() { |
|
74 | + public function setUp(){ |
|
75 | 75 | $this->prefixService = $this->createContainer()->get(TablePrefixService::SERVICE_ID); |
76 | 76 | } |
77 | 77 | |
78 | - public function testService() { |
|
78 | + public function testService(){ |
|
79 | 79 | $this->assertInstanceOf('StingerSoft\PlatformBundle\Service\Doctrine\TablePrefixService', $this->prefixService); |
80 | 80 | } |
81 | 81 | |
82 | - public function testSubscribedEvents() { |
|
82 | + public function testSubscribedEvents(){ |
|
83 | 83 | $this->assertArraySubset(array( |
84 | 84 | 'loadClassMetadata' |
85 | 85 | ), $this->prefixService->getSubscribedEvents()); |
86 | 86 | } |
87 | 87 | |
88 | - public function testSingleInheritanceWithoutRoot() { |
|
88 | + public function testSingleInheritanceWithoutRoot(){ |
|
89 | 89 | $cm = $this->mockEventArgs(); |
90 | 90 | $cm->method('isInheritanceTypeSingleTable')->will($this->returnValue(true)); |
91 | 91 | $cm->method('isRootEntity')->will($this->returnValue(false)); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $this->assertEquals($cm->associationMappings, self::$assocMappingBefore); |
97 | 97 | } |
98 | 98 | |
99 | - public function testloadClassMetadata() { |
|
99 | + public function testloadClassMetadata(){ |
|
100 | 100 | $cm = $this->mockEventArgs(); |
101 | 101 | $cm->method('isInheritanceTypeSingleTable')->will($this->returnValue(true)); |
102 | 102 | $cm->method('isRootEntity')->will($this->returnValue(true)); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $this->assertEquals($cm->associationMappings, self::$assocMappingAfter); |
108 | 108 | } |
109 | 109 | |
110 | - public function testInvalidNamespace() { |
|
110 | + public function testInvalidNamespace(){ |
|
111 | 111 | $cm = $this->mockEventArgs(); |
112 | 112 | $cm->method('isInheritanceTypeSingleTable')->will($this->returnValue(true)); |
113 | 113 | $cm->method('isRootEntity')->will($this->returnValue(true)); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $this->assertEquals($cm->associationMappings, self::$assocMappingBefore); |
120 | 120 | } |
121 | 121 | |
122 | - protected function mockEventArgs() { |
|
122 | + protected function mockEventArgs(){ |
|
123 | 123 | $cm = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->setConstructorArgs(array( |
124 | 124 | 'StingerSoftPlatform:User' |
125 | 125 | ))->getMock(); |