Skip to content

Commit fbc9b5e

Browse files
committed
formatting
1 parent 7cc120e commit fbc9b5e

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

src/Illuminate/Support/Facades/Blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @method static void compile(string|null $path = null)
1616
* @method static void component(string $class, string|null $alias = null, string $prefix = '')
1717
* @method static void components(array $components, string $prefix = '')
18-
* @method static void componentNamespace(string $namespace)
18+
* @method static void componentNamespace(string $namespace, string $prefix)
1919
* @method static void directive(string $name, callable $handler)
2020
* @method static void extend(callable $compiler)
2121
* @method static void if(string $name, callable $callback)

src/Illuminate/View/Compilers/ComponentTagCompiler.php

+20-19
Original file line numberDiff line numberDiff line change
@@ -276,40 +276,41 @@ public function componentClass(string $component)
276276
}
277277

278278
/**
279-
* Guess the class name for the given component.
279+
* Find the class for the given component using the registered namespaces.
280280
*
281281
* @param string $component
282-
* @return string
282+
* @return string|null
283283
*/
284-
public function guessClassName(string $component)
284+
public function findClassByComponent(string $component)
285285
{
286-
$namespace = Container::getInstance()
287-
->make(Application::class)
288-
->getNamespace();
286+
$segments = explode('::', $component);
289287

290-
$class = $this->formatClassName($component);
288+
$prefix = $segments[0];
291289

292-
return $namespace.'View\\Components\\'.$class;
290+
if (! isset($this->namespaces[$prefix]) || ! isset($segments[1])) {
291+
return;
292+
}
293+
294+
if (class_exists($class = $this->namespaces[$prefix].'\\'.$this->formatClassName($segments[1]))) {
295+
return $class;
296+
}
293297
}
294298

295299
/**
296-
* Find the class for the given component.
300+
* Guess the class name for the given component.
297301
*
298302
* @param string $component
299-
* @return string|null
303+
* @return string
300304
*/
301-
public function findClassByComponent(string $component)
305+
public function guessClassName(string $component)
302306
{
303-
$pieces = explode('::', $component);
304-
$prefix = $pieces[0];
307+
$namespace = Container::getInstance()
308+
->make(Application::class)
309+
->getNamespace();
305310

306-
if (! isset($this->namespaces[$prefix]) || ! isset($pieces[1])) {
307-
return;
308-
}
311+
$class = $this->formatClassName($component);
309312

310-
if (class_exists($location = $this->namespaces[$prefix].'\\'.$this->formatClassName($pieces[1]))) {
311-
return $location;
312-
}
313+
return $namespace.'View\\Components\\'.$class;
313314
}
314315

315316
/**

0 commit comments

Comments
 (0)