@@ -9,6 +9,9 @@ |
||
9 | 9 | private $collection = null; |
10 | 10 | private $mongo = null; |
11 | 11 | |
12 | + /** |
|
13 | + * @param Mongo $mongo |
|
14 | + */ |
|
12 | 15 | public function __construct($collection, $mongo = null) |
13 | 16 | { |
14 | 17 | $this->collection = $collection; |
@@ -9,11 +9,11 @@ |
||
9 | 9 | $config = Config::getInstance(); |
10 | 10 | |
11 | 11 | $config->setAll([ |
12 | - 'debug' => true, |
|
13 | - 'siteName' => 'Project Base', |
|
12 | + 'debug' => true, |
|
13 | + 'siteName' => 'Project Base', |
|
14 | 14 | |
15 | - // Project settings |
|
16 | - 'projectDir' => $projectDir |
|
15 | + // Project settings |
|
16 | + 'projectDir' => $projectDir |
|
17 | 17 | ]); |
18 | 18 | |
19 | 19 | if (file_exists($projectDir . '/config.json')) |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | $job = $queueJobs->pop(); |
19 | 19 | |
20 | 20 | $pid = ($job === null) ? 0 : pcntl_fork(); |
21 | - if ($job !== null && $pid === 0) return self::runJob($job); |
|
21 | + if ($job !== null && $pid === 0) { |
|
22 | + return self::runJob($job); |
|
23 | + } |
|
22 | 24 | $children[$pid] = true; |
23 | 25 | self::checkChildren($maxChildren, $children); |
24 | 26 | } |
@@ -50,7 +52,9 @@ discard block |
||
50 | 52 | |
51 | 53 | public static function addJobs() |
52 | 54 | { |
53 | - if (Redis::canRun(__CLASS__) === false) return; |
|
55 | + if (Redis::canRun(__CLASS__) === false) { |
|
56 | + return; |
|
57 | + } |
|
54 | 58 | |
55 | 59 | $jobs = Config::getInstance()->get("cronjobs", []); |
56 | 60 | foreach ($jobs as $className) { |
@@ -62,7 +66,9 @@ discard block |
||
62 | 66 | { |
63 | 67 | $class = new $className(); |
64 | 68 | |
65 | - if (!($class instanceof CronJob)) throw new IllegalException("$className is not an instanceof \\cvweiss\projectbase\\CronJob"); |
|
69 | + if (!($class instanceof CronJob)) { |
|
70 | + throw new IllegalException("$className is not an instanceof \\cvweiss\projectbase\\CronJob"); |
|
71 | + } |
|
66 | 72 | |
67 | 73 | $cron = \Cron\CronExpression::factory($class->getCron()); |
68 | 74 | if ($cron->isDue() && get_class($class) != basename(__CLASS__)) { |
@@ -59,8 +59,12 @@ |
||
59 | 59 | public function find(string $collection, array $query = [], array $sort = null, int $limit = 0):array |
60 | 60 | { |
61 | 61 | $options = []; |
62 | - if ($sort != null) $options['sort'] = $sort; |
|
63 | - if ($limit != 0) $options['limit'] = $limit; |
|
62 | + if ($sort != null) { |
|
63 | + $options['sort'] = $sort; |
|
64 | + } |
|
65 | + if ($limit != 0) { |
|
66 | + $options['limit'] = $limit; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | $query = new \MongoDB\Driver\Query($query, $options); |
66 | 70 | $cursor = $this->manager->executeQuery($this->database . ".$collection", $query); |
@@ -47,6 +47,6 @@ |
||
47 | 47 | |
48 | 48 | public static function output($text) |
49 | 49 | { |
50 | - echo date('Y-m-d H:i:s')." > $text\n"; |
|
50 | + echo date('Y-m-d H:i:s') . " > $text\n"; |
|
51 | 51 | } |
52 | 52 | } |
@@ -14,7 +14,9 @@ |
||
14 | 14 | $lastRun = microtime(); |
15 | 15 | |
16 | 16 | while (microtime() < $doneAt && $childrenCount < $maxChildren) { |
17 | - if (pcntl_fork()) return true; |
|
17 | + if (pcntl_fork()) { |
|
18 | + return true; |
|
19 | + } |
|
18 | 20 | $sleep = floor(($lastRun + $usleep) - microtime()); |
19 | 21 | usleep($sleep); |
20 | 22 | $childrenCount++; |
@@ -77,7 +77,9 @@ |
||
77 | 77 | protected function update(BulkWrite $bulk = null):bool |
78 | 78 | { |
79 | 79 | // If we have nothing to update then move along |
80 | - if (sizeof($this->updates) == 0) return true; |
|
80 | + if (sizeof($this->updates) == 0) { |
|
81 | + return true; |
|
82 | + } |
|
81 | 83 | |
82 | 84 | $commit = $bulk === null; |
83 | 85 | $bulk = $this->getBulkWriter($bulk); |
@@ -11,12 +11,16 @@ |
||
11 | 11 | $projectDir = basename($vendorDir) == 'vendor' ? dirname($vendorDir) : dirname(dirname(__DIR__)); |
12 | 12 | |
13 | 13 | $dirs = ['/view/', '/cache/', '/cache/jade']; |
14 | - foreach ($dirs as $dir) self::makeDir($projectDir . $dir); |
|
14 | + foreach ($dirs as $dir) { |
|
15 | + self::makeDir($projectDir . $dir); |
|
16 | + } |
|
15 | 17 | } |
16 | 18 | |
17 | 19 | private static function makeDir($dir) |
18 | 20 | { |
19 | - if (is_dir($dir)) return; |
|
21 | + if (is_dir($dir)) { |
|
22 | + return; |
|
23 | + } |
|
20 | 24 | echo "Creating directory: $dir\n"; |
21 | 25 | mkdir($dir); |
22 | 26 | } |
@@ -7,8 +7,8 @@ |
||
7 | 7 | $paths = [$config->get('projectDir') . '/view/', $config->get('projectDir') . '/vendor/cvweiss/project.base/view/']; |
8 | 8 | |
9 | 9 | $jade = new \Tale\Jade\Renderer([ |
10 | - 'paths' => $paths, |
|
11 | - 'pretty' => $config->get('debug', false), |
|
10 | + 'paths' => $paths, |
|
11 | + 'pretty' => $config->get('debug', false), |
|
12 | 12 | 'cachePath' => $config->get('cachePath', $config->get('projectDir') . '/cache/jade/'), |
13 | 13 | ]); |
14 | 14 |