@@ -68,6 +68,13 @@ class GearmanParser
6868 */
6969 private $ bundles ;
7070
71+ /**
72+ * @var array
73+ *
74+ * Namespaces paths to be searched
75+ */
76+ private $ resources ;
77+
7178 /**
7279 * @var array
7380 *
@@ -82,13 +89,21 @@ class GearmanParser
8289 */
8390 private $ defaultSettings ;
8491
92+ /**
93+ * Root kernel directory
94+ *
95+ * @var string
96+ */
97+ private $ rootDir ;
98+
8599 /**
86100 * Construct method
87101 *
88102 * @param KernelInterface $kernel Kernel instance
89103 * @param Reader $reader Reader
90104 * @param Finder $finder Finder
91- * @param array $bundles Bundle array where to parse workers, defined on condiguration
105+ * @param array $bundles Bundle array where to parse workers, defined in configuration
106+ * @param array $resources Array of namespace paths to be searched for worker annotations
92107 * @param array $servers Server list defined on configuration
93108 * @param array $defaultSettings Default settings defined on configuration
94109 */
@@ -97,6 +112,7 @@ public function __construct(
97112 Reader $ reader ,
98113 Finder $ finder ,
99114 array $ bundles ,
115+ array $ resources ,
100116 array $ servers ,
101117 array $ defaultSettings
102118 )
@@ -106,8 +122,10 @@ public function __construct(
106122 $ this ->reader = $ reader ;
107123 $ this ->finder = $ finder ;
108124 $ this ->bundles = $ bundles ;
125+ $ this ->resources = $ resources ;
109126 $ this ->servers = $ servers ;
110127 $ this ->defaultSettings = $ defaultSettings ;
128+ $ this ->rootDir = $ this ->kernel ->getRootDir ();
111129 }
112130
113131 /**
@@ -117,7 +135,8 @@ public function __construct(
117135 */
118136 public function load ()
119137 {
120- list ($ paths , $ excludedPaths ) = $ this ->loadNamespaceMap ($ this ->kernelBundles , $ this ->bundles );
138+ list ($ paths , $ excludedPaths ) = $ this ->loadBundleNamespaceMap ($ this ->kernelBundles , $ this ->bundles );
139+ $ paths = array_merge ($ paths , $ this ->loadResourceNamespaceMap ($ this ->rootDir , $ this ->resources ));
121140
122141 return $ this ->parseNamespaceMap ($ this ->finder , $ this ->reader , $ paths , $ excludedPaths );
123142 }
@@ -132,7 +151,7 @@ public function load()
132151 *
133152 * @return array Return an array containing paths and ignore paths
134153 */
135- public function loadNamespaceMap (array $ kernelBundles , array $ bundles )
154+ public function loadBundleNamespaceMap (array $ kernelBundles , array $ bundles )
136155 {
137156 $ paths = array ();
138157 $ excludedPaths = array ();
@@ -177,6 +196,19 @@ public function loadNamespaceMap(array $kernelBundles, array $bundles)
177196 );
178197 }
179198
199+ /**
200+ * Get resource paths
201+ * @param string $rootDir
202+ * @param array $resources
203+ * @return array
204+ */
205+ public function loadResourceNamespaceMap ($ rootDir , array $ resources )
206+ {
207+ return array_map (function ($ resource ) use ($ rootDir ) {
208+ return $ rootDir . '/ ' . trim ($ resource , '/ ' ) . '/ ' ;
209+ }, $ resources );
210+ }
211+
180212 /**
181213 * Perform a parsing inside all namespace map
182214 *
0 commit comments