Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ServiceStarter.php
Go to the documentation of this file.
1
<?php
2
namespace
Ubiquity\scaffolding\starter
;
3
4
use
Ubiquity\utils\base\UFileSystem
;
5
14
class
ServiceStarter
{
15
16
private
$servicesContent
;
17
18
private
$servicesName
;
19
20
private
function
loadServices
() {
21
$file = $this->
getServicesFilename
();
22
if
(\file_exists($file)) {
23
$this->servicesContent = UFileSystem::load($file);
24
}
25
}
26
27
private
function
getServicesFilename
() {
28
return \ROOT . \DS .
'config'
. \DS . $this->servicesName .
'.php'
;
29
}
30
31
public
function
__construct
(?
string
$servicesName
=
'services'
) {
32
$this->servicesName =
$servicesName
;
33
$this->
loadServices
();
34
}
35
36
public
function
getTemplateDir
() {
37
return \dirname(__DIR__) .
"/templates/services/"
;
38
}
39
40
public
function
addService
($serviceName) {
41
$file = $this->
getTemplateDir
() . $serviceName .
'.tpl'
;
42
if
(\file_exists($file)) {
43
$serviceContent = UFileSystem::load($file);
44
if
(\strpos($this->servicesContent, $serviceContent) ===
false
) {
45
$this->servicesContent = rtrim($this->servicesContent) .
"\n"
. $serviceContent;
46
}
47
}
48
}
49
50
public
function
addServices
(array $services) {
51
foreach
($services as $service) {
52
$this->
addService
($service);
53
}
54
}
55
56
public
function
save
() {
57
return
UFileSystem::save($this->
getServicesFilename
(), $this->servicesContent);
58
}
59
}
60
Ubiquity\scaffolding\starter\ServiceStarter
Ubiquity\scaffolding\starter$ServiceStarter This class is part of Ubiquity.
Definition
ServiceStarter.php:14
Ubiquity\scaffolding\starter\ServiceStarter\addServices
addServices(array $services)
Definition
ServiceStarter.php:50
Ubiquity\scaffolding\starter\ServiceStarter\getServicesFilename
getServicesFilename()
Definition
ServiceStarter.php:27
Ubiquity\scaffolding\starter\ServiceStarter\$servicesContent
$servicesContent
Definition
ServiceStarter.php:16
Ubiquity\scaffolding\starter\ServiceStarter\loadServices
loadServices()
Definition
ServiceStarter.php:20
Ubiquity\scaffolding\starter\ServiceStarter\$servicesName
$servicesName
Definition
ServiceStarter.php:18
Ubiquity\scaffolding\starter\ServiceStarter\getTemplateDir
getTemplateDir()
Definition
ServiceStarter.php:36
Ubiquity\scaffolding\starter\ServiceStarter\addService
addService($serviceName)
Definition
ServiceStarter.php:40
Ubiquity\scaffolding\starter\ServiceStarter\save
save()
Definition
ServiceStarter.php:56
Ubiquity\scaffolding\starter\ServiceStarter\__construct
__construct(?string $servicesName='services')
Definition
ServiceStarter.php:31
Ubiquity\utils\base\UFileSystem
File system utilities Ubiquity\utils\base$UFileSystem This class is part of Ubiquity.
Definition
UFileSystem.php:16
Ubiquity\scaffolding\starter
Definition
ServiceStarter.php:2
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity-dev
src
Ubiquity
scaffolding
starter
ServiceStarter.php
Generated on Sun Dec 10 2023 15:04:09 for
Ubiquity
by
doxygen
1.9.8