Skip to content

Commit 7b2a634

Browse files
author
Wazabii
committed
Better naming
1 parent 8021d82 commit 7b2a634

File tree

1 file changed

+12
-39
lines changed

1 file changed

+12
-39
lines changed

SwiftRender.php

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,20 @@ public function setContainer(ContainerInterface $container): void
7474
* Get container instance
7575
* @return ContainerInterface
7676
*/
77-
public function getContainer(): ContainerInterface
77+
public function provider(): ContainerInterface
7878
{
7979
return $this->container;
8080
}
8181

82+
/**
83+
* Get container instance
84+
* @return ContainerInterface
85+
*/
86+
public function getContainer(): ContainerInterface
87+
{
88+
return $this->provider();
89+
}
90+
8291
/**
8392
* Set a default file ending (".php" is pre defined)
8493
* @param string $ending
@@ -232,48 +241,11 @@ public function setPartial(string $partial, array $args = array()): self
232241
$this->setFile($file);
233242
}
234243
$func = $this->build($this->file, $args);
235-
236-
237-
238244
$this->partial[$key][$key2] = $func;
239245

240246
return $this;
241247
}
242248

243-
/**
244-
* Create a partial view
245-
* @param string $keyA Filename/key
246-
* @param string|array $keyB Args/filename
247-
* @param array $keyC Args
248-
*/
249-
public function setPartialOLD(string $keyA, string|array $keyB = array(), array $keyC = array()): self
250-
{
251-
$partial = $keyB;
252-
if (is_array($keyB)) {
253-
$keyC = $keyB;
254-
$partial = $keyA;
255-
}
256-
257-
if (is_null($this->file)) {
258-
$this->setFile($keyA);
259-
}
260-
$func = $this->build($this->file, $keyC);
261-
262-
if(empty($this->partial[$partial]) || is_string($keyB)) {
263-
if(is_string($partial) && $partial[0] === "!") {
264-
$partial = substr($partial, 1);
265-
$this->partial[$partial] = [$func];
266-
267-
} else {
268-
$this->partial[$partial][] = $func;
269-
}
270-
271-
} else {
272-
$this->partial[$partial] = [$func];
273-
}
274-
return $this;
275-
}
276-
277249
/**
278250
* Unset a setted partial
279251
* @param string $key Partal key, example: ("sidebar", "breadcrumb")
@@ -455,7 +427,7 @@ private function build(string|callable $file, array $args = array()): callable
455427
$file = substr($file, 1);
456428
$throwError = false;
457429
}
458-
$filePath = "{$dir}{$file}.{$this->ending}";
430+
$filePath = realpath("{$dir}{$file}.{$this->ending}");
459431
if (is_file($filePath)) {
460432
if (is_array($argsFromFile) && count($argsFromFile) > 0) {
461433
$args = $argsFromFile;
@@ -464,6 +436,7 @@ private function build(string|callable $file, array $args = array()): callable
464436
break;
465437

466438
} else {
439+
467440
$missingFiles[] = $file;
468441
}
469442
}

0 commit comments

Comments
 (0)